What happens when copying a document that is being edited on Windows10? - windows-10

I found my backup and sync program (Icedrive) never completes on my windows 10 computer, and I fear it is due to it resetting the copying progress when the file is edited.
I'm not talking about appending to document but rather the follow scenario
0.Initial
original | 012345
copied |
1.Copied half-way
original | 012345
copied | 012
2.Edited
original | 0a23c5
copied | 012
3.What to do now?
3.1 Continue to copy but the file is corrupt
original | 0a23c5
copied | 0123c5
3.2 Restarting
original | 0a23c5
copied |

Related

Retrieving the current change list number of a Perforce Workspace including reverts

The command p4 changes -m1 //path/to/your/project/...#have to get the current changelist, as shown by this solution, works great until we have a commit that reverts the commit immediately before it.
For example, if I have the following setup:
4 - CL#3 was reverted and submitted here
3 - Somebody submitted this CL
2 - <= Current workspace is here
1
0
I run p4 changes -m1 //path/to/your/project/...#have, I get 2 as expected
I then sync to 4 and run the command again, but I still get 2. I assume this is because there is no new file locally and perforce still thinks I am on 2 when I should be on 4.
This is an issue because it breaks some scripts that run on new CLs that are coming in. Is it possible to either ignore such CLs or adjust the command in some way to know that are on 4 even though there are no file changes (because 4 is a revert of 3)?
Reproducing your setup by adding a file in change 3 and then deleting it in change 4, we can indeed see that changes -m1 #have returns change 2:
Sams-MacBook-Pro:test samwise$ p4 changes
Change 4 on 2023/01/26 by samwise#samwise-dvcs-1517552832 'delete ola'
Change 3 on 2023/01/26 by samwise#samwise-dvcs-1517552832 'add ola'
Change 2 on 2023/01/26 by samwise#samwise-dvcs-1517552832 'add bar'
Change 1 on 2023/01/26 by samwise#samwise-dvcs-1517552832 'add foo'
Sams-MacBook-Pro:test samwise$ p4 sync #4
#4 - file(s) up-to-date.
Sams-MacBook-Pro:test samwise$ p4 changes -m1 "#have"
Change 2 on 2023/01/26 by samwise#samwise-dvcs-1517552832 'add bar'
This is because changes -m1 #have is just returning the maximum change among those returned by p4 files #have:
Sams-MacBook-Pro:test samwise$ p4 files "#have"
//stream/main/test/bar#1 - add change 2 (text)
//stream/main/test/foo#1 - add change 1 (text)
We do not have any file belonging to change 4, because change 4 consists solely of deleted revisions, which by definition are never synced to the workspace.
Sams-MacBook-Pro:test samwise$ p4 files #=4
//stream/main/test/ola#2 - delete change 4 (text)
When we sync to change 4, we don't get ola#2, we get ola#none, exactly as if we'd synced to change 2 (or any change where ola does not exist as a non-deleted file):
Sams-MacBook-Pro:test samwise$ p4 sync #4
#4 - file(s) up-to-date.
Sams-MacBook-Pro:test samwise$ p4 sync #2
#2 - file(s) up-to-date.
Sams-MacBook-Pro:test samwise$ p4 have ola
ola - file(s) not on client.
At this point it's actually equally correct to say that we're synced to either change 2 or change 4, since either will give us the same set of files. In fact, if we diff the depot at those two changelists, we can see that those two points in time are effectively identical:
Sams-MacBook-Pro:test samwise$ p4 diff2 -q ...#2 ...#4
...#2 - no differing files.
If we want to divine change 4 from our current sync state rather than just the effectively identical change 2, the p4 cstat command is a useful tool -- this will iterate through all the changes for which our workspace contains all revisions up to that point:
Sams-MacBook-Pro:test samwise$ p4 cstat
... change 1
... status have
... change 2
... status have
... change 4
... status have
Since we have all changes up thru 4 according to p4 cstat, that is likely to be the best answer to the question "what change am I synced to?"

Is it possible to find top 10 changed file of type in perforce

In software maintenance the quality of a class can be hinted by looking at the number of changes that this file has gone through over time.
Is it possible to list top files with most revisions in perforce, given a specific file type, eg. java-file.
I've found the p4 filelog command, but the output that I want is a bit different:
# rank filename revisions
-------------------------------------
1 BuggyFile1.java 63
2 BuggyFile2.java 37
3 BuggyFile3.java 15
4 BuggyFile4.java 14
... aso
Any ideas how to get hold of such list?
Note: My project depot contains 15 000+ files
Use p4 files to get the list of files and revisions, reformat the output to put the revision first, and then sort by revision in descending order:
% p4 -Ztag -F "%rev% %depotFile%" files //....java | sort -rn
63 BuggyFile1.java
37 BuggyFile2.java
15 BuggyFile3.java
14 BuggyFile4.javaj
With a little more scripting you can get it in the exact format you describe, but hopefully that simple command gives you a good starting point.

direct access and update section of file on hard disk

I wonder if I can do the following and how:
I have an extremely large file in a fixed width format stored in a hard disk with *NIX system. I want to know if one can do update on a portion of the big file without read in and write out the entire file in the memory. For example of the following file, I want to go to a specific location "5" on the hard disk and replace only the content EE to ZZ without rewrite the entire file.
1 AA
2 BB
3 CC
4 DD
5 EE ->ZZ
6 FF
7 GG
8 HH
9 II
.. ..
Regardless of programming language, is this possible?
That's easy to do, as long as you replace contents with new contents - you can't add or remove anything. Think of the file contents as a long strip of tape stuck to a table. You can cut out a piece of tape and replace it with another piece of the exact same length without disturbing the rest of the tape. But if you want to replace the piece you cut out with a shorter or longer piece, you have to pull up lots of tape and stick it back down somewhere else to keep a continuous strip of tape.

awk/sed/grep command to compare the contents of three files

Hi I am trying to automate some data entry, and I am using a tcp server/client to send filenames around for other server to go into a repository and pull these files. as part of testing this I am running the program with logging the filenames that are supposed to be sent, what was received, and if it got received I am sending a reply back with the filename.
so I have three text files with file names inside of them.
SupposedToSend.txt
Recieved.txt
GotReplyFor.txt
I know that awk could do what I am trying to do but I am not sure how to set it up, I need to compare the three files for elements that does not exists in any of the other files, so if one entry is missing from any file i need to know which one and from which file.
I can write a program for this which will take much longer to write and to run since these files are getting 5 elements/minute dumped into them
paste -d '\n' SupposedToSend.txt Recieved.txt GotReplyFor.txt | uniq -c | grep -v '^ 3'
It's tolerable if you have no errors, deeply suboptimal otherwise. Or if the data in the different files is out of sequence... (In which case you might need to sort them somehow.)
Or you could just run diff3 to compare 3 files...

Controlling placement of non-x utility programs using xinit

Just getting started with linux programming and X Windows in specific. I am trying to make an application where I launch 4 different programs (such as VLC, web browser etc) in a quadrant view. For now I don't need (or want) an window manager sitting on top, just the bare bones applications running.
I can do this with the x utils (like a clock etc) using the -geometry commands.
My question is, how do I control the placement of these other applications?
Solution 1
devilspie is the perfect tool for this. As an example:
+--------+------------------------+
| Pidgin | |
| Buddy | Pidgin |
| List | Conversation |
| | |
| +------------------------+
| | |
| | Xchat |
| | |
| | |
+--------+------------------------+
could be done with the following configuration.
(if (is (application_name) "Pidgin")
(begin
(if (is (window_role) "buddy_list")
(begin
(undecorate)
(skip_tasklist)
(geometry "199x767+0+0")
)
)
(if (is (window_role) "conversation")
(begin
(undecorate)
(geometry "822x400+201+0")
)
)
)
)
Solution 2
start the desired applications and then use wmctrl to move and resize the windows to their desired positions. You may use the -r argument to acheive this.
-r <WIN> -e <MVARG> Resize and move the window around the desktop.
Devilspie experience (update)
As requested in the comment. I use devilspie all the time, it's really great and works with every window manager I've used gnome, xfce, kde, fvwm. I've put together a working devilspie config that will do part of what you want. You can place this file in ~/.devilspie/devilspie.ds. There is a screenshot attached as well showing the result of this config file. The best documentation I have found for devilspie is on foosel.org. I highly recommend you use that. when testing devilspie run it in the foreground in a terminal. Make sure there are no other devilspie process running kill them if so. Every time you change your config and want to see the result do a CTRL+C on the devilspie and run it again. Some other things to keep note of if vlc was maximized when it was closed, then it will open again maximized and will ignore devilspie requests for resizing and moving. So make sure vlc is not maximized when you close it. You could alternatively call unmaximize and then do the geometry call.
(debug)
(if
(is (application_name) "VLC media player")
(geometry "500x300+0+0")
)
(if
(is (application_name) "xterm")
(geometry "300x300+510+0")
)
(focus)
screetshot

Resources