[Updated] [+- ] D8673: config: add a .hg/nonsharedrc which won't be shared in share-safe mode

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Aug 10 15:31:20 UTC 2020


pulkit updated this revision to Diff 22385.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8673?vs=22330&id=22385

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8673/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8673

AFFECTED FILES
  mercurial/commands.py
  mercurial/localrepo.py
  tests/test-completion.t
  tests/test-share-safe.t

CHANGE DETAILS

diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -199,6 +199,25 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     added c
   
+
+Testing that nonsharedrc is loaded for source and not shared
+
+  $ cd ../source
+  $ touch .hg/nonsharedrc
+  $ echo "[ui]" >> .hg/nonsharedrc
+  $ echo "traceback=true" >> .hg/nonsharedrc
+
+  $ hg showconfig ui.traceback
+  true
+
+  $ HGEDITOR=cat hg config --non-shared
+  [ui]
+  traceback=true
+
+  $ cd ../shared1
+  $ hg showconfig ui.traceback
+  [1]
+
 Unsharing works
 
   $ hg unshare
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -258,7 +258,7 @@
   cat: output, rev, decode, include, exclude, template
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, stream, ssh, remotecmd, insecure
   commit: addremove, close-branch, amend, secret, edit, force-close-branch, interactive, include, exclude, message, logfile, date, user, subrepos
-  config: untrusted, edit, local, shared, global, template
+  config: untrusted, edit, local, shared, non-shared, global, template
   continue: dry-run
   copy: forget, after, at-rev, force, include, exclude, dry-run
   debugancestor: 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -707,18 +707,28 @@
     if not rcutil.use_repo_hgrc():
         return False
 
+    ret = False
     # first load config from shared source if we has to
     if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
         try:
             ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
+            ret = True
         except IOError:
             pass
 
     try:
         ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
-        return True
+        ret = True
     except IOError:
-        return False
+        pass
+
+    try:
+        ui.readconfig(hgvfs.join(b'nonsharedrc'), root=wdirvfs.base)
+        ret = True
+    except IOError:
+        pass
+
+    return ret
 
 
 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2144,6 +2144,7 @@
         (b'e', b'edit', None, _(b'edit user config')),
         (b'l', b'local', None, _(b'edit repository config')),
         (b'', b'shared', None, _(b'edit share source config (EXPERIMENTAL)')),
+        (b'', b'non-shared', None, _(b'edit non shared config (EXPERIMENTAL)')),
         (b'g', b'global', None, _(b'edit global config')),
     ]
     + formatteropts,
@@ -2191,7 +2192,7 @@
     """
 
     opts = pycompat.byteskwargs(opts)
-    editopts = (b'edit', b'local', b'global', b'shared')
+    editopts = (b'edit', b'local', b'global', b'shared', b'non_shared')
     if any(opts.get(o) for o in editopts):
         cmdutil.check_at_most_one_arg(opts, *editopts[1:])
         if opts.get(b'local'):
@@ -2210,6 +2211,8 @@
                         _(b"this does not support editing share source config")
                     )
             paths = [vfsmod.vfs(repo.sharedpath).join(b'hgrc')]
+        elif opts.get(b'non_shared'):
+            paths = [repo.vfs.join(b'nonsharedrc')]
         else:
             paths = rcutil.userrcpath()
 



To: pulkit, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200810/a6ac3a38/attachment-0002.html>


More information about the Mercurial-patches mailing list