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

login
register
mail settings
Submitter Ben Goswami
Date April 30, 2013, 8:13 p.m.
Message ID <e00f1814391cc4d44c50.1367352797@devrs155.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1517/
State Superseded
Commit 61f1223ab3581370f1109af302c52653a9ca05cd
Headers show

Comments

Ben Goswami - April 30, 2013, 8:13 p.m.
# HG changeset patch
# User Ben Goswami <bengoswami@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
Bryan O'Sullivan - April 30, 2013, 10:36 p.m.
On Tue, Apr 30, 2013 at 2:46 PM, Kevin Bullock <
kbullock+mercurial@ringworld.org> wrote:

> This series is way too much code movement for the last couple days of a
> code freeze. The bug it fixes also isn't critical. I'd recommend sending
> the series again after tomorrow.
>

How about letting it just mature in your mailbox until after the freeze
ends. It's fine to not review something like this during a freeze, but
there is no benefit to anyone from telling someone to resend the patch
series in 30 hours.

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