--- a/hgext/convert/git.py Sun Jul 01 20:30:04 2007 -0700
+++ b/hgext/convert/git.py Sun Jul 01 21:09:08 2007 -0700
@@ -5,6 +5,9 @@
from common import NoRepo, commit, converter_source
class convert_git(converter_source):
+ def gitcmd(self, s):
+ return os.popen('GIT_DIR=%s %s' % (self.path, s))
+
def __init__(self, ui, path, rev=None):
if os.path.isdir(path + "/.git"):
path += "/.git"
@@ -18,13 +21,12 @@
def getheads(self):
rev = self.rev or 'HEAD'
- fh = os.popen("GIT_DIR=%s git-rev-parse --verify %s" % (self.path, rev))
+ fh = self.gitcmd("git-rev-parse --verify %s" % rev)
return [fh.read()[:-1]]
def catfile(self, rev, type):
if rev == "0" * 40: raise IOError()
- fh = os.popen("GIT_DIR=%s git-cat-file %s %s 2>/dev/null"
- % (self.path, type, rev))
+ fh = self.gitcmd("git-cat-file %s %s 2>/dev/null" % (type, rev))
return fh.read()
def getfile(self, name, rev):
@@ -35,8 +37,7 @@
def getchanges(self, version):
self.modecache = {}
- fh = os.popen("GIT_DIR=%s git-diff-tree --root -m -r %s"
- % (self.path, version))
+ fh = self.gitcmd("git-diff-tree --root -m -r %s" % version)
changes = []
for l in fh:
if "\t" not in l: continue
@@ -84,7 +85,7 @@
def gettags(self):
tags = {}
- fh = os.popen('git-ls-remote --tags "%s" 2>/dev/null' % self.path)
+ fh = self.gitcmd('git-ls-remote --tags "%s" 2>/dev/null' % self.path)
prefix = 'refs/tags/'
for line in fh:
line = line.strip()