D4572: localrepo: document and test bug around opening shared repos

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Thu Sep 13 16:31:02 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As part of refactoring this code, I realized that we don't
  validate the requirements of a shared repository. This commit
  documents that next to the requirements validation code and adds a
  test demonstrating the buggy behavior.
  
  I'm not sure if I'll fix this. But it is definitely a bug that
  users could encounter, as LFS, narrow, and potentially other
  extensions dynamically add requirements on first use. One part
  of this I'm not sure about is how to handle loading the .hg/hgrc
  of the shared repo. We need to do that in order to load extensions.
  But we don't want that repo's hgrc to overwrite the current repo's.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

diff --git a/tests/test-share.t b/tests/test-share.t
--- a/tests/test-share.t
+++ b/tests/test-share.t
@@ -439,6 +439,29 @@
 
   $ rm -r thatdir
 
+Demonstrate buggy behavior around requirements validation
+See comment in localrepo.py:makelocalrepository() for more.
+
+  $ hg init sharenewrequires
+  $ hg share sharenewrequires shareoldrequires
+  updating working directory
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ cat >> sharenewrequires/.hg/requires << EOF
+  > missing-requirement
+  > EOF
+
+We cannot open the repo with the unknown requirement
+
+  $ hg -R sharenewrequires status
+  abort: repository requires features unknown to this Mercurial: missing-requirement!
+  (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
+  [255]
+
+BUG: we don't get the same error when opening the shared repo pointing to it
+
+  $ hg -R shareoldrequires status
+
 Explicitly kill daemons to let the test exit on Windows
 
   $ killdaemons.py
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -438,6 +438,19 @@
     # Then we validate that the known set is reasonable to use together.
     ensurerequirementscompatible(ui, requirements)
 
+    # TODO there are unhandled edge cases related to opening repositories with
+    # shared storage. If storage is shared, we should also test for requirements
+    # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
+    # that repo, as that repo may load extensions needed to open it. This is a
+    # bit complicated because we don't want the other hgrc to overwrite settings
+    # in this hgrc.
+    #
+    # This bug is somewhat mitigated by the fact that we copy the .hg/requires
+    # file when sharing repos. But if a requirement is added after the share is
+    # performed, thereby introducing a new requirement for the opener, we may
+    # will not see that and could encounter a run-time error interacting with
+    # that shared store since it has an unknown-to-us requirement.
+
     # At this point, we know we should be capable of opening the repository.
     # Now get on with doing that.
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list