-1

I am new to Perforce and want to create a automated tool to get the latest revision by itself. I have a mapping like this:

P4CLIENT: Proj_name 
Worspace root direcctory: C:\...\Proj_name  
Stream: Build

Now what i desire is it should get latest revision of all files from:

Build\fold1\fold2   to    C:\...\Proj_name\fold1\fold2

When I just ran p4 sync command, it copied all files from Build to C:\...\Proj_name.

So please tell how to specify the folder path from where to get the latest revision. Will the command p4 sync //depot/proj1/... work for me and how does it change in my condition ?

Aman
  • 979
  • 3
  • 10
  • 23
  • Assuming that `//depot/proj1/...` maps to a location in your client, then `p4 sync //depot/proj1/...` will sync those files. It's not quite clear what you're asking. If you want to change where those files are synced to, run `p4 client` to change the depot-to-client mappings. – jamesdlin Jun 19 '16 at 07:46
  • @jamesdlin It is simple: Suppose I have mapped a/b to c/d but now I want to get latest revision from a/b/e/f to c/d/e/f/. How to achieve this from command line. – Aman Jun 21 '16 at 09:53
  • If your current directory is at the root of your Perforce client, `p4 sync c/d/...` will sync everything under `c/d`and give you `c/d/e/f`. Or you can do `p4 sync //depot/a/b/...`. – jamesdlin Jun 21 '16 at 18:05
  • @jamesdlin is there any command for getting Client name and Client root. – Aman Jun 22 '16 at 08:31
  • As I already mentioned, run `p4 client`. – jamesdlin Jun 22 '16 at 19:16

1 Answers1

2

You use the View: section of your client spec to describe which parts of the overall repository you wish to work with, and where those files should be placed on your workstation's filesystem.

In your particular case, to specify the folder path, as well as where those files should be placed, you might specify your View: as something like:

View:
    //depot/Build/fold1/fold2/...  //Proj_name/fold1/fold2/...

You may have considerably more complex view mappings; the view syntax is quite powerful. To learn more about view mappings, type p4 help views.

After you change your View: specification for your client, run:

p4 sync

The sync command will notice that you have changed your view mapping, and it will re-arrange the files in the root of your client on your workstation, so that they are arranged as described by your new view mapping.

If you don't wish to sync your entire client, you can specify a subset of the files which should be sync'd, by naming that subset of files using a file pattern as an argument to the sync command:

p4 sync //depot/Build/fold1/fold2/*.cpp

However, that can be quite confusing, and I recommend that, to start, you avoid using that advanced usage, and stick to performing a p4 sync with no file arguments, at least until you get more comfortable with how p4 sync is used. For one thing, when you are sync'ing different subsets of files with different file arguments, it is quite easy to get your workstation's filesystem into an un-buildable state, by getting half of the files from one changelist and half from another, which will cause you to have code that doesn't compile, etc.

So, for now:

  1. Consider which parts of the repository you wish to work with, and where you want them to go on your workstation's filesystem
  2. Run p4 client and describe the appropriate View: line(s) to specify those files, using the pattern-matching syntax of the View: field
  3. Run p4 sync and Perforce will put those files on your computer as specified.
Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • In the 2nd step, "Run p4 client and describe the appropriate View" do I need to manually change the view. Isn't there any command for this? – Aman Jun 21 '16 at 09:21
  • Can you please also tell commands to get the Client root and Client name and Client Stream. I couldn't find them in command reference. – Aman Jun 21 '16 at 09:22