• Is there a way to grab the local revision from a Subversioned directory without using the actual SVN
    17 replies, posted
  • Avatar of LemONPLaNE
  • I'm automating my Source dedicated server using Python, and I've run into a speed issue. Turns out calling a process through any of the subprocess methods is pretty slow, which messes up my timers. I've made my own version of the export command that uses shutil.copytree(), but I can't work out a way to grab the local revision without using subprocess.call(['svn', 'info', folder]). I know that the subversion data is stored in a SQLite database inside the .svn directory, but 1) Opening it in a database viewer just shows an empty file even though there's tons of info in the file if I open it in a text editor, and 2) I don't know two shits about SQLite. I can't scan through the file with f.readlines() and regex either, since the plain text part of the .db file is completely different depending on the size and contents of the repo. Ideas?
  • Avatar of Donkie
  • In the .svn/entries file there is some information about the revision. Line 4 is the current revision, line 11 is the latest revision where something changed, and some other stuff, this is all plaintext. Atleast TortoiseSVN does this, I don't know if any other SVN softwares does it some other way. (this is how wiremod does it)
  • Avatar of LemONPLaNE
  • [QUOTE=Donkie;34143855]In the .svn/entries file there is some information about the revision. Line 4 is the current revision, line 11 is the latest revision where something changed, and some other stuff, this is all plaintext. Atleast TortoiseSVN does this, I don't know if any other SVN softwares does it some other way. (this is how wiremod does it)[/QUOTE] [img]http://i.imgur.com/ZKkeM.png[/img] Really? By the way, I can still grab the local SVN revision no problem.
  • Avatar of gparent
  • [QUOTE=LemONPLaNE;34145234] Really? By the way, I can still grab the local SVN revision no problem.[/QUOTE] Either way, you shouldn't rely on the file format not changing. It's a terrible hack. Spawning the process probably takes the most time, maybe using a SVN library to check the revision would work.
  • Avatar of LemONPLaNE
  • [QUOTE=gparent;34152399]Either way, you shouldn't rely on the file format not changing. It's a terrible hack. Spawning the process probably takes the most time, maybe using a SVN library to check the revision would work.[/QUOTE] ...File format changes? I'm not changing anything. And yes, there is an SVN library for Python, called pySVN. It's closed source and has no documentation. Does that tell you why I don't use it?
  • Avatar of subenji99
  • do you have access to the post-commit hook serverside? We just have that output the current revision to a file whenever a commit is added. (If you're not using your own, Some svn hosts let you modify svn hooks, some do not.) [url]http://svnbook.red-bean.com/en/1.5/svn.ref.reposhooks.post-commit.html[/url]
  • Avatar of gparent
  • [QUOTE=LemONPLaNE;34152594]...File format changes? I'm not changing anything. And yes, there is an SVN library for Python, called pySVN. It's closed source and has no documentation. Does that tell you why I don't use it?[/QUOTE] File format changes as in subversion could be updated and the file might change and your stuff would break. I found this with a simple google search: [url]http://pysvn.tigris.org/docs/pysvn.html[/url] Open source (must be a different one) and has some documentation, I didn't look at it but figured it might help you. Not sure when was the latest commit.
  • Avatar of LemONPLaNE
  • [QUOTE=subenji99;34155899]do you have access to the post-commit hook serverside? We just have that output the current revision to a file whenever a commit is added. (If you're not using your own, Some svn hosts let you modify svn hooks, some do not.) [url]http://svnbook.red-bean.com/en/1.5/svn.ref.reposhooks.post-commit.html[/url][/QUOTE] I'm running a GMod server, I don't need to commit. I just need to checkout. [QUOTE=gparent;34157801]File format changes as in subversion could be updated and the file might change and your stuff would break. I found this with a simple google search: [url]http://pysvn.tigris.org/docs/pysvn.html[/url] Open source (must be a different one) and has some documentation, I didn't look at it but figured it might help you. Not sure when was the latest commit.[/QUOTE] That's the one I was talking about. It's extremely clunky to use and half the documentation is TBD.
  • Avatar of gparent
  • [QUOTE=LemONPLaNE;34159859]I'm running a GMod server, I don't need to commit. I just need to checkout. That's the one I was talking about. It's extremely clunky to use and half the documentation is TBD.[/QUOTE] I see. I didn't think it was this one since you said it was closed source.
  • Avatar of LemONPLaNE
  • [QUOTE=gparent;34160695]I see. I didn't think it was this one since you said it was closed source.[/QUOTE] I'm not used to tigris. Me and a few mates were staring at the page for half an hour and couldn't find the source.
  • Avatar of danharibo
  • [QUOTE=LemONPLaNE;34161481]I'm not used to tigris. Me and a few mates were staring at the page for half an hour and couldn't find the source.[/QUOTE] [url]http://pysvn.tigris.org/project_source_code.html[/url]
  • Avatar of subenji99
  • In that case, why not have your svn update command redirect output to a file instead of stdout, which you can then regex for "Updated to revision <number>."
  • Avatar of LemONPLaNE
  • [QUOTE=subenji99;34161616]In that case, why not have your svn update command redirect output to a file instead of stdout, which you can then regex for "Updated to revision <number>."[/QUOTE] Because I'd still have to invoke the command. searching for the number afterwards would just add yet another operation, thus lengthening the time it takes to finish instead.
  • Avatar of danharibo
  • [QUOTE=LemONPLaNE;34161669]Because I'd still have to invoke the command. searching for the number afterwards would just add yet another operation, thus lengthening the time it takes to finish instead.[/QUOTE]The overhead for looking into a file for a string is minuscule compared to how long subversion will take.
  • Avatar of LemONPLaNE
  • [QUOTE=danharibo;34162538]The overhead for looking into a file for a string is minuscule compared to how long subversion will take.[/QUOTE] That is true, actually.
  • Avatar of subenji99
  • Yeah, I'm not saying do an update every time you need the revision, just an alteration to your current update task to store the revision for later access.
  • Avatar of LemONPLaNE
  • [QUOTE=subenji99;34167186]Yeah, I'm not saying do an update every time you need the revision, just an alteration to your current update task to store the revision for later access.[/QUOTE] I realized. I'm now writing the revision to the (in SVN 1.7) defunct entries file every time I update.