Mercurial > hg
comparison hgext/convert/convcmd.py @ 19119:61f1223ab358
splicemap: move parsesplicemap to convcmd.py (issue2084)
parsesplicemap is only referenced from convcmd.py
This move is necessary to enable other changes related to
this issue
author | Ben Goswami <bengoswami@fb.com> |
---|---|
date | Wed, 24 Apr 2013 18:26:37 -0700 |
parents | 05acdf8e1f23 |
children | 58e782f076e7 |
comparison
equal
deleted
inserted
replaced
19118:b09acf81abcc | 19119:61f1223ab358 |
---|---|
13 from subversion import svn_source, svn_sink | 13 from subversion import svn_source, svn_sink |
14 from monotone import monotone_source | 14 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, common | 18 import filemap |
19 | 19 |
20 import os, shutil | 20 import os, shutil |
21 from mercurial import hg, util, encoding | 21 from mercurial import hg, util, encoding |
22 from mercurial.i18n import _ | 22 from mercurial.i18n import _ |
23 | 23 |
116 # Extend/Override with new author map if necessary | 116 # Extend/Override with new author map if necessary |
117 if opts.get('authormap'): | 117 if opts.get('authormap'): |
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 = common.parsesplicemap(opts.get('splicemap')) | 121 self.splicemap = self.parsesplicemap(opts.get('splicemap')) |
122 self.branchmap = mapfile(ui, opts.get('branchmap')) | 122 self.branchmap = mapfile(ui, opts.get('branchmap')) |
123 | |
124 | |
125 def parsesplicemap(self, path): | |
126 """Parse a splicemap, return a child/parents dictionary.""" | |
127 if not path: | |
128 return {} | |
129 m = {} | |
130 try: | |
131 fp = open(path, 'r') | |
132 for i, line in enumerate(fp): | |
133 line = line.splitlines()[0].rstrip() | |
134 if not line: | |
135 # Ignore blank lines | |
136 continue | |
137 try: | |
138 child, parents = line.split(' ', 1) | |
139 parents = parents.replace(',', ' ').split() | |
140 except ValueError: | |
141 raise util.Abort(_('syntax error in %s(%d): child parent1' | |
142 '[,parent2] expected') % (path, i + 1)) | |
143 pp = [] | |
144 for p in parents: | |
145 if p not in pp: | |
146 pp.append(p) | |
147 m[child] = pp | |
148 except IOError, e: | |
149 if e.errno != errno.ENOENT: | |
150 raise | |
151 return m | |
152 | |
123 | 153 |
124 def walktree(self, heads): | 154 def walktree(self, heads): |
125 '''Return a mapping that identifies the uncommitted parents of every | 155 '''Return a mapping that identifies the uncommitted parents of every |
126 uncommitted changeset.''' | 156 uncommitted changeset.''' |
127 visit = heads | 157 visit = heads |