Note: this question is related to, but not a duplicate of How do you clear the default changelist without altering your worktree in Perforce
. My argument is that, while similar, this question is specifically with regards to the P4V client.
Suppose I'm using perforce to track a file. The current state of the file (file1
) is identical on the server Depot
, and the local Filesystem
For illustration purposes, I will also show the current 'state' of the default Changelist:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file1 | file1 | <empty> |
If I make a change offline (file1
is now file2
), perforce won't know about it yet (I am aware that ideally this shouldn't happen and that all changes should always be tracked, and that the file should have been write protected, but it can if perforce isn't running, the moon is in the wrong quarter, etc. so for the sake of argument, suppose that this did in fact occur):
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file1 | file2 | <empty> |
If I Reconcile Offline Work...
or have the file get added manually to the changelist, the changelist now is aware of this change:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file1 | file2 | file1 -> file2 |
If I then submit the changelist, the change it currently has tracked is applied on the server, and the changelist is once again empty:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file2 | file2 | <empty> |
Suppose I've made a change and tracked it. The local filesystem is changed (file2
is now file3
), and the changelist reflects that:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file2 | file3 | file2 -> file3 |
Suppose then that I now want to move back to the state where the workspace/changelist is unaware of file2
having been changed to be file3
, but without actually modifying the file on disk:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file2 | file3 | <empty> |
note how filesystem still is in state file3
, not file2
What would it take to do that? Is there a way to perform this action without backing up the change out of the workspace and reverting completely or running 'clean' and then re-applying the change offline?
I know I don't want to just 'revert' the change, because that reverts not just the state of the changelist but also of the file locally:
| Depot | Filesystem | Changelist |
|-------+------------+----------------|
| file2 | file2 | <empty> |
note how filesystem has lost state file3
and was also reverted to file2
How can I 'revert' my changelist/workspace to no longer track a change without the file in my local filesystem being reverted, or modified in any way?
I'm using the P4V v2015.2
It is not possible using just the P4V UI (at least in v2015.2).
However it is possible through the commandline, where the 'revert' command has a -k
flag, which p4 help revert
explains as:
The -k flag marks the file as reverted in server metadata without altering files in the client workspace.
I am aware that this was discussed in a similar question here: How do you clear the default changelist without altering your worktree in Perforce - but neither the question nor the selected answer mention the P4V client, so I'm writing a more detailed explanation below in case it benefits someone.
Right click anywhere in your workspace view and choose Open Command Window Here
Enter the following command: p4 revert -k -c default //...
-k
flag means to not modify local files when reverting the changelist-c
flag specifies the changelist you want. Use default
or the exact changelist number you want to untrack the files in.//...
means all files in the workspace. Note that this is always still limited to the files in the changelist you specified with -c
!Once you've run that command it will list each pending change that was removed from the changelist.
Whether or not such an action should be performed is up to the reader's discretion, and the warning in the other answer should be taken into consideration.
My main use case has been where files already in the changelist were for some reason removed, moved, or renamed without those actions getting tracked.
Yes, ideally those changes should have been tracked, and I probably have to look into my workflow to avoid this in the future. Nonetheless, attempting to submit the changelist while in this state can cause errors since those 'pending changes' don't technically exist anymore.
To avoid this I've found it easiest to clear the changelist with the -k
flag as described above, removing the old changes that were no longer representative of the local filesystem, and then running Reconcile Offline Work...
on all relevant directories to get just the current latest state into the changelist, and then submitting that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With