[PATCH 1 of 4] splicemap: move parsesplicemap to convcmd.py (issue2084)

Ben Goswami bengoswami at fb.com
Tue Apr 30 15:13:17 CDT 2013


# HG changeset patch
# User Ben Goswami <bengoswami at fb.com>
# Date 1366853197 25200
#      Wed Apr 24 18:26:37 2013 -0700
# Node ID e00f1814391cc4d44c5007b2874cd7c39901c817
# Parent  12acbea17625a1441503418f7f2f49aa3825cf2f
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

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -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) -
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -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.'''


More information about the Mercurial-devel mailing list