Jump to content


Re-connect existing folder with changes


  • Please log in to reply
4 replies to this topic

#1 RavenAB

RavenAB

    Member

  • Members
  • PipPip
  • 10 posts

Posted 16 August 2019 - 03:11 PM

Against best practice advice I've been doing updates to a project while it was not currently "connected" to Perforce, i.e. I had no workspace pointing to the folder.

To get back in sync with the Perforce project, I created a new workspace and used the existing folder with all it's files. When trying to sync the project, P4V refuses (as by design) to overwrite the local files that has been changed while the folder/workspace was disconnected. So far so good. However, I would have expected P4V to let me resolve all the files that had been changed during the "offline" period. Instead, it just produces a can't overwrite existing file warning for each of the files when fetching the latest revision, and when checking the file in the Workspace tree it has no icon and says not synced in your workspace. If I reconcile, P4V sees the existing files with changes as new and only allows adding. When trying to submit the add, however, P4V now knows that the file must be resolved, as it spits out the error out of date files must be resolved or reverted. Trying to manually force a resolve or re-resolve does not work.

How do I get out of this annoying situation? Thanks in advance for any help.

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 928 posts

Posted 16 August 2019 - 04:14 PM

View PostRavenAB, on 16 August 2019 - 03:11 PM, said:

To get back in sync with the Perforce project, I created a new workspace

You made this too complicated.  :)  Switch back to your original workspace and "reconcile".  Done.

Reconcile uses the information of what you had synced to your workspace before you went offline in order to figure out what changes you've made since then (i.e. it's diffing what you have now vs what you synced).  It's designed to handle this exact situation in a one-shot command.  If you create a new workspace, that information is lost, and everything gets harder.  All your files showed up as "new" because you never synced anything to this new workspace, so relative to that empty state everything is new (and will conflict with the existing files).

As long as you haven't done something really destructive like delete your original workspace, you can just switch back to it, do the reconcile (which will now work correctly), and pick up from there as if you were connected all along.  If any resolves are needed they'll use your last-synced files as the common base so merging will be as easy as possible.

#3 RavenAB

RavenAB

    Member

  • Members
  • PipPip
  • 10 posts

Posted 16 August 2019 - 05:04 PM

View PostSambwise, on 16 August 2019 - 04:14 PM, said:

Switch back to your original workspace and "reconcile".  Done.

I should obviously have mentioned that the original workspace was indeed deleted. Sorry for the confusion. Any ways around when this situation occurs? Except for the brute force one involving syncing to a different folder and then overwrite that folder with the latest, local one.

#4 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 928 posts

Posted 16 August 2019 - 05:24 PM

Oh dear.  Command line time!

To start, revert the files that you opened with that reconcile, because they'll gum everything up.  Use the "-k" flag to make sure you don't delete any of your local changes:

p4 revert -k //...

Come up with a best guess of when you synced the workspace from the depot.  It's better to err on the side of too early.  Then run:

p4 flush @DATE

e.g. "p4 flush @2019/08/03".  This will tell the server "pretend I synced to the head revision as of this date".

Now go ahead and run:

p4 reconcile

It will use the "flushed" revisions as the base.  If you guessed too late of a date, the files in your workspace will be implicitly backing out the changes that you didn't really sync from the depot, so be careful!  Run:

p4 diff

to inspect your changes and make sure it looks like the work you did (or the work you did plus changes from the depot that you did actually sync).  Keep a particular eye out for deletions that don't look like yours, because that probably means you flushed to too late of a date and now you're backing out someone else's work.

Everything you've done up to this point can be trivially undone by going back to the start (i.e. you can revert -k and flush to a different date at this point).  Be fairly confident that you got the right date (or an earlier one) before proceeding to the "resolve" step, since that will modify your workspace files and after that it might be difficult to rewind.  Note that if you went TOO early you'll have more changes to resolve and therefore a higher chance of conflicts, but at least nothing will get silently dropped.

If everything looks good you can now run:

p4 sync
p4 resolve
p4 submit


#5 RavenAB

RavenAB

    Member

  • Members
  • PipPip
  • 10 posts

Posted 19 August 2019 - 08:04 AM

View PostSambwise, on 16 August 2019 - 05:24 PM, said:

Oh dear.  Command line time!

Thank you very much, worked like a charm! As I'm so much more used to using P4V than the command line, I switched over to P4V after the reconcile command to investigate the changes visually and submit them in a, for me, more familiar manner.

Appreciate the excellent guide!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users