Patchwork [3,of,3] convert: secret config option for disabling debugsvnlog

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 7, 2014, 4:37 p.m.
Message ID <6a5c6d529e603d886d6c.1391791032@mk-desktop>
Download mbox | patch
Permalink /patch/3514/
State Accepted
Commit 62153c5d1ce29dc1a545b62fdf374a68f053ea57
Headers show

Comments

Mads Kiilerich - Feb. 7, 2014, 4:37 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1391790577 -3600
#      Fri Feb 07 17:29:37 2014 +0100
# Node ID 6a5c6d529e603d886d6c822093f87aad6ee35db1
# Parent  418d3b7958df5445b776c15a5a6272c17e8175ea
convert: secret config option for disabling debugsvnlog

Subversion issues involving svn log such as d54467c1a198 can be tricky to
debug when it is run in an 'hg debugsvnlog' sub process. Debugging is simpler
when convert only uses one process.

With this change convert will invoke the svn log directly when setting
  [convert]
  svn.debugsvnlog = False

This is intentionally not documented.
Matt Mackall - Feb. 10, 2014, 12:25 a.m.
On Fri, 2014-02-07 at 17:37 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1391790577 -3600
> #      Fri Feb 07 17:29:37 2014 +0100
> # Node ID 6a5c6d529e603d886d6c822093f87aad6ee35db1
> # Parent  418d3b7958df5445b776c15a5a6272c17e8175ea
> convert: secret config option for disabling debugsvnlog

These are queued for default, thanks.

Patch

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -174,6 +174,30 @@ 
             self._stdout.close()
             self._stdout = None
 
+class directlogstream(list):
+    """Direct revision log iterator.
+    This can be used for debugging and development but it will probably leak
+    memory and is not suitable for real conversions."""
+    def __init__(self, url, paths, start, end, limit=0,
+                  discover_changed_paths=True, strict_node_history=False):
+
+        def receiver(orig_paths, revnum, author, date, message, pool):
+            paths = {}
+            if orig_paths is not None:
+                for k, v in orig_paths.iteritems():
+                    paths[k] = changedpath(v)
+            self.append((paths, revnum, author, date, message))
+
+        # Use an ra of our own so that our parent can consume
+        # our results without confusing the server.
+        t = transport.SvnRaTransport(url=url)
+        svn.ra.get_log(t.ra, paths, start, end, limit,
+                       discover_changed_paths,
+                       strict_node_history,
+                       receiver)
+
+    def close(self):
+        pass
 
 # Check to see if the given path is a local Subversion repo. Verify this by
 # looking for several svn-specific files and directories in the given
@@ -992,6 +1016,9 @@ 
             relpaths.append(p.strip('/'))
         args = [self.baseurl, relpaths, start, end, limit,
                 discover_changed_paths, strict_node_history]
+        # undocumented feature: debugsvnlog can be disabled
+        if not self.ui.configbool('convert', 'svn.debugsvnlog', True):
+            return directlogstream(*args)
         arg = encodeargs(args)
         hgexe = util.hgexecutable()
         cmd = '%s debugsvnlog' % util.shellquote(hgexe)
diff --git a/tests/test-convert-svn-source.t b/tests/test-convert-svn-source.t
--- a/tests/test-convert-svn-source.t
+++ b/tests/test-convert-svn-source.t
@@ -198,11 +198,12 @@ 
   extra:       convert_revision=svn:........-....-....-....-............/proj B/mytrunk@1 (re)
   $ cd ..
 
-Test converting empty heads (issue3347)
+Test converting empty heads (issue3347).
+Also tests getting logs directly without debugsvnlog.
 
   $ svnadmin create svn-empty
   $ svnadmin load -q svn-empty < "$TESTDIR/svn/empty.svndump"
-  $ hg --config convert.svn.trunk= convert svn-empty
+  $ hg --config convert.svn.trunk= --config convert.svn.debugsvnlog=0 convert svn-empty
   assuming destination svn-empty-hg
   initializing destination svn-empty-hg repository
   scanning source...