macdjord
macdjord

Reputation: 555

How can you save and restore a list of checked out files in Perforce?

I have, in perforce, a sort of 'basic working set' of files that I keep checked out (and therefore writable) when working. However, every time I commit my changes, this list gets disrupted - some things committed, others reverted - and then I have to waste time tracking down and checking out all these files again.

So, is there some way to save the list of currently checked out files, and then later check out those same files again?

Upvotes: 1

Views: 781

Answers (3)

jamesdlin
jamesdlin

Reputation: 89965

You can do:

p4 -ztag opened | grep depotFile | cut -d ' ' -f 3 > files.txt

to save a list of files already open in your client. (If you don't have Unix utilities for Windows, you could construct this list by whatever means you want, such as running p4 opened > files.txt and manually editing files.txt in an editor.)

Once you have a list of files, you can open all of them via:

p4 -x files.txt edit

This doesn't meet your preference for a GUI-based solution, but you could create .cmd scripts to perform these actions and then double-click on them (or on shortcuts to them).

Upvotes: 1

Samwise
Samwise

Reputation: 71454

You said that shelving's not the answer, but that's what I would go with as the easiest solution (i.e. the one that involves the least scripting and/or fewest manual steps) for the specific question you're asking:

  1. Shelve your pending change (let's call this change 1000).
  2. Move your open files to a new pending change (let's call this change 1001).
  3. Submit change 1001.
  4. Unshelve change 1000.
  5. Sync and resolve.

Now you have the same exact files open (the unshelve opened them) but at the head revision (the sync and resolve does that).


Now, looking past what you asked for to what might make your life easier: rather than reverting the files you don't want to submit (and having some sort of scheme to get them back later, possibly via shelving as described above), what I'd do is move them to another changelist. So instead of:

  1. Identify "unchanged" files.
  2. Revert unchanged files.
  3. Submit remaining files with "reopen" option.
  4. Reopen previously reverted files (somehow).

I'd do:

  1. Identify "unchanged" files.
  2. Move unchanged files to another changelist N.
  3. Submit remaining files with "reopen" option.
  4. Move all files from changelist N back to the default changelist.

All of those except step 1 are simple one-shot commands that you can do from any client. Personally, I'd automate steps 1+2 with a script (I'm assuming it's programmatically possible to determine whether the only diff in one of these files is the timestamp) and put it into P4Win/P4V as a "custom tool".

Upvotes: 0

tkosinski
tkosinski

Reputation: 1696

The easiest solution would be to exclude those generated files via your workspace specification, e.g., "-//depot/files/ignorablefile.sh"

They can still reside in your local workspace, but the app will not attempt to update them or add them to source control.

Upvotes: 0

Related Questions