[PATCH] dispatch: use --section.setting=value instead of --config=section.setting=value

Mads Kiilerich mads at kiilerich.com
Fri May 2 11:24:07 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1398943909 -7200
#      Thu May 01 13:31:49 2014 +0200
# Branch stable
# Node ID a9669ccfde3af288ad4b186e4f2ce8672cad4412
# Parent  e88b1ad2871cd900262cde1633b561996d28388d
dispatch: use --section.setting=value instead of --config=section.setting=value

Convenient shortcut, looks more elegant than --config and is a fine supplement
to normal command line options.

--config was apparently not documented anywhere.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -419,8 +419,8 @@ class changectx(basectx):
                 self._repo.ui.status(
                     (_("note: using %s as ancestor of %s and %s\n") %
                      (short(anc), short(self._node), short(n2))) +
-                    ''.join(_("      alternatively, use --config "
-                              "merge.preferancestor=%s\n") %
+                    ''.join(_("      alternatively, use "
+                              "--merge.preferancestor=%s\n") %
                             short(n) for n in sorted(cahs) if n != anc))
         return changectx(self._repo, anc)
 
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -98,7 +98,8 @@ def _runcatch(req):
 
             # read --config before doing anything else
             # (e.g. to change trust settings for reading .hg/hgrc)
-            cfgs = _parseconfig(req.ui, _earlygetopt(['--config'], req.args))
+            cfgs = _parseconfig(req.ui, _earlygetopt(['--config', '--.'],
+                                req.args))
 
             if req.repo:
                 # copy configs that were passed on the cmdline (--config) to
@@ -387,7 +388,8 @@ class cmdalias(object):
         self.cmdname = cmd = args.pop(0)
         args = map(util.expandpath, args)
 
-        for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"):
+        for invalidarg in ("--cwd", "-R", "--repository", "--repo",
+                           "--config", "--."):
             if _earlygetopt([invalidarg], args):
                 def fn(ui, *args):
                     ui.warn(_("error in definition for alias '%s': %s may only "
@@ -551,6 +553,10 @@ def _earlygetopt(aliases, args):
     >>> args = ['x', '-Rbar', 'y']
     >>> _earlygetopt(['-R'], args), args
     (['bar'], ['x', 'y'])
+
+    >>> args = ['x--y.z', '--a.b=c', '-Rbar', '--a.b.c', '--d.e=f', 'y']
+    >>> _earlygetopt(['--.'], args), args
+    (['a.b=c', 'a.b.c=--d.e=f'], ['x--y.z', '-Rbar', 'y'])
     """
     try:
         argcount = args.index("--")
@@ -564,7 +570,8 @@ def _earlygetopt(aliases, args):
         equals = arg.find('=')
         if equals > -1:
             arg = arg[:equals]
-        if arg in aliases:
+        dashdashdot = re.match(r'--.*\.', arg) and '--.' in aliases
+        if arg in aliases or dashdashdot:
             del args[pos]
             if equals > -1:
                 v = fullarg[equals + 1:]
@@ -575,6 +582,8 @@ def _earlygetopt(aliases, args):
                     break
                 v = args.pop(pos)
                 argcount -= 2
+            if dashdashdot:
+                v = arg[2:] + '=' + v
             values.append(v)
         elif arg[:2] in shortopts:
             # short option can have no following space, e.g. hg log -Rfoo
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -12,6 +12,9 @@ by ``name = value`` entries::
 The above entries will be referred to as ``ui.username`` and
 ``ui.verbose``, respectively. See the Syntax section below.
 
+Configuration values can be specified on the command line as
+``--ui.username=Name`` or ``--ui.verbose True``.
+
 Files
 =====
 
@@ -1288,7 +1291,7 @@ For a quick setup in a trusted environme
 you want it to accept pushes from anybody, you can use the following
 command line::
 
-    $ hg --config web.allow_push=* --config web.push_ssl=False serve
+    $ hg --web.allow_push=* --web.push_ssl=False serve
 
 Note that this will allow anybody to push anything to the server and
 that this should not be used for public servers.
diff --git a/tests/test-globalopts.t b/tests/test-globalopts.t
--- a/tests/test-globalopts.t
+++ b/tests/test-globalopts.t
@@ -213,6 +213,8 @@ Testing --config:
 
   $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
   quuxfoo
+  $ hg --cwd c --paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
+  quuxfoo
   $ hg --cwd c --config '' tip -q
   abort: malformed --config option: '' (use --config section.name=value)
   [255]
diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
--- a/tests/test-merge-criss-cross.t
+++ b/tests/test-merge-criss-cross.t
@@ -25,7 +25,7 @@ Criss cross merging
 
   $ hg up -r3
   note: using 0f6b37dbe527 as ancestor of adfe50279922 and cf89f02107e5
-        alternatively, use --config merge.preferancestor=40663881a6dd
+        alternatively, use --merge.preferancestor=40663881a6dd
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo '6 second change' > f2
   $ hg ci -m '6 second change f2'
@@ -76,7 +76,7 @@ Criss cross merging
 
   $ hg merge -v --debug --tool internal:dump 5
   note: using 0f6b37dbe527 as ancestor of 3b08d01b0ab5 and adfe50279922
-        alternatively, use --config merge.preferancestor=40663881a6dd
+        alternatively, use --merge.preferancestor=40663881a6dd
     searching for copies back to rev 3
   resolving manifests
    branchmerge: True, force: False, partial: False
@@ -114,9 +114,9 @@ Criss cross merging
   2 first change
 
   $ hg up -qC .
-  $ hg merge -v --tool internal:dump 5 --config merge.preferancestor="null 40663881 3b08d"
+  $ hg merge -v --tool internal:dump 5 --merge.preferancestor="null 40663881 3b08d"
   note: using 40663881a6dd as ancestor of 3b08d01b0ab5 and adfe50279922
-        alternatively, use --config merge.preferancestor=0f6b37dbe527
+        alternatively, use --merge.preferancestor=0f6b37dbe527
   resolving manifests
   merging f1
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -127,7 +127,7 @@ Redo merge with merge.preferancestor="*"
 
   $ rm f*
   $ hg up -qC .
-  $ hg merge -v --debug --tool internal:dump 5 --config merge.preferancestor="*"
+  $ hg merge -v --debug --tool internal:dump 5 --merge.preferancestor="*"
   note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   
   calculating bids for ancestor 0f6b37dbe527
@@ -170,9 +170,9 @@ The other way around:
 
   $ hg up -C -r5
   note: using 0f6b37dbe527 as ancestor of 3b08d01b0ab5 and adfe50279922
-        alternatively, use --config merge.preferancestor=40663881a6dd
+        alternatively, use --merge.preferancestor=40663881a6dd
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg merge -v --debug --config merge.preferancestor="*"
+  $ hg merge -v --debug --merge.preferancestor="*"
   note: merging adfe50279922+ and 3b08d01b0ab5 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   
   calculating bids for ancestor 0f6b37dbe527
@@ -213,13 +213,13 @@ The other way around:
 Verify how the output looks and and how verbose it is:
 
   $ hg up -qC
-  $ hg merge --config merge.preferancestor="*"
+  $ hg merge --merge.preferancestor="*"
   note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
   $ hg up -qC
-  $ hg merge -v --config merge.preferancestor="*"
+  $ hg merge -v --merge.preferancestor="*"
   note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   
   calculating bids for ancestor 0f6b37dbe527
@@ -238,7 +238,7 @@ Verify how the output looks and and how 
   (branch merge, don't forget to commit)
 
   $ hg up -qC
-  $ hg merge -v --debug --config merge.preferancestor="*"
+  $ hg merge -v --debug --merge.preferancestor="*"
   note: merging 3b08d01b0ab5+ and adfe50279922 using bids from ancestors 0f6b37dbe527 and 40663881a6dd
   
   calculating bids for ancestor 0f6b37dbe527
@@ -294,7 +294,7 @@ http://stackoverflow.com/questions/93500
 
   $ hg merge
   note: using 70008a2163f6 as ancestor of 0d355fdef312 and 4b8b546a3eef
-        alternatively, use --config merge.preferancestor=b211bbc6eb3c
+        alternatively, use --merge.preferancestor=b211bbc6eb3c
   merging x
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -306,9 +306,9 @@ http://stackoverflow.com/questions/93500
 
   $ hg up -qC .
 
-  $ hg merge --config merge.preferancestor=b211bbc6eb3c
+  $ hg merge --merge.preferancestor=b211bbc6eb3c
   note: using b211bbc6eb3c as ancestor of 0d355fdef312 and 4b8b546a3eef
-        alternatively, use --config merge.preferancestor=70008a2163f6
+        alternatively, use --merge.preferancestor=70008a2163f6
   merging x
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
@@ -320,7 +320,7 @@ http://stackoverflow.com/questions/93500
 
   $ hg up -qC .
 
-  $ hg merge -v --config merge.preferancestor="*"
+  $ hg merge -v --merge.preferancestor="*"
   note: merging 0d355fdef312+ and 4b8b546a3eef using bids from ancestors 70008a2163f6 and b211bbc6eb3c
   
   calculating bids for ancestor 70008a2163f6


More information about the Mercurial-devel mailing list