Jump to content


Reverting all files in a shelf if they are identical to head

revert shelf

  • Please log in to reply
5 replies to this topic

#1 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 02 September 2020 - 02:12 PM

Hi,

I am looking for a command line method to prune ALL files in a shelf that matches head. (which means that these files have already been checked in and can be pruned)

Currently I am selecting each in a shelf individually in P4V and diffing w.r.t to head and "IF" identical reverting it..

What would be the method to do this across all files in a shelf on the command line?

- Thanks in advance

#2 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 02 September 2020 - 02:14 PM

Correction - The Topic title should have been "Deleting all files in a shelf if they are identical to head"

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 02 September 2020 - 02:44 PM

I'd probably do this by a sequence like this:

p4 unshelve -s SHELF
p4 sync ...
p4 resolve -as
p4 revert -a (or p4 diff -sr | p4 -x- revert)
p4 shelve -r -s SHELF

You could also do this by some scripting to directly remove the identical files in the shelf, but it feels more straightforward to me to just use your workspace to do the work of "rebasing" the shelf to the head revision and then using "p4 shelve -r" to replace the shelf with the result.

#4 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 02 September 2020 - 02:54 PM

Thanks Sambwise..

#5 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 02 September 2020 - 06:05 PM

Thinking about the proposed solution...
I do not want to touch the files in my WA. p4 sync does that...
Is there a way I can pull this off without modifying unrelated files

#6 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 02 September 2020 - 08:41 PM

Hmm...

p4 -F %depotFile% files @=CHANGE | p4 -x - tag -a -l to-revert
p4 -F "diff2 -q %depotFile%@=CHANGE %depotFile%#head" files @=CHANGE | p4 -F %depotFile% -x - run | p4 -x - labelsync -l to-revert -d
p4 -F %depotFile% files @to-revert | p4 -x - shelve -d -c CHANGE
p4 label -d to-revert
?

Be nice if "p4 diff2" had an -Oi flag that made it only output identical files; then this'd be a one-liner!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users