##// END OF EJS Templates
convert: don't ignore errors from git diff-tree
Julien Cristau -
r28816:f4a42bb7 default
parent child Browse files
Show More
@@ -1,397 +1,399
1 # git.py - git support for the convert extension
1 # git.py - git support for the convert extension
2 #
2 #
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7 from __future__ import absolute_import
7 from __future__ import absolute_import
8
8
9 import os
9 import os
10 from mercurial import (
10 from mercurial import (
11 config,
11 config,
12 error,
12 error,
13 node as nodemod,
13 node as nodemod,
14 )
14 )
15 from mercurial.i18n import _
15 from mercurial.i18n import _
16
16
17 from . import (
17 from . import (
18 common,
18 common,
19 )
19 )
20
20
21 class submodule(object):
21 class submodule(object):
22 def __init__(self, path, node, url):
22 def __init__(self, path, node, url):
23 self.path = path
23 self.path = path
24 self.node = node
24 self.node = node
25 self.url = url
25 self.url = url
26
26
27 def hgsub(self):
27 def hgsub(self):
28 return "%s = [git]%s" % (self.path, self.url)
28 return "%s = [git]%s" % (self.path, self.url)
29
29
30 def hgsubstate(self):
30 def hgsubstate(self):
31 return "%s %s" % (self.node, self.path)
31 return "%s %s" % (self.node, self.path)
32
32
33 class convert_git(common.converter_source, common.commandline):
33 class convert_git(common.converter_source, common.commandline):
34 # Windows does not support GIT_DIR= construct while other systems
34 # Windows does not support GIT_DIR= construct while other systems
35 # cannot remove environment variable. Just assume none have
35 # cannot remove environment variable. Just assume none have
36 # both issues.
36 # both issues.
37
37
38 def _gitcmd(self, cmd, *args, **kwargs):
38 def _gitcmd(self, cmd, *args, **kwargs):
39 return cmd('--git-dir=%s' % self.path, *args, **kwargs)
39 return cmd('--git-dir=%s' % self.path, *args, **kwargs)
40
40
41 def gitrun0(self, *args, **kwargs):
41 def gitrun0(self, *args, **kwargs):
42 return self._gitcmd(self.run0, *args, **kwargs)
42 return self._gitcmd(self.run0, *args, **kwargs)
43
43
44 def gitrun(self, *args, **kwargs):
44 def gitrun(self, *args, **kwargs):
45 return self._gitcmd(self.run, *args, **kwargs)
45 return self._gitcmd(self.run, *args, **kwargs)
46
46
47 def gitrunlines0(self, *args, **kwargs):
47 def gitrunlines0(self, *args, **kwargs):
48 return self._gitcmd(self.runlines0, *args, **kwargs)
48 return self._gitcmd(self.runlines0, *args, **kwargs)
49
49
50 def gitrunlines(self, *args, **kwargs):
50 def gitrunlines(self, *args, **kwargs):
51 return self._gitcmd(self.runlines, *args, **kwargs)
51 return self._gitcmd(self.runlines, *args, **kwargs)
52
52
53 def gitpipe(self, *args, **kwargs):
53 def gitpipe(self, *args, **kwargs):
54 return self._gitcmd(self._run3, *args, **kwargs)
54 return self._gitcmd(self._run3, *args, **kwargs)
55
55
56 def gitread(self, s):
56 def gitread(self, s):
57 fh = self.gitopen(s)
57 fh = self.gitopen(s)
58 data = fh.read()
58 data = fh.read()
59 return data, fh.close()
59 return data, fh.close()
60
60
61 def __init__(self, ui, path, revs=None):
61 def __init__(self, ui, path, revs=None):
62 super(convert_git, self).__init__(ui, path, revs=revs)
62 super(convert_git, self).__init__(ui, path, revs=revs)
63 common.commandline.__init__(self, ui, 'git')
63 common.commandline.__init__(self, ui, 'git')
64
64
65 if os.path.isdir(path + "/.git"):
65 if os.path.isdir(path + "/.git"):
66 path += "/.git"
66 path += "/.git"
67 if not os.path.exists(path + "/objects"):
67 if not os.path.exists(path + "/objects"):
68 raise common.NoRepo(_("%s does not look like a Git repository") %
68 raise common.NoRepo(_("%s does not look like a Git repository") %
69 path)
69 path)
70
70
71 # The default value (50) is based on the default for 'git diff'.
71 # The default value (50) is based on the default for 'git diff'.
72 similarity = ui.configint('convert', 'git.similarity', default=50)
72 similarity = ui.configint('convert', 'git.similarity', default=50)
73 if similarity < 0 or similarity > 100:
73 if similarity < 0 or similarity > 100:
74 raise error.Abort(_('similarity must be between 0 and 100'))
74 raise error.Abort(_('similarity must be between 0 and 100'))
75 if similarity > 0:
75 if similarity > 0:
76 self.simopt = ['-C%d%%' % similarity]
76 self.simopt = ['-C%d%%' % similarity]
77 findcopiesharder = ui.configbool('convert', 'git.findcopiesharder',
77 findcopiesharder = ui.configbool('convert', 'git.findcopiesharder',
78 False)
78 False)
79 if findcopiesharder:
79 if findcopiesharder:
80 self.simopt.append('--find-copies-harder')
80 self.simopt.append('--find-copies-harder')
81 else:
81 else:
82 self.simopt = []
82 self.simopt = []
83
83
84 common.checktool('git', 'git')
84 common.checktool('git', 'git')
85
85
86 self.path = path
86 self.path = path
87 self.submodules = []
87 self.submodules = []
88
88
89 self.catfilepipe = self.gitpipe('cat-file', '--batch')
89 self.catfilepipe = self.gitpipe('cat-file', '--batch')
90
90
91 def after(self):
91 def after(self):
92 for f in self.catfilepipe:
92 for f in self.catfilepipe:
93 f.close()
93 f.close()
94
94
95 def getheads(self):
95 def getheads(self):
96 if not self.revs:
96 if not self.revs:
97 output, status = self.gitrun('rev-parse', '--branches', '--remotes')
97 output, status = self.gitrun('rev-parse', '--branches', '--remotes')
98 heads = output.splitlines()
98 heads = output.splitlines()
99 if status:
99 if status:
100 raise error.Abort(_('cannot retrieve git heads'))
100 raise error.Abort(_('cannot retrieve git heads'))
101 else:
101 else:
102 heads = []
102 heads = []
103 for rev in self.revs:
103 for rev in self.revs:
104 rawhead, ret = self.gitrun('rev-parse', '--verify', rev)
104 rawhead, ret = self.gitrun('rev-parse', '--verify', rev)
105 heads.append(rawhead[:-1])
105 heads.append(rawhead[:-1])
106 if ret:
106 if ret:
107 raise error.Abort(_('cannot retrieve git head "%s"') % rev)
107 raise error.Abort(_('cannot retrieve git head "%s"') % rev)
108 return heads
108 return heads
109
109
110 def catfile(self, rev, type):
110 def catfile(self, rev, type):
111 if rev == nodemod.nullhex:
111 if rev == nodemod.nullhex:
112 raise IOError
112 raise IOError
113 self.catfilepipe[0].write(rev+'\n')
113 self.catfilepipe[0].write(rev+'\n')
114 self.catfilepipe[0].flush()
114 self.catfilepipe[0].flush()
115 info = self.catfilepipe[1].readline().split()
115 info = self.catfilepipe[1].readline().split()
116 if info[1] != type:
116 if info[1] != type:
117 raise error.Abort(_('cannot read %r object at %s') % (type, rev))
117 raise error.Abort(_('cannot read %r object at %s') % (type, rev))
118 size = int(info[2])
118 size = int(info[2])
119 data = self.catfilepipe[1].read(size)
119 data = self.catfilepipe[1].read(size)
120 if len(data) < size:
120 if len(data) < size:
121 raise error.Abort(_('cannot read %r object at %s: unexpected size')
121 raise error.Abort(_('cannot read %r object at %s: unexpected size')
122 % (type, rev))
122 % (type, rev))
123 # read the trailing newline
123 # read the trailing newline
124 self.catfilepipe[1].read(1)
124 self.catfilepipe[1].read(1)
125 return data
125 return data
126
126
127 def getfile(self, name, rev):
127 def getfile(self, name, rev):
128 if rev == nodemod.nullhex:
128 if rev == nodemod.nullhex:
129 return None, None
129 return None, None
130 if name == '.hgsub':
130 if name == '.hgsub':
131 data = '\n'.join([m.hgsub() for m in self.submoditer()])
131 data = '\n'.join([m.hgsub() for m in self.submoditer()])
132 mode = ''
132 mode = ''
133 elif name == '.hgsubstate':
133 elif name == '.hgsubstate':
134 data = '\n'.join([m.hgsubstate() for m in self.submoditer()])
134 data = '\n'.join([m.hgsubstate() for m in self.submoditer()])
135 mode = ''
135 mode = ''
136 else:
136 else:
137 data = self.catfile(rev, "blob")
137 data = self.catfile(rev, "blob")
138 mode = self.modecache[(name, rev)]
138 mode = self.modecache[(name, rev)]
139 return data, mode
139 return data, mode
140
140
141 def submoditer(self):
141 def submoditer(self):
142 null = nodemod.nullhex
142 null = nodemod.nullhex
143 for m in sorted(self.submodules, key=lambda p: p.path):
143 for m in sorted(self.submodules, key=lambda p: p.path):
144 if m.node != null:
144 if m.node != null:
145 yield m
145 yield m
146
146
147 def parsegitmodules(self, content):
147 def parsegitmodules(self, content):
148 """Parse the formatted .gitmodules file, example file format:
148 """Parse the formatted .gitmodules file, example file format:
149 [submodule "sub"]\n
149 [submodule "sub"]\n
150 \tpath = sub\n
150 \tpath = sub\n
151 \turl = git://giturl\n
151 \turl = git://giturl\n
152 """
152 """
153 self.submodules = []
153 self.submodules = []
154 c = config.config()
154 c = config.config()
155 # Each item in .gitmodules starts with whitespace that cant be parsed
155 # Each item in .gitmodules starts with whitespace that cant be parsed
156 c.parse('.gitmodules', '\n'.join(line.strip() for line in
156 c.parse('.gitmodules', '\n'.join(line.strip() for line in
157 content.split('\n')))
157 content.split('\n')))
158 for sec in c.sections():
158 for sec in c.sections():
159 s = c[sec]
159 s = c[sec]
160 if 'url' in s and 'path' in s:
160 if 'url' in s and 'path' in s:
161 self.submodules.append(submodule(s['path'], '', s['url']))
161 self.submodules.append(submodule(s['path'], '', s['url']))
162
162
163 def retrievegitmodules(self, version):
163 def retrievegitmodules(self, version):
164 modules, ret = self.gitrun('show', '%s:%s' % (version, '.gitmodules'))
164 modules, ret = self.gitrun('show', '%s:%s' % (version, '.gitmodules'))
165 if ret:
165 if ret:
166 # This can happen if a file is in the repo that has permissions
166 # This can happen if a file is in the repo that has permissions
167 # 160000, but there is no .gitmodules file.
167 # 160000, but there is no .gitmodules file.
168 self.ui.warn(_("warning: cannot read submodules config file in "
168 self.ui.warn(_("warning: cannot read submodules config file in "
169 "%s\n") % version)
169 "%s\n") % version)
170 return
170 return
171
171
172 try:
172 try:
173 self.parsegitmodules(modules)
173 self.parsegitmodules(modules)
174 except error.ParseError:
174 except error.ParseError:
175 self.ui.warn(_("warning: unable to parse .gitmodules in %s\n")
175 self.ui.warn(_("warning: unable to parse .gitmodules in %s\n")
176 % version)
176 % version)
177 return
177 return
178
178
179 for m in self.submodules:
179 for m in self.submodules:
180 node, ret = self.gitrun('rev-parse', '%s:%s' % (version, m.path))
180 node, ret = self.gitrun('rev-parse', '%s:%s' % (version, m.path))
181 if ret:
181 if ret:
182 continue
182 continue
183 m.node = node.strip()
183 m.node = node.strip()
184
184
185 def getchanges(self, version, full):
185 def getchanges(self, version, full):
186 if full:
186 if full:
187 raise error.Abort(_("convert from git does not support --full"))
187 raise error.Abort(_("convert from git does not support --full"))
188 self.modecache = {}
188 self.modecache = {}
189 cmd = ['diff-tree','-z', '--root', '-m', '-r'] + self.simopt + [version]
189 cmd = ['diff-tree','-z', '--root', '-m', '-r'] + self.simopt + [version]
190 output, status = self.gitrun(*cmd)
190 output, status = self.gitrun(*cmd)
191 if status:
191 if status:
192 raise error.Abort(_('cannot read changes in %s') % version)
192 raise error.Abort(_('cannot read changes in %s') % version)
193 changes = []
193 changes = []
194 copies = {}
194 copies = {}
195 seen = set()
195 seen = set()
196 entry = None
196 entry = None
197 subexists = [False]
197 subexists = [False]
198 subdeleted = [False]
198 subdeleted = [False]
199 difftree = output.split('\x00')
199 difftree = output.split('\x00')
200 lcount = len(difftree)
200 lcount = len(difftree)
201 i = 0
201 i = 0
202
202
203 skipsubmodules = self.ui.configbool('convert', 'git.skipsubmodules',
203 skipsubmodules = self.ui.configbool('convert', 'git.skipsubmodules',
204 False)
204 False)
205 def add(entry, f, isdest):
205 def add(entry, f, isdest):
206 seen.add(f)
206 seen.add(f)
207 h = entry[3]
207 h = entry[3]
208 p = (entry[1] == "100755")
208 p = (entry[1] == "100755")
209 s = (entry[1] == "120000")
209 s = (entry[1] == "120000")
210 renamesource = (not isdest and entry[4][0] == 'R')
210 renamesource = (not isdest and entry[4][0] == 'R')
211
211
212 if f == '.gitmodules':
212 if f == '.gitmodules':
213 if skipsubmodules:
213 if skipsubmodules:
214 return
214 return
215
215
216 subexists[0] = True
216 subexists[0] = True
217 if entry[4] == 'D' or renamesource:
217 if entry[4] == 'D' or renamesource:
218 subdeleted[0] = True
218 subdeleted[0] = True
219 changes.append(('.hgsub', nodemod.nullhex))
219 changes.append(('.hgsub', nodemod.nullhex))
220 else:
220 else:
221 changes.append(('.hgsub', ''))
221 changes.append(('.hgsub', ''))
222 elif entry[1] == '160000' or entry[0] == ':160000':
222 elif entry[1] == '160000' or entry[0] == ':160000':
223 if not skipsubmodules:
223 if not skipsubmodules:
224 subexists[0] = True
224 subexists[0] = True
225 else:
225 else:
226 if renamesource:
226 if renamesource:
227 h = nodemod.nullhex
227 h = nodemod.nullhex
228 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
228 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
229 changes.append((f, h))
229 changes.append((f, h))
230
230
231 while i < lcount:
231 while i < lcount:
232 l = difftree[i]
232 l = difftree[i]
233 i += 1
233 i += 1
234 if not entry:
234 if not entry:
235 if not l.startswith(':'):
235 if not l.startswith(':'):
236 continue
236 continue
237 entry = l.split()
237 entry = l.split()
238 continue
238 continue
239 f = l
239 f = l
240 if entry[4][0] == 'C':
240 if entry[4][0] == 'C':
241 copysrc = f
241 copysrc = f
242 copydest = difftree[i]
242 copydest = difftree[i]
243 i += 1
243 i += 1
244 f = copydest
244 f = copydest
245 copies[copydest] = copysrc
245 copies[copydest] = copysrc
246 if f not in seen:
246 if f not in seen:
247 add(entry, f, False)
247 add(entry, f, False)
248 # A file can be copied multiple times, or modified and copied
248 # A file can be copied multiple times, or modified and copied
249 # simultaneously. So f can be repeated even if fdest isn't.
249 # simultaneously. So f can be repeated even if fdest isn't.
250 if entry[4][0] == 'R':
250 if entry[4][0] == 'R':
251 # rename: next line is the destination
251 # rename: next line is the destination
252 fdest = difftree[i]
252 fdest = difftree[i]
253 i += 1
253 i += 1
254 if fdest not in seen:
254 if fdest not in seen:
255 add(entry, fdest, True)
255 add(entry, fdest, True)
256 # .gitmodules isn't imported at all, so it being copied to
256 # .gitmodules isn't imported at all, so it being copied to
257 # and fro doesn't really make sense
257 # and fro doesn't really make sense
258 if f != '.gitmodules' and fdest != '.gitmodules':
258 if f != '.gitmodules' and fdest != '.gitmodules':
259 copies[fdest] = f
259 copies[fdest] = f
260 entry = None
260 entry = None
261
261
262 if subexists[0]:
262 if subexists[0]:
263 if subdeleted[0]:
263 if subdeleted[0]:
264 changes.append(('.hgsubstate', nodemod.nullhex))
264 changes.append(('.hgsubstate', nodemod.nullhex))
265 else:
265 else:
266 self.retrievegitmodules(version)
266 self.retrievegitmodules(version)
267 changes.append(('.hgsubstate', ''))
267 changes.append(('.hgsubstate', ''))
268 return (changes, copies, set())
268 return (changes, copies, set())
269
269
270 def getcommit(self, version):
270 def getcommit(self, version):
271 c = self.catfile(version, "commit") # read the commit hash
271 c = self.catfile(version, "commit") # read the commit hash
272 end = c.find("\n\n")
272 end = c.find("\n\n")
273 message = c[end + 2:]
273 message = c[end + 2:]
274 message = self.recode(message)
274 message = self.recode(message)
275 l = c[:end].splitlines()
275 l = c[:end].splitlines()
276 parents = []
276 parents = []
277 author = committer = None
277 author = committer = None
278 for e in l[1:]:
278 for e in l[1:]:
279 n, v = e.split(" ", 1)
279 n, v = e.split(" ", 1)
280 if n == "author":
280 if n == "author":
281 p = v.split()
281 p = v.split()
282 tm, tz = p[-2:]
282 tm, tz = p[-2:]
283 author = " ".join(p[:-2])
283 author = " ".join(p[:-2])
284 if author[0] == "<": author = author[1:-1]
284 if author[0] == "<": author = author[1:-1]
285 author = self.recode(author)
285 author = self.recode(author)
286 if n == "committer":
286 if n == "committer":
287 p = v.split()
287 p = v.split()
288 tm, tz = p[-2:]
288 tm, tz = p[-2:]
289 committer = " ".join(p[:-2])
289 committer = " ".join(p[:-2])
290 if committer[0] == "<": committer = committer[1:-1]
290 if committer[0] == "<": committer = committer[1:-1]
291 committer = self.recode(committer)
291 committer = self.recode(committer)
292 if n == "parent":
292 if n == "parent":
293 parents.append(v)
293 parents.append(v)
294
294
295 if committer and committer != author:
295 if committer and committer != author:
296 message += "\ncommitter: %s\n" % committer
296 message += "\ncommitter: %s\n" % committer
297 tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:]
297 tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:]
298 tz = -int(tzs) * (int(tzh) * 3600 + int(tzm))
298 tz = -int(tzs) * (int(tzh) * 3600 + int(tzm))
299 date = tm + " " + str(tz)
299 date = tm + " " + str(tz)
300
300
301 c = common.commit(parents=parents, date=date, author=author,
301 c = common.commit(parents=parents, date=date, author=author,
302 desc=message,
302 desc=message,
303 rev=version)
303 rev=version)
304 return c
304 return c
305
305
306 def numcommits(self):
306 def numcommits(self):
307 output, ret = self.gitrunlines('rev-list', '--all')
307 output, ret = self.gitrunlines('rev-list', '--all')
308 if ret:
308 if ret:
309 raise error.Abort(_('cannot retrieve number of commits in %s') \
309 raise error.Abort(_('cannot retrieve number of commits in %s') \
310 % self.path)
310 % self.path)
311 return len(output)
311 return len(output)
312
312
313 def gettags(self):
313 def gettags(self):
314 tags = {}
314 tags = {}
315 alltags = {}
315 alltags = {}
316 output, status = self.gitrunlines('ls-remote', '--tags', self.path)
316 output, status = self.gitrunlines('ls-remote', '--tags', self.path)
317
317
318 if status:
318 if status:
319 raise error.Abort(_('cannot read tags from %s') % self.path)
319 raise error.Abort(_('cannot read tags from %s') % self.path)
320 prefix = 'refs/tags/'
320 prefix = 'refs/tags/'
321
321
322 # Build complete list of tags, both annotated and bare ones
322 # Build complete list of tags, both annotated and bare ones
323 for line in output:
323 for line in output:
324 line = line.strip()
324 line = line.strip()
325 if line.startswith("error:") or line.startswith("fatal:"):
325 if line.startswith("error:") or line.startswith("fatal:"):
326 raise error.Abort(_('cannot read tags from %s') % self.path)
326 raise error.Abort(_('cannot read tags from %s') % self.path)
327 node, tag = line.split(None, 1)
327 node, tag = line.split(None, 1)
328 if not tag.startswith(prefix):
328 if not tag.startswith(prefix):
329 continue
329 continue
330 alltags[tag[len(prefix):]] = node
330 alltags[tag[len(prefix):]] = node
331
331
332 # Filter out tag objects for annotated tag refs
332 # Filter out tag objects for annotated tag refs
333 for tag in alltags:
333 for tag in alltags:
334 if tag.endswith('^{}'):
334 if tag.endswith('^{}'):
335 tags[tag[:-3]] = alltags[tag]
335 tags[tag[:-3]] = alltags[tag]
336 else:
336 else:
337 if tag + '^{}' in alltags:
337 if tag + '^{}' in alltags:
338 continue
338 continue
339 else:
339 else:
340 tags[tag] = alltags[tag]
340 tags[tag] = alltags[tag]
341
341
342 return tags
342 return tags
343
343
344 def getchangedfiles(self, version, i):
344 def getchangedfiles(self, version, i):
345 changes = []
345 changes = []
346 if i is None:
346 if i is None:
347 output, status = self.gitrunlines('diff-tree', '--root', '-m',
347 output, status = self.gitrunlines('diff-tree', '--root', '-m',
348 '-r', version)
348 '-r', version)
349 if status:
349 if status:
350 raise error.Abort(_('cannot read changes in %s') % version)
350 raise error.Abort(_('cannot read changes in %s') % version)
351 for l in output:
351 for l in output:
352 if "\t" not in l:
352 if "\t" not in l:
353 continue
353 continue
354 m, f = l[:-1].split("\t")
354 m, f = l[:-1].split("\t")
355 changes.append(f)
355 changes.append(f)
356 else:
356 else:
357 output, status = self.gitrunlines('diff-tree', '--name-only',
357 output, status = self.gitrunlines('diff-tree', '--name-only',
358 '--root', '-r', version,
358 '--root', '-r', version,
359 '%s^%s' % (version, i + 1), '--')
359 '%s^%s' % (version, i + 1), '--')
360 if status:
361 raise error.Abort(_('cannot read changes in %s') % version)
360 changes = [f.rstrip('\n') for f in output]
362 changes = [f.rstrip('\n') for f in output]
361
363
362 return changes
364 return changes
363
365
364 def getbookmarks(self):
366 def getbookmarks(self):
365 bookmarks = {}
367 bookmarks = {}
366
368
367 # Handle local and remote branches
369 # Handle local and remote branches
368 remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote')
370 remoteprefix = self.ui.config('convert', 'git.remoteprefix', 'remote')
369 reftypes = [
371 reftypes = [
370 # (git prefix, hg prefix)
372 # (git prefix, hg prefix)
371 ('refs/remotes/origin/', remoteprefix + '/'),
373 ('refs/remotes/origin/', remoteprefix + '/'),
372 ('refs/heads/', '')
374 ('refs/heads/', '')
373 ]
375 ]
374
376
375 exclude = set([
377 exclude = set([
376 'refs/remotes/origin/HEAD',
378 'refs/remotes/origin/HEAD',
377 ])
379 ])
378
380
379 try:
381 try:
380 output, status = self.gitrunlines('show-ref')
382 output, status = self.gitrunlines('show-ref')
381 for line in output:
383 for line in output:
382 line = line.strip()
384 line = line.strip()
383 rev, name = line.split(None, 1)
385 rev, name = line.split(None, 1)
384 # Process each type of branch
386 # Process each type of branch
385 for gitprefix, hgprefix in reftypes:
387 for gitprefix, hgprefix in reftypes:
386 if not name.startswith(gitprefix) or name in exclude:
388 if not name.startswith(gitprefix) or name in exclude:
387 continue
389 continue
388 name = '%s%s' % (hgprefix, name[len(gitprefix):])
390 name = '%s%s' % (hgprefix, name[len(gitprefix):])
389 bookmarks[name] = rev
391 bookmarks[name] = rev
390 except Exception:
392 except Exception:
391 pass
393 pass
392
394
393 return bookmarks
395 return bookmarks
394
396
395 def checkrevformat(self, revstr, mapname='splicemap'):
397 def checkrevformat(self, revstr, mapname='splicemap'):
396 """ git revision string is a 40 byte hex """
398 """ git revision string is a 40 byte hex """
397 self.checkhexformat(revstr, mapname)
399 self.checkhexformat(revstr, mapname)
General Comments 0
You need to be logged in to leave comments. Login now