1

so far I have used Tortoise SVN to commit and update folders under version control. When I commit I check "all" in the GUI dialog so that deletions as well as additions are committed.

Now I have more and more folders under version control and I would like to have a batch file for committing and updating all of them.

So far I have experimented with the command line and found this:

svn add . --force
svn commit -m"Adding missing files"

This adds new files but does not reflect any deletions.

Could you please help me with the batch files? It would make my work a lot easier but I am really too unexperienced with SVN/batch files to do this on my own...

I use Win7x64 and Tortoise SVN 1.7.12 with the command line extension.

Thank you!

2 Answers 2

7

I think I figured something out using gammay's and this input:

cd "C:\Users\User\Desktop"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\?"`) do svn add "%%i %%j"
for /f "usebackq tokens=2*" %%i in (`svn status ^| findstr /r "^\!"`) do svn delete "%%i %%j"
svn commit -m "Commit via Batch"

And

cd "C:\Users\User\Desktop"
svn update

and repeatedly for different paths!

Thank you :)

0

Firstly, which svn command line tools do you use? You can use CollabNet for 'svn' commands.

Secondly, to delete files, you need to checkout existing files from svn, then use svn delete and then svn commit.

Your question is not clear - if this doesn't answer your question, please provide a few more details.


Edited to answer asker's requirement (in comments below): OK. What you want is a script which will find the new files in the folder and add them to SVN automatically and find deleted files in folder and delete them from SVN too. I can tell you this is a dangerous as undesired files can get added/deleted.

Still, if you want to go ahead with this script this is what the script can do:

  • Run svn status which displays missing (deleted) files and unknown (to be added) files
!    FileA [Missing - deleted]
?    FileD [Unknown - to be added]
  • Parse the output to find the ! files and run svn delete on these files
svn delete FileA
  • Parse the output to find the ? files and run svn add on these files
svn add FileD
  • svn commit
    • This commits the above deleted & added files and also any modifications.
    • If you do not want to commit modifications, commit individual added/deleted files
6
  • 1
    Tortoise (which the user refers to in his question) has command line tools if you check that option during installation.
    – djangofan
    Commented May 22, 2013 at 16:51
  • Hi, thank you for your replies! I use SVN.exe which comes with Tortoise just as djangofan said. I will try to describe my use case some further: I have a folder with subfolders and files. All files in this folder are under version control so when I commit, changes will go to the server. But when I add (or delete) a whole new file it is not added (or removed) to (or from) the server. What I need is a batch file that I can double click and without asking will commit the latest version of existing files, add new files or delete deleted files. Does this make it clearer?
    – Cerd
    Commented May 28, 2013 at 13:06
  • When you say "when I add (or delete) a whole new file it is not added (or removed) to (or from) the server", what happens? What is the error you get? What are the steps followed?
    – gammay
    Commented Jun 7, 2013 at 11:57
  • I don't think this is an error. I just need to know the command to commit a deletion to the repository. And how to run the code from a batch file. Example: PC1 contains a folder with: FileA, FileB, FileC -> I delete FileA and add FileD -> I run the batch I would like to have repository contains FileB, FileC, FileD -> I update on PC2 the folder on PC2 now contains FileB, FileC, FileD
    – Cerd
    Commented Jun 7, 2013 at 22:13
  • Thank you very much! But what's the code to run all the steps you mentioned automatically in the batch file? I mean without manually selecting files A, D?
    – Cerd
    Commented Jul 1, 2013 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.