2015-06-04 21:09:46 +00:00
|
|
|
|
2015-07-28 20:26:00 +00:00
|
|
|
import subprocess, os, sgprops
|
2015-06-04 21:09:46 +00:00
|
|
|
import xml.etree.cElementTree as ET
|
|
|
|
|
|
|
|
class SVNCatalogRepository:
|
2015-07-28 20:26:00 +00:00
|
|
|
def __init__(self, node):
|
|
|
|
path = node.getValue("path")
|
2015-07-26 03:45:01 +00:00
|
|
|
if not os.path.exists(path):
|
|
|
|
raise RuntimeError("No directory at:" + path)
|
|
|
|
|
2015-06-04 21:09:46 +00:00
|
|
|
self._path = path
|
|
|
|
xml = subprocess.check_output(["svn", "info", "--xml", path])
|
|
|
|
root = ET.fromstring(xml)
|
2015-07-26 03:45:01 +00:00
|
|
|
|
2015-07-11 20:47:13 +00:00
|
|
|
if (root.find(".//repository/root") == None):
|
2015-06-04 21:09:46 +00:00
|
|
|
raise RuntimeError("Not an SVN repository:" + path)
|
2015-07-26 03:45:01 +00:00
|
|
|
|
2015-07-28 20:26:00 +00:00
|
|
|
self._aircraftPath = None
|
|
|
|
if node.hasChild("scan-suffix"):
|
|
|
|
self._aircraftPath = os.path.join(path, node.getValue("scan-suffix"))
|
|
|
|
|
|
|
|
@property
|
|
|
|
def path(self):
|
|
|
|
return self._path
|
|
|
|
|
|
|
|
@property
|
|
|
|
def aircraftPath(self):
|
|
|
|
return self._aircraftPath
|
|
|
|
|
2015-06-04 21:09:46 +00:00
|
|
|
def hasPathChanged(self, path, oldRevision):
|
|
|
|
return self.scmRevisionForPath(path) != oldRevision
|
2015-07-26 03:45:01 +00:00
|
|
|
|
2015-06-04 21:09:46 +00:00
|
|
|
def scmRevisionForPath(self, path):
|
|
|
|
xml = subprocess.check_output(["svn", "info", "--xml", path])
|
|
|
|
root = ET.fromstring(xml)
|
2015-07-11 20:47:13 +00:00
|
|
|
commit = root.find(".//entry/commit")
|
2015-06-04 21:09:46 +00:00
|
|
|
return commit.get('revision', 0)
|
2015-07-26 03:45:01 +00:00
|
|
|
|
2015-06-04 21:09:46 +00:00
|
|
|
def update(self):
|
2015-07-28 02:40:00 +00:00
|
|
|
print "SVN update of", self._path
|
|
|
|
subprocess.call(["svn", "update", self._path])
|