49

I created a changelist by doing...

$ svn changelist my_changes

... added files to it, and then committed the changelist...

$ svn ci --changelist my_changes --keep-changelists

... so now, I have "kept" my changelist and it shows up every time I view status.

$ svn status
... modified/added/deleted files listed here...

--- Changelist 'my_changes':
... files that are a part of this changelist listed here...

I "kept" the changelist for a reason, but I don't need it anymore so I'm ready to remove it. How do I remove this changelist from SVN? I know how to remove files from the changelist, but not the changelist itself.

Hristo
  • 45,559
  • 65
  • 163
  • 230

3 Answers3

64

Remove all the associated files from a changelist and it'll disappear.

Official way

See https://stackoverflow.com/a/15992735/253468

svn changelist --remove --recursive --cl my_changes .

Manual way

i.e. svn changelist --remove file.name

D:\Programming>mkdir test
D:\Programming>cd test
D:\Programming\test>svnadmin create .
D:\Programming\test>svn co file:///D:\Programming\test co
Checked out revision 0.
D:\Programming\test>cd co
D:\Programming\test\co>echo "hello" > test.file
D:\Programming\test\co>svn add test.file
A       test.file

D:\Programming\test\co>svn status
A       test.file

D:\Programming\test\co>svn changelist mycl test.file
A [mycl] test.file

D:\Programming\test\co>svn status
--- Changelist 'mycl':
A       test.file

D:\Programming\test\co>svn changelist --remove test.file
D [mycl] test.file

D:\Programming\test\co>svn status
A       test.file

Automation in Bash

# Remove all files from a specific CL
# Usage: svn_remove_cl my_changes
function svn_remove_cl() {
    svn status |\
    sed -n "/--- Changelist '$1':/,/--- Changelist.*/p" |\
    grep -v '^--- Changelist' |\
    awk '{print $2}' |\
    xargs svn changelist --remove
}

Explanation:

  • svn status: output all the modified files
  • sed: find the changelist and take the output after the CL title until the next CL or the end of svn status's output
  • grep: remove the CL titles from the buffer
  • awk: remove the file statuses, keep only the filenames (i.e. the second column)
  • xargs: put each line as an argument to svn changelist
    (may need tweaks if you have spaces or special characters in the filenames)

Example run

~/tmp/wc$ svn status
A       d

--- Changelist 'cl_a':
A       a
A       e
A       f

--- Changelist 'cl_x':
A       b
A       c
~/tmp/wc$ svn_remove_cl cl_x
Path 'b' is no longer a member of a changelist.
Path 'c' is no longer a member of a changelist.
~/tmp/wc$ svn status
A       b
A       c
A       d

--- Changelist 'cl_a':
A       a
A       e
A       f
Community
  • 1
  • 1
TWiStErRob
  • 44,762
  • 26
  • 170
  • 254
  • yea... I know about this approach, but its so manual. there has to be an automatic changelist removeal command... – Hristo Oct 15 '12 at 23:32
  • If there is, `svn help changelist` doesn't list it... or maybe `using --recursive` switch. Also what about copying the CL description to a file from `svn status` and then: `cat file | sed 's/[A-Z][:blank:]+\(.*\)/\1/g' | xargs svn changelist --remove`, sorry, couldn't test, I don't have a unix command line at hand. – TWiStErRob Oct 15 '12 at 23:48
  • 1
    Hey, added a script to help removal based on the idea in my prev comment. I didn't use it in actual dev, but on a sample repo it worked (see example). – TWiStErRob Dec 07 '12 at 13:11
43

For those that are wondering, you can do this with a single command with svn. Simply navigate to the to level directory of files under your change list exist and run:

svn changelist --remove --recursive .

This will loop over all files under the current directory and attempt to disassociate them from the change list.

lillicoder
  • 552
  • 5
  • 9
43

If you want to delete just one changelist (e.g. my_changes) move to the top level folder of your working copy and run:

svn changelist --remove --recursive --cl my_changes .
user2255549
  • 431
  • 1
  • 4
  • 2