开发者

How to revert to an earlier revision of a project in Perforce following a deletion?

Let's say I have a project under //depot/MyProject. At changelist 1001, this project took a major 开发者_运维百科change in direction, changing everything about it. At changelist 2001, it got p4 deleted. The depot is now at change 3000.

I'd like to restore //depot/MyProject back to its state at changelist 1000. Specifically, I'd like the revision history to record the fact that change 3001 is an integration of change 1000 - i.e. the last version of this project before the major change.

Can Perforce do this at all? Or do I have to rename it into something like //depot/MyProjectOriginal, because //depot/MyProject is now tainted with all those deleted revisions?

(the naive attempt to p4 integrate //depot/MyProject/...@1000 //depot/MyProject/... fails with an "all revision(s) already integrated" message)


You cannot force the integration.

You have two options: you can create a branch using changelist 1000 as the base; or sync to changelist 1000, check out all files, and then submit (a.k.a rolling back).

Option 1

If you do want the history of your changes between 1001-3000 (i.e. a fresh start from changelist 1000) then this is the better option. Using P4V, create a new branchspec and then perform an integrate from your current project to the new branch at changelist 1000. This will be submitted as changelist 3001, when you compare differences between revisions, you will not see of the changes between 1001-3000.

In the P4 visualizer this will appear as a new branch creation at 1000.

Option 2

Sync to changelist 1000, check out all files, and then submit. There should not be any conflicts to resolve. This will be submitted as changelist 3001, however when you review history you will see the everything.

I hope this makes sense, any questions, please ask.


I don't believe that you can integrate files on top of one another like that. I think that you have two options.

If you are willing to move the files, you can do a

p4 integ //depot/MyProject/...@1000 //depot/MyOriginal/Project/...

and that will integrate MyProject at changelist 1000 to the new location.

If you'd like to keep the project at the same place, you can do that as well. It's really easiest in p4v - you can right click on the folder in workspace or depot view and choose "rollback...". In the subsequent dialog, you can then pick a changelist (or date, revision, etc) to roll the folder back to. In your case, I think that you would choose changelist 1000. Stick the files into a new pending changelist (I think that this is always good practice). You can then run a preveiw (to see what would happen), save the contents to a new changelist (so that you can inspect file contents before submitting), or just go for broke and pull the trigger and submit (I generally wouldn't recommend this).

HTH


Just do:

p4 copy //depot/MyProject/...@1000 //depot/MyProject/...

This also make a nice revision graph.


Though there is an accepted answer and plenty of other solutions, none of them works for me coz I need to rollback a large directory (with GBs of data)

Here is the way I used, which works fine for huge directory: (Suggested to do in a new and clean workspace, though not strictly required)

Assuming the directory to rollback is //depot/foo/bar and you want to rollback to changelist 1234

  • Make sure no one is locking any files, and make sure the directory you are trying to rollback exists in your client spec
  • p4 copy -v //depot/foo/bar/...@1234 //depot/foo/bar/...
  • p4 submit

p4 copy -v is the meat of the solution. It tells Perforce server to perform virtual copy, which means Perforce copies the files but not actually in your workspace. This avoid huge data transfer for file content (when copying and when submitting). In my case, by using "rollback" in P4V (which is doing non-virtual copy), it took over an hour just for copy, and over an hour for submit for my folder. With virtual copy, whole process took me around 1 minute.

The most important thing is, it keep a sensible history. You can see your files being updated and rolled back, and all previous history exists.


use p4 integrate -f //depot/MyProject/...@1000 //depot/MyProject/...

The -f flag means force an integration even if they have already been integrated. From http://www.perforce.com/perforce/doc.current/manuals/cmdref/integrate.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜