splicemap: move parsesplicemap to convcmd.py (issue2084)
authorBen Goswami <bengoswami@fb.com>
Wed, 24 Apr 2013 18:26:37 -0700
changeset 19119 61f1223ab358
parent 19118 b09acf81abcc
child 19120 58e782f076e7
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
hgext/convert/common.py
hgext/convert/convcmd.py
--- a/hgext/convert/common.py	Thu May 02 14:11:34 2013 -0500
+++ b/hgext/convert/common.py	Wed Apr 24 18:26:37 2013 -0700
@@ -424,34 +424,6 @@
             self.fp.close()
             self.fp = None
 
-def parsesplicemap(path):
-    """Parse a splicemap, return a child/parents dictionary."""
-    if not path:
-        return {}
-    m = {}
-    try:
-        fp = open(path, 'r')
-        for i, line in enumerate(fp):
-            line = line.splitlines()[0].rstrip()
-            if not line:
-                # Ignore blank lines
-                continue
-            try:
-                child, parents = line.split(' ', 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
-
 def makedatetimestamp(t):
     """Like util.makedate() but for time t instead of current time"""
     delta = (datetime.datetime.utcfromtimestamp(t) -
--- a/hgext/convert/convcmd.py	Thu May 02 14:11:34 2013 -0500
+++ b/hgext/convert/convcmd.py	Wed Apr 24 18:26:37 2013 -0700
@@ -15,7 +15,7 @@
 from gnuarch import gnuarch_source
 from bzr import bzr_source
 from p4 import p4_source
-import filemap, common
+import filemap
 
 import os, shutil
 from mercurial import hg, util, encoding
@@ -118,9 +118,39 @@
             self.readauthormap(opts.get('authormap'))
             self.authorfile = self.dest.authorfile()
 
-        self.splicemap = common.parsesplicemap(opts.get('splicemap'))
+        self.splicemap = self.parsesplicemap(opts.get('splicemap'))
         self.branchmap = mapfile(ui, opts.get('branchmap'))
 
+
+    def parsesplicemap(self, path):
+        """Parse a splicemap, return a child/parents dictionary."""
+        if not path:
+            return {}
+        m = {}
+        try:
+            fp = open(path, 'r')
+            for i, line in enumerate(fp):
+                line = line.splitlines()[0].rstrip()
+                if not line:
+                    # Ignore blank lines
+                    continue
+                try:
+                    child, parents = line.split(' ', 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
+
+
     def walktree(self, heads):
         '''Return a mapping that identifies the uncommitted parents of every
         uncommitted changeset.'''