diff treepkg/subversion.py @ 282:f58f9adb7dc3

Add functions to get SVN logs and extract tag revisions from it. Add some tests for the log parsing.
author Bernhard Herzog <bh@intevation.de>
date Tue, 04 Aug 2009 10:09:12 +0000
parents 4b700b39c32f
children 020421cd3ee2
line wrap: on
line diff
--- a/treepkg/subversion.py	Tue Aug 04 10:01:56 2009 +0000
+++ b/treepkg/subversion.py	Tue Aug 04 10:09:12 2009 +0000
@@ -10,6 +10,9 @@
 import os
 import shutil
 import re
+import StringIO
+
+from lxml import etree
 
 import run
 from cmdexpand import cmdexpand
@@ -70,6 +73,29 @@
                               % svn_working_copy)
     return int(str_rev)
 
+def log_xml(url, base_revision):
+    """Return the log in XML of the repository at url from base_revision to HEAD
+    """
+    args = ["--revision", str(base_revision) + ":HEAD",
+            "--verbose",
+            "--xml"]
+    return run.capture_output(cmdexpand("svn log @args $url", **locals()))
+
+
+def extract_tag_revisions(xml_log):
+    """Extracts the revisions which changed an SVN tag since its creation
+    This includes the revision which created the tag and all subsequent
+    changes.  The xml_log parameter should contain the xml-Version of
+    the SVN log of the tag that includes at least the revision that
+    created the tag and all the newer revisions.
+    """
+    tree = etree.parse(StringIO.StringIO(xml_log))
+    tag_revisions = tree.xpath("logentry/@revision"
+                               "[.>=../../logentry/@revision"
+                               "[../paths/path[@copyfrom-path]]]")
+    return tag_revisions
+
+
 
 class SvnRepository(object):
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)