My workflow for testing my changes to our source code on a remote machine is the following:
1) On local machine: Shelve changes that I'd like to test
2) On remote machine (ssh):
$ p4 revert //...
$ p4 sync
$ p4 unshelve -s <changelist number>
$ ./run_test_scripts
This seems to work fine when I've only made changes to files that already exists. If I've added new files these will be created during p4 unshelve, but not deleted during p4 revert. The documentation says that this is what p4 revert does so it isn't unexpected, but causes some problems if I want to test the same files again:
$ p4 revert //...
<some file>#none - was add, abandoned
$ p4 sync
File(s) up-to-date.
$ p4 unshelve -s <changelist number>
Can't clobber writable file <some file>
Is there way I can delete the files abandoned Perforce?
I think what you're looking for is p4 revert -w. From the help:
The -w flag causes files that are open for add to be deleted from the workspace when they are reverted.
Note: I'm using the 2013.2/719516 client against a 2013.2/708877 server, in case that switch was added recently...
Edit: just reread your question - this is a workaround, perhaps not a full solution...
There is a setting in P4Win that allows you to overwrite files when unshelving:
Overwrite workspace files even if they are writeable
I normally use that in combination with another option (again in the gui):
Revert checked our files before unshelving
They solve my problem.
Looking in the console output while running this from the gui, it looks like it is the -f parameter in the unshelve command.
p4 unshelve -s <changelist> -f -c <changelist> <files>
Related
TL;DR: How do I sync an existing p4 workspace to a new label, so that all my previous changes are undone, and it is as good as a new sync?
Hi,
I have a perforce workspace synced to a label L1.
I added/deleted/edited a few files
I moved a few files inside a folder (mv a.txt b.txt new_folder/)
I want to cleanly sync this workspace to label L2 now.
I already removed all shelved and pending changelists, then tried
p4 reconcile -w ... && p4 revert -w ... && p4 sync ...#L2
Looks like it almost works, except that the files I moved inside a new folder do not get synced (p4 sync -f works though). But I do not want to use p4 sync -f on the entire workspace, as it would resync the unchanged files as well.
I am sorry if this question has been answered before, I am pretty new to perforce, so maybe could not find the correct terms to search for.
The ... path limits the scope of each operation to the current directory; if you ran those commands from a different directory than the one you moved the files to, that may be why they didn't get synced. I'd do:
p4 revert //...
p4 clean //...
p4 sync #L2
I opened a bunch of files using p4 edit in my workspace and after making some changes on each of them, I decided to put them up for review so I staged them using p4 change and I got a number to mark the changelist. Once I did that I am not able to see the actual changes made in the workspace. The files have gone to a version prior to my p4 edit.
How do I revert my workspace to a changes pointing to a change-list?
p4 undo -c 403767
p4 undo #403767
p4 switch #403767
p4 revert -c 403767
None of the above seems to work. Also when I do a p4 opened -u <author-name> I have a string that says integrate change 403767 (text) for all the files listed.
The integrate change 403767 indicates that these files are open for integrate, so these can't be the files that you opened with p4 edit.
Files can be opened for integrate by the p4 integrate, p4 copy, p4 merge, or p4 undo command.
Further, if a file is listed by p4 opened, its current working state is already in your workspace. If you had opened the file for edit and neither reverted nor submitted it, p4 opened would say edit change 403767 and your edits would be in your workspace.
I will hazard a guess that what you are actually trying to do is integrate changes from another branch, and you're confused because those changes do not yet appear in your workspace. Run:
p4 resolve -am
p4 resolve
That might get things into the state you're expecting.
According to the p4 help revert, I get:
The -w flag causes files that are open for add to be deleted from the
workspace when they are reverted.
But, when I try to use the -w, I get the following:
> p4 revert -w ./dir1/newfile.c
//depot/test/dir1/newfile.c#1 - was add, reverted
> ls ./dir1/newfile.c
./dir1/newfile.c
Am I missing something, or is this a bug in p4? (Note: my version is as follows):
Proxy version: P4P/LINUX26X86_64/2014.2/1099171 (2015/06/16)
"p4 revert" only undoes the operations that haven't been submitted yet.
It will not delete the file from disk. You should delete the file separately after reverting.
I am trying to move a crazy amount of files on perforce.
It was almost done on my first attempt using p4 integ -v
However, the integ command 'copies' the selected files.
I have to delete the source files and leave only target files for some reason.
Next, I tried p4 move command. This command has no -v option with it.
It is also impossible to sync all files to my local machine. (tens of TB)
Does anyone know how to perform p4 move without actually sync it?
Now, I've tried -k option to fake perforce out:
p4 sync -k //src_dir/...
p4 edit //src_dir/...
p4 move -k //src_dir/... //tar_dir/...
But Perforce reports submit failed because I don't have //tar_dir in my local machine. Did I missed anything?
Unless you specifically require the "p4 move" semantics (e.g. maintaining atomicity of each add/delete pair when integrating to other branches -- and since it sounds like you're doing this on an entire branch or even multiple branches I'm guessing you DON'T want that), I'd recommend doing:
p4 copy -v //src_dir/... //tar_dir/...
p4 sync -k //src_dir/...
p4 delete -k //src_dir/...
p4 submit
How can I grab my local changelist and send it to someone else in Perforce? More specifically, I would like to send unsubmitted changes from a local pending changelist to another user's pending changelist.
set P4DIFF=C:\cygwin\bin\diff.exe
p4 diff -du -c 12345 > patch-to-head.diff
# On Other machine
patch -p1 < patch-to-head.diff
I may be wrong on the env var there, and you might have to do some fixups on the diff file, but the general idea is that you generate a GNU Unified Diff, that you can send to people that can use GNU patch to apply it.
P4 now has native support for the shelve operation in 2009.2. Both the client and server need to be at least 2009.2 to use this.
http://blog.perforce.com/blog/?p=1872
To shelve your pending changelist YOURCHANGE:
p4 shelve [-c YOURCHANGE]
The other user then does:
p4 unshelve -s YOURCHANGE [-c THEIRCHANGE]
In either case the "-c" arg can be omitted to use the default changelist instead. In the p4 shelve case it means a new changelist will be created and the files in your default changelist will be shelved into it; in the p4 unshelve case it means the shelved files from your changelist will be unshelved into the other user's default changelist.
Not sure exactly what you are trying to do, but you may also want to consider P4_Shelve. It allows you to put a load of pending changes away on a virtual shelf, and then grab them back again later. Depending on what exactly you want to achieve by sending a changelist to someone else, this could provide a part of the answer.
Linked from the P4Shelve site is P4Tar which may also be useful - this does all the packing on the client side so you just get left with a file you can send to someone else.
Perforce 2016, osx. Diff for pending changelist:
mac:src user$ cl=123456 && p4 diff -du $( p4 files #=$cl | sed s/#.*// ) > $cl.diff
output: 123456.diff
Applying patch:
mac:src user$ patch -p0 < 123456.diff