2015-06-05 05:09:46 +08:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import xml.etree.cElementTree as ET
|
|
|
|
|
|
|
|
class SVNCatalogRepository:
|
|
|
|
def __init__(self, path):
|
|
|
|
self._path = path
|
|
|
|
xml = subprocess.check_output(["svn", "info", "--xml", path])
|
|
|
|
root = ET.fromstring(xml)
|
2015-07-12 04:47:13 +08:00
|
|
|
|
|
|
|
if (root.find(".//repository/root") == None):
|
2015-06-05 05:09:46 +08:00
|
|
|
raise RuntimeError("Not an SVN repository:" + path)
|
|
|
|
|
|
|
|
def hasPathChanged(self, path, oldRevision):
|
|
|
|
return self.scmRevisionForPath(path) != oldRevision
|
|
|
|
|
|
|
|
def scmRevisionForPath(self, path):
|
|
|
|
xml = subprocess.check_output(["svn", "info", "--xml", path])
|
|
|
|
root = ET.fromstring(xml)
|
2015-07-12 04:47:13 +08:00
|
|
|
commit = root.find(".//entry/commit")
|
2015-06-05 05:09:46 +08:00
|
|
|
return commit.get('revision', 0)
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
subprocess.call(["svn", "update"])
|
|
|
|
|