8

I had added a bunch of new files into a new changelist using p4 add command. I shelved the changelist for review purpose (swarm server picks the changes from shelved changelist).

During code review, I was told to remove a file from the changelist. I did the following steps to achieve the same

  1. First, unshelve the changelist

    p4 unshelve -c (cl-number)

  2. Reverted the file that I had added previously

    p4 revert (file)

Perforce says "....../file - was add, abandoned"

  1. Again, shelve the files back

    p4 shelve -f -c (cl-number)

Now, if I see p4 change (cl-number), the file that I deleted is not visible in the files mentioned below. However, if I do p4 describe -s -S (cl-number), the removed file is still visible and not being removed from shelve.

What should be done to remove a specific file in a shelved changelist?

LuFFy
  • 8,799
  • 10
  • 41
  • 59
Sathya
  • 81
  • 1
  • 1
  • 2

2 Answers2

11

You need to run p4 shelve -d -c (cl-number) (file).

See also p4 help shelve.

sferencik
  • 3,144
  • 1
  • 24
  • 36
  • 1
    Just want to add on top, in case such shelved changelist is submitted and associated with swarm review. We still have to do `p4 shelve -f -c (cl-number)` in order to update associated swarm review with our shelved changelist as well. Anyway, your solution also works especially whenever we need to remove individual files. Thanks! – haxpor Sep 01 '21 at 12:15
8

This is an option that's pretty close to what you tried:

p4 unshelve -c (cl-number)
p4 revert (file)
p4 shelve -r -c (cl-number)

The "-r" flag causes the entire shelf to be replaced with what's in your workspace, rather than adding what's in your workspace to the shelf (and leaving other shelved files untouched).

Samwise
  • 68,105
  • 3
  • 30
  • 44