##// END OF EJS Templates
convert: turn splicemap into a simple dictionary...
Patrick Mezard -
r16105:ebaa0aa7 stable
parent child Browse files
Show More
@@ -407,3 +407,25 b' class mapfile(dict):'
407 407 if self.fp:
408 408 self.fp.close()
409 409 self.fp = None
410
411 def parsesplicemap(path):
412 """Parse a splicemap, return a child/parents dictionary."""
413 m = {}
414 try:
415 fp = open(path, 'r')
416 for i, line in enumerate(fp):
417 try:
418 child, parents = line.splitlines()[0].rstrip().rsplit(' ', 1)
419 parents = parents.replace(',', ' ').split()
420 except ValueError:
421 raise util.Abort(_('syntax error in %s(%d): child parent1'
422 '[,parent2] expected') % (path, i + 1))
423 pp = []
424 for p in parents:
425 if p not in pp:
426 pp.append(p)
427 m[child] = pp
428 except IOError, e:
429 if e.errno != errno.ENOENT:
430 raise
431 return m
@@ -15,7 +15,7 b' from monotone import monotone_source'
15 15 from gnuarch import gnuarch_source
16 16 from bzr import bzr_source
17 17 from p4 import p4_source
18 import filemap
18 import filemap, common
19 19
20 20 import os, shutil
21 21 from mercurial import hg, util, encoding
@@ -118,7 +118,7 b' class converter(object):'
118 118 self.readauthormap(opts.get('authormap'))
119 119 self.authorfile = self.dest.authorfile()
120 120
121 self.splicemap = mapfile(ui, opts.get('splicemap'))
121 self.splicemap = common.parsesplicemap(opts.get('splicemap'))
122 122 self.branchmap = mapfile(ui, opts.get('branchmap'))
123 123
124 124 def walktree(self, heads):
@@ -319,7 +319,7 b' class converter(object):'
319 319 self.commitcache[prev].branch))
320 320 self.dest.setbranch(commit.branch, pbranches)
321 321 try:
322 parents = self.splicemap[rev].replace(',', ' ').split()
322 parents = self.splicemap[rev]
323 323 self.ui.status(_('spliced in %s as parents of %s\n') %
324 324 (parents, rev))
325 325 parents = [self.map.get(p, p) for p in parents]
@@ -43,7 +43,7 b' test invalid splicemap'
43 43 > $CHILDID2
44 44 > EOF
45 45 $ hg convert --splicemap splicemap repo2 repo1
46 abort: syntax error in splicemap(1): key/value pair expected
46 abort: syntax error in splicemap(1): child parent1[,parent2] expected
47 47 [255]
48 48
49 49 splice repo2 on repo1
General Comments 0
You need to be logged in to leave comments. Login now