aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo/git.py')
-rw-r--r--MgaRepo/git.py74
1 files changed, 67 insertions, 7 deletions
diff --git a/MgaRepo/git.py b/MgaRepo/git.py
index c9018e6..a16a1ea 100644
--- a/MgaRepo/git.py
+++ b/MgaRepo/git.py
@@ -14,10 +14,11 @@ class GITLogEntry(VCSLogEntry):
VCSLogEntry.__init__(self, revision, author, data)
class GIT(VCS):
+ vcs_dirname = ".git"
def __init__(self):
VCS.__init__(self)
self.vcs_name = "git"
- self.vcs_command = config.get("global", "git-command", "git")
+ self.vcs_command = config.get("global", "git-command", ["git", "svn"])
self.vcs_supports['clone'] = True
self.env_defaults = {"GIT_SSH": self.vcs_wrapper}
@@ -28,7 +29,8 @@ class GIT(VCS):
# To speed things up on huge repositories, we'll just grab all the
# revision numbers for this specific directory and grab these only
# in stead of having to go through each and every revision...
- retval, result = execcmd("svn log --stop-on-copy --xml %s" % url)
+ cmd = ["svn", "log", "-g", "--xml", url]
+ retval, result = execcmd(*cmd)
if retval:
return retval
parser = ElementTree.XMLParser()
@@ -40,16 +42,74 @@ class GIT(VCS):
topurl = dirname(url)
trunk = basename(url)
tags = "releases"
- execcmd("git svn init %s --trunk=%s --tags=%s %s" % (topurl, trunk, tags, targetpath), show=True)
+ # cloning svn braches as well should rather be optionalif reenabled..
+ #cmd = ["init", topurl, "--trunk="+trunk, "--tags="+tags, targetpath]
+ cmd = ["init", url, targetpath]
+ self._execVcs(*cmd, **kwargs)
chdir(targetpath)
+ revisions.sort()
for entry in logentries:
- revisions.append(entry.attrib["revision"])
+ revisions.append(int(entry.attrib["revision"]))
+ revisions.sort()
while revisions:
- execcmd("git svn fetch --log-window-size=1000 -r%d" % int(revisions.pop()), show=True)
-
- cmd = ["svn", "rebase"]
+ cmd = ["fetch", "--log-window-size=1000", "-r%d" % revisions.pop(0)]
+ self._execVcs(*cmd, **kwargs)
+ cmd = ["rebase", "--log-window-size=1000", "--local", "--fetch-all", "git-svn"]
return self._execVcs_success(*cmd, **kwargs)
+ def update(self, path, **kwargs):
+ cmd = ["log", "--oneline", "--limit=1"]
+ retval, result = self._execVcs(*cmd)
+ if retval:
+ return retval
+
+ revision = result.split()
+
+ if revision[0][0] == 'r':
+ startrev = "-r"+str(int(revision[0][1:])+1)
+ else:
+ startrev = "BASE"
+
+ cmd = ["propget", "svn:entry:committed-rev"]
+ retval, lastrev = self._execVcs(*cmd)
+ if retval:
+ return retval
+
+ cmd = ["git", "config", "--get-regexp", '^svn-remote.svn.(url|fetch)']
+ retval, result = execcmd(*cmd)
+ if retval:
+ return retval
+ result = result.strip().split()
+ url = result[1] + "/" + result[3].split(":")[0]
+
+ # To speed things up on huge repositories, we'll just grab all the
+ # revision numbers for this specific directory and grab these only
+ # in stead of having to go through each and every revision...
+ cmd = ["svn", "log", "-g", "--xml", "%s:%s" % (startrev,lastrev), url]
+ retval, result = execcmd(*cmd)
+ if retval:
+ return retval
+ parser = ElementTree.XMLParser()
+ result = "".join(result.split("\n"))
+ parser.feed(result)
+ log = parser.close()
+ logentries = log.getiterator("logentry")
+ revisions = []
+ chdir(path)
+ for entry in logentries:
+ revisions.append(int(entry.attrib["revision"]))
+ revisions.sort()
+ while revisions:
+ cmd = ["fetch", "--log-window-size=1000", "-r%d" % revisions.pop(0)]
+ self._execVcs(*cmd, **kwargs)
+
+ cmd = ["rebase", "--log-window-size=1000", "--local", "--fetch-all", "git-svn"]
+ status, output = self._execVcs(*cmd, **kwargs)
+ if status == 0:
+ return [x.split() for x in output.split()]
+ return None
+
+
class SVNLook(VCSLook):
def __init__(self, repospath, txn=None, rev=None):
VCSLook.__init__(self, repospath, txn, rev)