comparison hgext/convert/git.py @ 6837:e30c56f337b1

convert: use git executable only, with subcommands The latest GIT has some changes in the way it is installed. Only the 'git' executable need to be in the path. All other commands are treated as sub commands of 'git'.
author Dhruva Krishnamurthy <dhruvakm@gmail.com>
date Thu, 24 Jul 2008 22:44:15 +0200
parents 30d2fecaab76
children c1dc903dc7b6
comparison
equal deleted inserted replaced
6835:08d9e0f974d9 6837:e30c56f337b1
30 if os.path.isdir(path + "/.git"): 30 if os.path.isdir(path + "/.git"):
31 path += "/.git" 31 path += "/.git"
32 if not os.path.exists(path + "/objects"): 32 if not os.path.exists(path + "/objects"):
33 raise NoRepo("%s does not look like a Git repo" % path) 33 raise NoRepo("%s does not look like a Git repo" % path)
34 34
35 checktool('git-rev-parse', 'git') 35 checktool('git', 'git')
36 36
37 self.path = path 37 self.path = path
38 38
39 def getheads(self): 39 def getheads(self):
40 if not self.rev: 40 if not self.rev:
41 return self.gitcmd('git-rev-parse --branches').read().splitlines() 41 return self.gitcmd('git rev-parse --branches').read().splitlines()
42 else: 42 else:
43 fh = self.gitcmd("git-rev-parse --verify %s" % self.rev) 43 fh = self.gitcmd("git rev-parse --verify %s" % self.rev)
44 return [fh.read()[:-1]] 44 return [fh.read()[:-1]]
45 45
46 def catfile(self, rev, type): 46 def catfile(self, rev, type):
47 if rev == "0" * 40: raise IOError() 47 if rev == "0" * 40: raise IOError()
48 fh = self.gitcmd("git-cat-file %s %s" % (type, rev)) 48 fh = self.gitcmd("git cat-file %s %s" % (type, rev))
49 return fh.read() 49 return fh.read()
50 50
51 def getfile(self, name, rev): 51 def getfile(self, name, rev):
52 return self.catfile(rev, "blob") 52 return self.catfile(rev, "blob")
53 53
54 def getmode(self, name, rev): 54 def getmode(self, name, rev):
55 return self.modecache[(name, rev)] 55 return self.modecache[(name, rev)]
56 56
57 def getchanges(self, version): 57 def getchanges(self, version):
58 self.modecache = {} 58 self.modecache = {}
59 fh = self.gitcmd("git-diff-tree --root -m -r %s" % version) 59 fh = self.gitcmd("git diff-tree --root -m -r %s" % version)
60 changes = [] 60 changes = []
61 seen = {} 61 seen = {}
62 for l in fh: 62 for l in fh:
63 if "\t" not in l: 63 if "\t" not in l:
64 continue 64 continue
107 rev=version) 107 rev=version)
108 return c 108 return c
109 109
110 def gettags(self): 110 def gettags(self):
111 tags = {} 111 tags = {}
112 fh = self.gitcmd('git-ls-remote --tags "%s"' % self.path) 112 fh = self.gitcmd('git ls-remote --tags "%s"' % self.path)
113 prefix = 'refs/tags/' 113 prefix = 'refs/tags/'
114 for line in fh: 114 for line in fh:
115 line = line.strip() 115 line = line.strip()
116 if not line.endswith("^{}"): 116 if not line.endswith("^{}"):
117 continue 117 continue
124 return tags 124 return tags
125 125
126 def getchangedfiles(self, version, i): 126 def getchangedfiles(self, version, i):
127 changes = [] 127 changes = []
128 if i is None: 128 if i is None:
129 fh = self.gitcmd("git-diff-tree --root -m -r %s" % version) 129 fh = self.gitcmd("git diff-tree --root -m -r %s" % version)
130 for l in fh: 130 for l in fh:
131 if "\t" not in l: 131 if "\t" not in l:
132 continue 132 continue
133 m, f = l[:-1].split("\t") 133 m, f = l[:-1].split("\t")
134 changes.append(f) 134 changes.append(f)
135 fh.close() 135 fh.close()
136 else: 136 else:
137 fh = self.gitcmd('git-diff-tree --name-only --root -r %s "%s^%s" --' 137 fh = self.gitcmd('git diff-tree --name-only --root -r %s "%s^%s" --'
138 % (version, version, i+1)) 138 % (version, version, i+1))
139 changes = [f.rstrip('\n') for f in fh] 139 changes = [f.rstrip('\n') for f in fh]
140 fh.close() 140 fh.close()
141 141
142 return changes 142 return changes