Show More
@@ -407,3 +407,25 b' class mapfile(dict):' | |||||
407 | if self.fp: |
|
407 | if self.fp: | |
408 | self.fp.close() |
|
408 | self.fp.close() | |
409 | self.fp = None |
|
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 | from gnuarch import gnuarch_source |
|
15 | from gnuarch import gnuarch_source | |
16 | from bzr import bzr_source |
|
16 | from bzr import bzr_source | |
17 | from p4 import p4_source |
|
17 | from p4 import p4_source | |
18 | import filemap |
|
18 | import filemap, common | |
19 |
|
19 | |||
20 | import os, shutil |
|
20 | import os, shutil | |
21 | from mercurial import hg, util, encoding |
|
21 | from mercurial import hg, util, encoding | |
@@ -118,7 +118,7 b' class converter(object):' | |||||
118 | self.readauthormap(opts.get('authormap')) |
|
118 | self.readauthormap(opts.get('authormap')) | |
119 | self.authorfile = self.dest.authorfile() |
|
119 | self.authorfile = self.dest.authorfile() | |
120 |
|
120 | |||
121 |
self.splicemap = |
|
121 | self.splicemap = common.parsesplicemap(opts.get('splicemap')) | |
122 | self.branchmap = mapfile(ui, opts.get('branchmap')) |
|
122 | self.branchmap = mapfile(ui, opts.get('branchmap')) | |
123 |
|
123 | |||
124 | def walktree(self, heads): |
|
124 | def walktree(self, heads): | |
@@ -319,7 +319,7 b' class converter(object):' | |||||
319 | self.commitcache[prev].branch)) |
|
319 | self.commitcache[prev].branch)) | |
320 | self.dest.setbranch(commit.branch, pbranches) |
|
320 | self.dest.setbranch(commit.branch, pbranches) | |
321 | try: |
|
321 | try: | |
322 |
parents = self.splicemap[rev] |
|
322 | parents = self.splicemap[rev] | |
323 | self.ui.status(_('spliced in %s as parents of %s\n') % |
|
323 | self.ui.status(_('spliced in %s as parents of %s\n') % | |
324 | (parents, rev)) |
|
324 | (parents, rev)) | |
325 | parents = [self.map.get(p, p) for p in parents] |
|
325 | parents = [self.map.get(p, p) for p in parents] |
@@ -43,7 +43,7 b' test invalid splicemap' | |||||
43 | > $CHILDID2 |
|
43 | > $CHILDID2 | |
44 | > EOF |
|
44 | > EOF | |
45 | $ hg convert --splicemap splicemap repo2 repo1 |
|
45 | $ hg convert --splicemap splicemap repo2 repo1 | |
46 |
abort: syntax error in splicemap(1): |
|
46 | abort: syntax error in splicemap(1): child parent1[,parent2] expected | |
47 | [255] |
|
47 | [255] | |
48 |
|
48 | |||
49 | splice repo2 on repo1 |
|
49 | splice repo2 on repo1 |
General Comments 0
You need to be logged in to leave comments.
Login now