comparison hgext/convert/git.py @ 10987:b3af02b1f19f stable

convert/git: check status when reading output stream
author Patrick Mezard <pmezard@gmail.com>
date Sun, 25 Apr 2010 23:07:46 +0200
parents 610f047326b9
children 33010ff1fd6f
comparison
equal deleted inserted replaced
10986:610f047326b9 10987:b3af02b1f19f
92 p = (entry[1] == "100755") 92 p = (entry[1] == "100755")
93 s = (entry[1] == "120000") 93 s = (entry[1] == "120000")
94 self.modecache[(f, h)] = (p and "x") or (s and "l") or "" 94 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
95 changes.append((f, h)) 95 changes.append((f, h))
96 entry = None 96 entry = None
97 if fh.close():
98 raise util.Abort(_('cannot read changes in %s') % version)
97 return (changes, {}) 99 return (changes, {})
98 100
99 def getcommit(self, version): 101 def getcommit(self, version):
100 c = self.catfile(version, "commit") # read the commit hash 102 c = self.catfile(version, "commit") # read the commit hash
101 end = c.find("\n\n") 103 end = c.find("\n\n")
142 node, tag = line.split(None, 1) 144 node, tag = line.split(None, 1)
143 if not tag.startswith(prefix): 145 if not tag.startswith(prefix):
144 continue 146 continue
145 tag = tag[len(prefix):-3] 147 tag = tag[len(prefix):-3]
146 tags[tag] = node 148 tags[tag] = node
149 if fh.close():
150 raise util.Abort(_('cannot read tags from %s') % self.path)
147 151
148 return tags 152 return tags
149 153
150 def getchangedfiles(self, version, i): 154 def getchangedfiles(self, version, i):
151 changes = [] 155 changes = []
154 for l in fh: 158 for l in fh:
155 if "\t" not in l: 159 if "\t" not in l:
156 continue 160 continue
157 m, f = l[:-1].split("\t") 161 m, f = l[:-1].split("\t")
158 changes.append(f) 162 changes.append(f)
159 fh.close()
160 else: 163 else:
161 fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --' 164 fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --'
162 % (version, version, i + 1)) 165 % (version, version, i + 1))
163 changes = [f.rstrip('\n') for f in fh] 166 changes = [f.rstrip('\n') for f in fh]
164 fh.close() 167 if fh.close():
168 raise util.Abort(_('cannot read changes in %s') % version)
165 169
166 return changes 170 return changes