Patchwork [3,of,4] config: don't set source when no source is specified - don't overwrite with ''

login
register
mail settings
Submitter Mads Kiilerich
Date March 19, 2014, 1:45 a.m.
Message ID <aecee5b4ae61ae98a138.1395193525@localhost.localdomain>
Download mbox | patch
Permalink /patch/3985/
State Accepted
Commit d19c9bdbbf35541fd50787d4b3f9081f3527bb1d
Headers show

Comments

Mads Kiilerich - March 19, 2014, 1:45 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1395193514 -3600
#      Wed Mar 19 02:45:14 2014 +0100
# Node ID aecee5b4ae61ae98a138583c63ce03a9e82084f0
# Parent  b9673d596335044e9cb7b1814c895e8a83bc10d4
config: don't set source when no source is specified - don't overwrite with ''

This prevents ui.fixconfig from overwriting the source of paths and it will
thus show up in showconfig --debug.

Patch

diff --git a/mercurial/config.py b/mercurial/config.py
--- a/mercurial/config.py
+++ b/mercurial/config.py
@@ -93,7 +93,8 @@  class config(object):
         if section not in self:
             self._data[section] = sortdict()
         self._data[section][item] = value
-        self._source[(section, item)] = source
+        if source:
+            self._source[(section, item)] = source
 
     def restore(self, data):
         """restore data returned by self.backup"""
diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -201,3 +201,14 @@  plain mode with exceptions
   --verbose: ui.verbose=False
   --debug: ui.debug=True
   --quiet: ui.quiet=False
+
+source of paths is not mangled
+
+  $ cat >> $HGRCPATH <<EOF
+  > [paths]
+  > foo = bar
+  > EOF
+  $ hg showconfig --debug paths
+  plain: True
+  read config from: $TESTTMP/hgrc
+  $TESTTMP/hgrc:17: paths.foo=$TESTTMP/bar