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

login
register
mail settings
Submitter phabricator
Date July 1, 2020, 10:02 a.m.
Message ID <differential-rev-PHID-DREV-4i2qknqq5fidxqwmt5na-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46603/
State New
Headers show

Comments

phabricator - July 1, 2020, 10:02 a.m.
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Previous patches add a safe mode for sharing repositories which involve sharing
  of source requirements and config files.
  
  In certain situations we might need to add a config to source repository which
  we does not want to share. For this, we add a `.hg/nonsharedrc` which won't be
  shared.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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
@@ -125,4 +125,18 @@ 
   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
+
+  $ cd ../shared1
+  $ hg showconfig ui.traceback
+  [1]
   $ hg unshare
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -715,18 +715,29 @@ 
     if not rcutil.use_repo_hgrc():
         return False
 
+    ret = False
     # first load config from shared source if we has to
     if 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
+
+    if sharedvfs is None:
+        try:
+            ui.readconfig(hgvfs.join(b'nonsharedrc'), root=wdirvfs.base)
+            ret = True
+        except IOError:
+            pass
+
+    return ret
 
 
 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):