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

login
register
mail settings
Submitter Ben Goswami
Date May 1, 2013, 1 a.m.
Message ID <b33b3ecea9c598dd1a96.1367370057@devrs155.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1522/
State Accepted
Commit 61f1223ab3581370f1109af302c52653a9ca05cd
Headers show

Comments

Ben Goswami - May 1, 2013, 1 a.m.
# HG changeset patch
# User Ben Goswami <bengoswami@fb.com>
# Date 1366853197 25200
#      Wed Apr 24 18:26:37 2013 -0700
# Node ID b33b3ecea9c598dd1a9630f2f0c5c6f798c196f8
# 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

Patch

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.'''