Jump to content


p4 sync for recreated client


  • Please log in to reply
2 replies to this topic

#1 Mailman Sync

Mailman Sync

    Advanced Member

  • Maillist Aggregator
  • 2495 posts

Posted 09 February 2018 - 05:30 AM

Originally posted to the perforce-user mailing list by: Hamza Sheikh


Does p4 download all data again during `p4 sync` if:

- the client is deleted `p4 client -d clientfoo`
- but data in workspace is not deleted
- then the client is created again with the same config values `p4 client`
- run `p4 sync`

I would expect the data to not be downloaded again in this case since
it already exists.

- Is my expectation wrong?
- Am I misunderstanding and data is not downloaded again?


Here's my scenario:

Create a Docker container. Mount a volume in the container that will
contain synced with p4, say at /ws. Create a workspace like below and
run `p4 sync`.

Client: foostr
Update: blahdate
Access: blahdate
Owner:  foouser
Host:   build-container
Description:
        Created by foouser.
Root:   /ws
Options:        noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions:  submitunchanged
LineEnd:        local
View:
        //depot/bar/... //foostr/bar/...


I can recreate the container many times and run `p4 sync`. If there
have been no changes, then the workspace is in sync and there's
nothing to do every time.

However, if I delete the client with `p4 client -d foostr`, create it
again with the same config, and run `p4 sync`, *all* files are
downloaded again.
_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user


#2 P4Sven

P4Sven

    Advanced Member

  • Staff
  • 32 posts
  • LocationWokingham, UK

Posted 09 February 2018 - 07:15 AM

HI Hamza,

The Perforce Helix server keeps track of the state of the workspace in its database (in the db.have table). When you delete the workspace you also wipe the db.have table for that workspace, therefore a 'p4 sync' will have to download all the files again.

Instead of deleting the client you could unload it instead (after creating an unload depot). This would preserve the client's state.

If you can guarantee that the state of the workspace has not changed between deleting the client workspace and recreation of the client workspace, you can use 'p4 sync -k', which will not download the files but update the metadata. Be careful with that though: If someone sneaked in a change to your files in between deletion and recreation of your client workspace, you now have synced in the incorrect state.

Cheers,

Sven Erik

--

Sven Erik Knop | Principal Solutions Engineer
Perforce Software<http://www.perforce.com>
T: +44 1189 771020<tel:+441189771020> | M: +44 7974 351514<tel:+447974351514>
Visit us on: Twitter<https://twitter.com/perforce> | LinkedIn<https://www.linkedin...force-software> | Facebook<https://www.facebook.com/Perforce>

New code hosting for Git, SVN, and more.
Try Helix TeamHub free today!<http://info.perforce...signature-link>



On 9 Feb 2018, at 07:29, Hamza Sheikh <fehrist@codeghar.com<mailto:fehrist@codeghar.com>> wrote:

Does p4 download all data again during `p4 sync` if:

- the client is deleted `p4 client -d clientfoo`
- but data in workspace is not deleted
- then the client is created again with the same config values `p4 client`
- run `p4 sync`

I would expect the data to not be downloaded again in this case since
it already exists.

- Is my expectation wrong?
- Am I misunderstanding and data is not downloaded again?


Here's my scenario:

Create a Docker container. Mount a volume in the container that will
contain synced with p4, say at /ws. Create a workspace like below and
run `p4 sync`.

Client: foostr
Update: blahdate
Access: blahdate
Owner:  foouser
Host:   build-container
Description:
       Created by foouser.
Root:   /ws
Options:        noallwrite noclobber nocompress unlocked nomodtime normdir
SubmitOptions:  submitunchanged
LineEnd:        local
View:
       //depot/bar/... //foostr/bar/...


I can recreate the container many times and run `p4 sync`. If there
have been no changes, then the workspace is in sync and there's
nothing to do every time.

However, if I delete the client with `p4 client -d foostr`, create it
again with the same config, and run `p4 sync`, *all* files are
downloaded again.
_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com<mailto:perforce-user@perforce.com>
http://maillist.perf...o/perforce-user

_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user


#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 548 posts

Posted 09 February 2018 - 03:40 PM

Adding on to what Sven said about "sync -k", this is the sequence I think you want to do:

p4 sync -k
p4 clean

The "clean" command will re-sync any files that don't match the expected state.  Note that if you made any changes in your workspace, these are now gone!

A good refinement to this is to add a date to the "sync -k" command to match the time when the client was last synced (if you know it).  That will minimize any difference between what you're telling the server you have and what you actually have.  In addition, if you know that timestamp, you can use "reconcile" instead of "clean" to catch modified files -- just don't do this if you did the "sync -k" to head, since then any out-of-date files will look "different" and you'll end up rolling back other people's changes.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users