Jump to content


Copying a Revision of a file to a new location in the client workspace.

Revision new location copy branching

  • Please log in to reply
5 replies to this topic

#1 raysid

raysid

    Member

  • Members
  • PipPip
  • 12 posts

Posted 12 May 2015 - 10:04 AM

Hi.

Consider a situation, where i have a file at C:\users\user1\clientworkspace1\folder1\hello.c. Say it has got 6 revisions available. What i need is, I want to copy say the 4th revision of file hello.c  to a new location without updating (i.e. syncing) to the latest copy of hello.c. So I may need to keep this 4th copy at say C:\users\user1\clientworkspace1\folder1\Revisions\hello.c where hello.c is the 4th revision in Revisions folder. Do i need to do any branching for this as i just need a copy of 4th revision to be placed at my revisions folder. There is no need to make a revisions folder at the depot.
I need to attain this by running a .bat file in windows.

Please provide a solution.

#2 P4Jen

P4Jen

    Advanced Member

  • Staff Moderators
  • 147 posts

Posted 12 May 2015 - 01:06 PM

Hi,

One method is to sync the revision you need to the workspace, then use OS commands to copy it to the other folder on
your machine.

For example:

  p4 sync //depot/myfile#3

will sync the third revision of the file to the workspace.

Once you have copied the file, you can sync the latest (head) revision to the workspace.

Note this approach must not be used with 'p4 reconcile', because Perforce will detect the file in the new location and open it for add.

You may also want to use a .p4ignore file, to make sure this file never gets added, if you run 'p4 add' on the directory where it resides.

Out of interest why do you need different revisions of the same file in the same workspace?

Hope this helps,
Jen.


#3 P4Sam

P4Sam

    Advanced Member

  • Members
  • PipPipPip
  • 484 posts
  • LocationSan Francisco, CA

Posted 12 May 2015 - 04:44 PM

The command you want is:

p4 print -o C:\users\user1\clientworkspace1\folder1\Revisions\hello.c C:\users\user1\clientworkspace1\folder1\hello.c#4

I'll echo Jen's caution about using .p4ignore (or a client view exclusion) so you don't end up adding this folder back to the depot and her curiosity about why you're doing this.  We have version control systems precisely so that we don't need to do things like keep old versions in a folder.  :)

#4 raysid

raysid

    Member

  • Members
  • PipPip
  • 12 posts

Posted 13 May 2015 - 09:30 AM

The answer to keeping Old Revision related to a workspace goes like this. In the phase of development cycle as i found, there are multiple users who use and write codes with changes. There are some peers who don't have access or requirement of access to that workspace due to varying reasons but has some improvements related to an idea which was once used in a revision and now discarded in the latest one. So since its always a big job(also unnecessary) to keep and manage a complete database of old revisions, the idea is to get those revisions when needed, share it with peers and do test and when over, just discard it with an update to the latest copy. Now since this test will be done by various users who may or maynot have same permission levels to access, the local copy of revision can be shared from the one who has permission for it. Some how this requirement came up and it was thought to have a solution this way.
Thanks for the informative reply @P4Jen and @P4Sam. Please put your thoughts on this requirement scenario and if there is a better way by P4?  By the time let me try out the details provided.

#5 P4Sam

P4Sam

    Advanced Member

  • Members
  • PipPipPip
  • 484 posts
  • LocationSan Francisco, CA

Posted 13 May 2015 - 03:20 PM

I think the better way to do it is to ensure that those users have the appropriate permission levels to access the files in Perforce.  What you're doing right now is essentially just circumventing your own permissions policies; why not update the policies to correctly reflect who needs to see what?  :)

#6 raysid

raysid

    Member

  • Members
  • PipPip
  • 12 posts

Posted 14 May 2015 - 06:03 PM

Thanks P4Sam for your suggestion.
Ok. I will try to make this as per policies though i have some doubt regarding it. May be i will raise those when I am stuck.





Also tagged with one or more of these keywords: Revision, new location, copy, branching

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users