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