5

I am using svn and on occasion I need to revert some changes that are not going well. I would like to make a zip of the changed files first. I would like the zip to have full paths. I am using TortoiseSVN for the most part, but I am not afraid to use a command line if need be.

Kara
  • 6,115
  • 16
  • 50
  • 57
Matthew Nichols
  • 4,866
  • 4
  • 41
  • 48

10 Answers10

6

You can just use a simple bash one-liner (provided that you are a Linux happy user):

zip ~/modified.zip $(svn status | grep ^M | awk '{ print $2;}')

This extracts all files with the status of M so Modified.

rantoniuk
  • 1,083
  • 12
  • 18
4

In the TourtoiseSVN Check for Modifications dialog

  • select the files you want
  • right click
  • then shell context menu to send them to 7zip
Kara
  • 6,115
  • 16
  • 50
  • 57
3

You can buy a copy of WinZip, or use the open-source 7-Zip. Both have command-line versions included that will do what you want. They both also support use as Windows shell extensions, meaning you can select one or more files from Windows Explorer, right-click, and perform compression options from the context menu. (Either would be better than using the drag-drop solution you posted, BTW.)

Both products contain pretty good documentation on using them from the command line, if that's the option you choose.

With 7-Zip's shell support, you Shift+Click or Ctrl+Click to select the files, then right-click any of them and choose 7-Zip->Add to archive... from the context menu. You can then check the option to include path information.

WinZip contains similar functionality from the Windows shell, although I haven't used it for years and can't give specific directions.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Thanks for pointing out some good stuff about 7-Zip; it is clearly more capable than I thought +1. However none of what you say here addresses the SVN question I asked. I am missing how this gets me a backup of the added/modified (and only those) files in my Working Copy. Maybe I missed something in your answer. – Matthew Nichols May 11 '12 at 23:39
  • You create the archive the first time (which includes all files). After that, choose the archive, right-click, choose `Add to archive...`, and then change the update mode to either `Update` or `Freshen`. Again, see the 7-Zip documentation (you can open the dialog described and click the `Help` button to get there). – Ken White May 11 '12 at 23:48
3

This is rough, but works.

@echo ================================================
@echo ZIPS all modified or added svn controlled files
@echo to the specified  zip file
@echo "svnzipmodified <filename>"
@echo ================================================
@if "%1"=="" goto end
@echo Getting list of modified or added files
@echo ================================================
svn status -q > list.txt
@echo Strip status text to leave path and filename
@echo ================================================
find "M    " list.txt > list2.txt
find "A    " list.txt >> list2.txt
(for /F "tokens=1,2*" %%i in (list2.txt) do @echo %%j) > list3.txt
@echo Zip up files
@echo ================================================
del %1 /Q
"C:\Program Files\MATLAB\R2010a\bin\win64\zip.exe" %1 -@ < list3.txt

pause
del list3.txt /Q
del list2.txt /Q
del list.txt /Q
@echo Done
@echo ================================================

:end
John
  • 31
  • 2
1

You could save your local changes to a file with:

svn diff > my_changes.patch

These changes can later be restored with:

patch -p0 < my_changes.patch
HAL
  • 2,011
  • 17
  • 10
  • I had seen that...I certainly get the utility of that. However what I want to do is be able to have a zip of all of the files that have been changed or added. – Matthew Nichols May 11 '12 at 22:06
  • Ok, I might have misunderstood what you are looking for. – HAL May 11 '12 at 22:08
1

I like this solution since it works on Windows and Mac with small modifications.

Download a command line subversion client. On Windows, check out SlikSVN at http://sliksvn.com/en/download/ since TortoiseSVN doesn't provide one.

Download Python 3.x if you don't have it.

Download 7zip and add it to your path.

Execute:

import os
import re
import subprocess
import time

re_svn = re.compile(r'(.)\s+(.+)$')
files = []

for line in os.popen('svn status -q').readlines():
    match = re_svn.match(line)
    if match:
        files.append(match.group(2))

if len(files) > 0:
    subprocess.call(['7z','a',time.strftime('%Y%m%d-%H%M%S') + '.zip'] + files)

Note: learning Python, but this appears to work.

Josh Unger
  • 6,717
  • 6
  • 33
  • 55
1

In linux this is how you would do it.

svn diff -r REV:HEAD --summarize | sed 's/[A-Za-z][ ]+//' | xargs zip myfiles.zip

Where REV is the revision number were you want to start from. Usually when you checked out.

SOURCE: http://www.semicolon.co.za/linux/get-list-of-changed-tiles-via-svn-diff-and-zip-them.html

Tali Luvhengo
  • 349
  • 1
  • 15
0

OK I found one way of doing it, but am not altogether happy about it. I am answering my own question but I am hoping that someone can improve upon it.

  1. Use WinZip to create an empty zip file with Include Full Path Information selected. Leave the zip open in WinZip. I was unable to figure out how do this with the native Windows zip utility.
  2. In working copy use the TourtoiseSVN context menu to open the Check for Modifications dialog.
  3. Select all of the files in the dialog and drag them and drop in WinZip.
Matthew Nichols
  • 4,866
  • 4
  • 41
  • 48
0

If you can agree to commit (into some different place) these changes before undo (which becomes just svn up PREV-REV), you can use any of "Files changed in revision" tricks

For TortoiseSVN latest, GUI-way, ("Exporting only changed files in TortoiseSVN between versions") may be preferable method for you

Community
  • 1
  • 1
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
0

Although Boscabouter's answer worked pretty well for me on one machine, I noticed on another machine that TortoiseSVN didn't have the Shell entry in its context menu. Therefore I couldn't easily send the files from the Check for modifications dialog to 7zip.

Based on Ken White's input, I used the command line to move the files to an archive:

  1. Open the TortoiseSVN Check for modifications dialog, for example from the base directory of your repository
  2. Mark all the files you are interested in, right-click on any file and choose Copy paths to clipboard
  3. Paste the paths into a temporary text file, say filelist.txt, within the same directory
  4. Open terminal in that directory (for example Shift + right-click on that folder in Windows Explorer, then choose Open command prompt)
  5. Run "%ProgramFiles%"\7-Zip\7z a -tzip modified.zip @filelist.txt

Alternatively to steps 1 - 3 you may run svn status | find "M " > filelist.txt and remove unwanted lines/characters with a text editor.

bgerth
  • 1,256
  • 1
  • 12
  • 19