[PATCH STABLE V3] convert: avoid wrong lfconvert defaults by moving configitems to core

Matt Harbison mharbison72 at gmail.com
Tue Nov 28 23:47:18 EST 2017


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1511929208 18000
#      Tue Nov 28 23:20:08 2017 -0500
# Branch stable
# Node ID 17c4806300527a9b637e0d37c0d080680b5b2a7e
# Parent  96dcc78468e3adc8170500ec351c6524f759f132
convert: avoid wrong lfconvert defaults by moving configitems to core

The `hg lfconvert --to-normal` command uses the convert extension internally to
work its magic, but that produced devel-warn messages if the convert extension
wasn't loaded by the user.  The test in fcd2f9b06629 (modified here) wasn't
showing the warnings because the convert extension was loaded via $HGRCPATH.
Most of the config options default to None/False, but 'hg.usebranchnames' and
'hg.tagsbranch' are supposed to default to True and 'default' respectively.

The first iteration of this was to ui.setconfig() inside lfconvert, to force the
convert extension to load.  But there really is no precedent for doing this, and
check-config complained that 'extensions.convert' isn't documented.  Yuya
suggested this alternative.

This partially backs out 0d5a1175d0f9.

diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py
--- a/hgext/convert/__init__.py
+++ b/hgext/convert/__init__.py
@@ -28,103 +28,6 @@
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
-configtable = {}
-configitem = registrar.configitem(configtable)
-
-configitem('convert', 'cvsps.cache',
-    default=True,
-)
-configitem('convert', 'cvsps.fuzz',
-    default=60,
-)
-configitem('convert', 'cvsps.logencoding',
-    default=None,
-)
-configitem('convert', 'cvsps.mergefrom',
-    default=None,
-)
-configitem('convert', 'cvsps.mergeto',
-    default=None,
-)
-configitem('convert', 'git.committeractions',
-    default=lambda: ['messagedifferent'],
-)
-configitem('convert', 'git.extrakeys',
-    default=list,
-)
-configitem('convert', 'git.findcopiesharder',
-    default=False,
-)
-configitem('convert', 'git.remoteprefix',
-    default='remote',
-)
-configitem('convert', 'git.renamelimit',
-    default=400,
-)
-configitem('convert', 'git.saverev',
-    default=True,
-)
-configitem('convert', 'git.similarity',
-    default=50,
-)
-configitem('convert', 'git.skipsubmodules',
-    default=False,
-)
-configitem('convert', 'hg.clonebranches',
-    default=False,
-)
-configitem('convert', 'hg.ignoreerrors',
-    default=False,
-)
-configitem('convert', 'hg.revs',
-    default=None,
-)
-configitem('convert', 'hg.saverev',
-    default=False,
-)
-configitem('convert', 'hg.sourcename',
-    default=None,
-)
-configitem('convert', 'hg.startrev',
-    default=None,
-)
-configitem('convert', 'hg.tagsbranch',
-    default='default',
-)
-configitem('convert', 'hg.usebranchnames',
-    default=True,
-)
-configitem('convert', 'ignoreancestorcheck',
-    default=False,
-)
-configitem('convert', 'localtimezone',
-    default=False,
-)
-configitem('convert', 'p4.encoding',
-    default=lambda: convcmd.orig_encoding,
-)
-configitem('convert', 'p4.startrev',
-    default=0,
-)
-configitem('convert', 'skiptags',
-    default=False,
-)
-configitem('convert', 'svn.debugsvnlog',
-    default=True,
-)
-configitem('convert', 'svn.trunk',
-    default=None,
-)
-configitem('convert', 'svn.tags',
-    default=None,
-)
-configitem('convert', 'svn.branches',
-    default=None,
-)
-configitem('convert', 'svn.startrev',
-    default=0,
-)
-
 # Commands definition was moved elsewhere to ease demandload job.
 
 @command('convert',
diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -44,6 +44,9 @@
 
 class p4_source(common.converter_source):
     def __init__(self, ui, path, revs=None):
+        # avoid import cycle
+        from . import convcmd
+
         super(p4_source, self).__init__(ui, path, revs=revs)
 
         if "/" in path and not path.startswith('//'):
@@ -53,7 +56,8 @@
         common.checktool('p4', abort=False)
 
         self.revmap = {}
-        self.encoding = self.ui.config('convert', 'p4.encoding')
+        self.encoding = self.ui.config('convert', 'p4.encoding',
+                                       convcmd.orig_encoding)
         self.re_type = re.compile(
             "([a-z]+)?(text|binary|symlink|apple|resource|unicode|utf\d+)"
             "(\+\w+)?$")
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -208,6 +208,99 @@
     default=None,
     generic=True,
 )
+coreconfigitem('convert', 'cvsps.cache',
+    default=True,
+)
+coreconfigitem('convert', 'cvsps.fuzz',
+    default=60,
+)
+coreconfigitem('convert', 'cvsps.logencoding',
+    default=None,
+)
+coreconfigitem('convert', 'cvsps.mergefrom',
+    default=None,
+)
+coreconfigitem('convert', 'cvsps.mergeto',
+    default=None,
+)
+coreconfigitem('convert', 'git.committeractions',
+    default=lambda: ['messagedifferent'],
+)
+coreconfigitem('convert', 'git.extrakeys',
+    default=list,
+)
+coreconfigitem('convert', 'git.findcopiesharder',
+    default=False,
+)
+coreconfigitem('convert', 'git.remoteprefix',
+    default='remote',
+)
+coreconfigitem('convert', 'git.renamelimit',
+    default=400,
+)
+coreconfigitem('convert', 'git.saverev',
+    default=True,
+)
+coreconfigitem('convert', 'git.similarity',
+    default=50,
+)
+coreconfigitem('convert', 'git.skipsubmodules',
+    default=False,
+)
+coreconfigitem('convert', 'hg.clonebranches',
+    default=False,
+)
+coreconfigitem('convert', 'hg.ignoreerrors',
+    default=False,
+)
+coreconfigitem('convert', 'hg.revs',
+    default=None,
+)
+coreconfigitem('convert', 'hg.saverev',
+    default=False,
+)
+coreconfigitem('convert', 'hg.sourcename',
+    default=None,
+)
+coreconfigitem('convert', 'hg.startrev',
+    default=None,
+)
+coreconfigitem('convert', 'hg.tagsbranch',
+    default='default',
+)
+coreconfigitem('convert', 'hg.usebranchnames',
+    default=True,
+)
+coreconfigitem('convert', 'ignoreancestorcheck',
+    default=False,
+)
+coreconfigitem('convert', 'localtimezone',
+    default=False,
+)
+coreconfigitem('convert', 'p4.encoding',
+    default=dynamicdefault,
+)
+coreconfigitem('convert', 'p4.startrev',
+    default=0,
+)
+coreconfigitem('convert', 'skiptags',
+    default=False,
+)
+coreconfigitem('convert', 'svn.debugsvnlog',
+    default=True,
+)
+coreconfigitem('convert', 'svn.trunk',
+    default=None,
+)
+coreconfigitem('convert', 'svn.tags',
+    default=None,
+)
+coreconfigitem('convert', 'svn.branches',
+    default=None,
+)
+coreconfigitem('convert', 'svn.startrev',
+    default=0,
+)
 coreconfigitem('debug', 'dirstate.delaywrite',
     default=0,
 )
diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t
--- a/tests/test-lfconvert.t
+++ b/tests/test-lfconvert.t
@@ -233,9 +233,10 @@
   $ cd ..
 
 round-trip: converting back to a normal (non-largefiles) repo with
-"lfconvert --to-normal" should give the same as ../bigfile-repo
+"lfconvert --to-normal" should give the same as ../bigfile-repo.  The
+convert extension is disabled to show config items can be loaded without it.
   $ cd largefiles-repo
-  $ hg lfconvert --to-normal . ../normal-repo
+  $ hg --config extensions.convert=! lfconvert --to-normal . ../normal-repo
   initializing destination ../normal-repo
   0 additional largefiles cached
   scanning source...


More information about the Mercurial-devel mailing list