Skip to content
Snippets Groups Projects
Commit ebaa0aa749e2 authored by Patrick Mézard's avatar Patrick Mézard
Browse files

convert: turn splicemap into a simple dictionary

Parsing the splicemap as a mapfile was a pain because map does not let us
override its parsing code and splicemap entries are not key/values. Besides we
had no need for mapfiles extra features. Just parse the splicemap and return a
dictionary.
parent 3e1efb458e8b
No related branches found
No related tags found
No related merge requests found
......@@ -407,3 +407,25 @@
if self.fp:
self.fp.close()
self.fp = None
def parsesplicemap(path):
"""Parse a splicemap, return a child/parents dictionary."""
m = {}
try:
fp = open(path, 'r')
for i, line in enumerate(fp):
try:
child, parents = line.splitlines()[0].rstrip().rsplit(' ', 1)
parents = parents.replace(',', ' ').split()
except ValueError:
raise util.Abort(_('syntax error in %s(%d): child parent1'
'[,parent2] expected') % (path, i + 1))
pp = []
for p in parents:
if p not in pp:
pp.append(p)
m[child] = pp
except IOError, e:
if e.errno != errno.ENOENT:
raise
return m
......@@ -15,7 +15,7 @@
from gnuarch import gnuarch_source
from bzr import bzr_source
from p4 import p4_source
import filemap
import filemap, common
import os, shutil
from mercurial import hg, util, encoding
......@@ -118,7 +118,7 @@
self.readauthormap(opts.get('authormap'))
self.authorfile = self.dest.authorfile()
self.splicemap = mapfile(ui, opts.get('splicemap'))
self.splicemap = common.parsesplicemap(opts.get('splicemap'))
self.branchmap = mapfile(ui, opts.get('branchmap'))
def walktree(self, heads):
......@@ -319,7 +319,7 @@
self.commitcache[prev].branch))
self.dest.setbranch(commit.branch, pbranches)
try:
parents = self.splicemap[rev].replace(',', ' ').split()
parents = self.splicemap[rev]
self.ui.status(_('spliced in %s as parents of %s\n') %
(parents, rev))
parents = [self.map.get(p, p) for p in parents]
......
......@@ -43,7 +43,7 @@
> $CHILDID2
> EOF
$ hg convert --splicemap splicemap repo2 repo1
abort: syntax error in splicemap(1): key/value pair expected
abort: syntax error in splicemap(1): child parent1[,parent2] expected
[255]
splice repo2 on repo1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment