Python script to automate commit

311 views
Skip to first unread message

Aman Qureshi

unread,
Dec 6, 2022, 7:25:49 AM12/6/22
to TortoiseSVN
Hi,
I  wanted to know how can we automate commit and update the files with python script for svn.
currently,
subprocess.call(["svn","checkout", url, local dir]) ---> this is working by fetching the repo and creatinfg a local copy 
subprocess.call(["svn", "commit", "-m", "Updating the files", "local dir"]) ---> this is not working

is there separate comand to add files then commit or I bascially want to commit all the files in the directory that are not in subversion.

Tried using pysvn and svn 1.0.1 noone of them are working  for me

Thanks in Advance.

Pavel Lyalyakin

unread,
Dec 6, 2022, 8:32:46 AM12/6/22
to TortoiseSVN
On Tue, Dec 6, 2022 at 4:25 PM Aman Qureshi via TortoiseSVN <torto...@googlegroups.com> wrote:
Hi,
I  wanted to know how can we automate commit and update the files with python script for svn.

Wrong mailing list. This mailing list is intended for topics related to the TortoiseSVN client. However, your question is about automating the `svn` command-line client. The users@ Apache Subversion is an appropriate place for your request.
 
currently,
subprocess.call(["svn","checkout", url, local dir]) ---> this is working by fetching the repo and creatinfg a local copy 
subprocess.call(["svn", "commit", "-m", "Updating the files", "local dir"]) ---> this is not working

Do you receive any errors when you call `svn commit` from this Python script? I'm afraid that right now it's unclear what exactly is not working.

Note that the commit will only happen if the working copy has local modifications. The commit won't happen if there is nothing to commit (no local modifications in the working copy, so there is nothing to commit into the repository). Note that if you create new files in the working copy, you need to run `svn add` to make Subversion track them.
 
is there separate comand to add files then commit or I bascially want to commit all the files in the directory that are not in subversion.

Tried using pysvn and svn 1.0.1 noone of them are working  for me

Thanks in Advance.

--
You received this message because you are subscribed to the Google Groups "TortoiseSVN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tortoisesvn...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tortoisesvn/2223010f-1038-4485-91b9-64c93ebf21a3n%40googlegroups.com.


--
With best regards,
Pavel Lyalyakin
VisualSVN Team

Aman Qureshi

unread,
Dec 7, 2022, 8:10:16 AM12/7/22
to TortoiseSVN
Hi, I tried both adding new files and making changes in the same already committed file (working copy local modification). The commit command with subprocess isn't showing any error, it just does not execute anything, call you to guide me through the command to add files with the same subprocess call.
So, I'll then just try to add all uncommitted files with the add command and the commit command

Kind Regards,
Aman Qureshi

Pavel Lyalyakin

unread,
Dec 7, 2022, 9:37:28 AM12/7/22
to TortoiseSVN
You should see some output when running the commands. Sample code:
[[[
import subprocess

subprocess.call(["svnadmin", "create", "mytestrepo"])
subprocess.call(["svn", "checkout", "file:///users/bahrep/mytestrepo", "myworkingcopy"])

with open("/users/bahrep/myworkingcopy/mytextfile.txt", "w") as myfile:
    myfile.write('File content')

subprocess.call(["svn", "add", "/users/bahrep/myworkingcopy/mytextfile.txt"])
subprocess.call(["svn", "commit", "-m", "My test log message", "/users/bahrep/myworkingcopy/"])
]]]

Creates a new local repository,
Checks out a working copy,
Creates a new file into the working copy and adds it to Subversion,
Commits this change.

Output:
[[[
Checked out revision 0.
A         /users/bahrep/myworkingcopy/mytextfile.txt
Adding         users/bahrep/myworkingcopy/mytextfile.txt
Transmitting file data .done
Committing transaction...
Committed revision 1.
]]]

PS I'm not a Python expert.

Aman Qureshi

unread,
Dec 7, 2022, 10:31:17 AM12/7/22
to TortoiseSVN
Thank you so much I was just missing the add command, other than that it's working for me. 
Thanks once again for your help, really appreciate it!

Pavel Lyalyakin

unread,
Dec 7, 2022, 10:56:37 AM12/7/22
to TortoiseSVN
Great! I'm glad that the suggestion helped.

Reply all
Reply to author
Forward
0 new messages