##// END OF EJS Templates
convert: gitcmd wrapper for os.popen
Brendan Cully -
r5216:39e6deaa default
parent child Browse files
Show More
@@ -14,6 +14,9 b' def recode(s):'
14 14 return s.decode("utf-8", "replace").encode("utf-8")
15 15
16 16 class convert_git(converter_source):
17 def gitcmd(self, s):
18 return os.popen('GIT_DIR=%s %s' % (self.path, s))
19
17 20 def __init__(self, ui, path):
18 21 if os.path.isdir(path + "/.git"):
19 22 path += "/.git"
@@ -23,13 +26,12 b' class convert_git(converter_source):'
23 26 raise NoRepo("couldn't open GIT repo %s" % path)
24 27
25 28 def getheads(self):
26 fh = os.popen("GIT_DIR=%s git-rev-parse --verify HEAD" % self.path)
29 fh = self.gitcmd("git-rev-parse --verify HEAD")
27 30 return [fh.read()[:-1]]
28 31
29 32 def catfile(self, rev, type):
30 33 if rev == "0" * 40: raise IOError()
31 fh = os.popen("GIT_DIR=%s git-cat-file %s %s 2>/dev/null"
32 % (self.path, type, rev))
34 fh = self.gitcmd("git-cat-file %s %s 2>/dev/null" % (type, rev))
33 35 return fh.read()
34 36
35 37 def getfile(self, name, rev):
@@ -40,8 +42,7 b' class convert_git(converter_source):'
40 42
41 43 def getchanges(self, version):
42 44 self.modecache = {}
43 fh = os.popen("GIT_DIR=%s git-diff-tree --root -m -r %s"
44 % (self.path, version))
45 fh = self.gitcmd("git-diff-tree --root -m -r %s" % version)
45 46 changes = []
46 47 for l in fh:
47 48 if "\t" not in l: continue
@@ -89,7 +90,7 b' class convert_git(converter_source):'
89 90
90 91 def gettags(self):
91 92 tags = {}
92 fh = os.popen('git-ls-remote --tags "%s" 2>/dev/null' % self.path)
93 fh = self.gitcmd('git-ls-remote --tags "%s" 2>/dev/null' % self.path)
93 94 prefix = 'refs/tags/'
94 95 for line in fh:
95 96 line = line.strip()
General Comments 0
You need to be logged in to leave comments. Login now