Patchwork [Bug,6394] New: Hgweb/scmutil do not handle subrepos that are symlinked on server

login
register
mail settings
Submitter mercurial-bugs@mercurial-scm.org
Date Aug. 9, 2020, 5:14 a.m.
Message ID <bug-6394-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/47015/
State Not Applicable
Headers show

Comments

mercurial-bugs@mercurial-scm.org - Aug. 9, 2020, 5:14 a.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=6394

            Bug ID: 6394
           Summary: Hgweb/scmutil do not handle subrepos that are
                    symlinked on server
           Product: Mercurial
           Version: unspecified
          Hardware: PC
                OS: Mac OS
            Status: UNCONFIRMED
          Severity: feature
          Priority: wish
         Component: hgweb
          Assignee: bugzilla@mercurial-scm.org
          Reporter: josh.davidson@lmco.com
                CC: mercurial-devel@mercurial-scm.org
    Python Version: ---

Created attachment 2085
  --> https://bz.mercurial-scm.org/attachment.cgi?id=2085&action=edit
Example hgweb before path is applied

Quoting from: https://www.mercurial-scm.org/wiki/Subrepository
Section 3.2 Info: "On hgweb servers, it will be useful to use symlinks or
duplicate path entries to allow shared libraries to appear in multiple places."

The problem is if a subrepo is shared amongst multiple multiple other
repositories, the most logical way (as suggested by Mercurial's own
documentation) is to have the subrepo symlinked in each container repo on the
server to support trivial paths in .hgsub files.  Read section 3 in above link
for why that is important.

However, walkrepos in scmutil does not pass "followsym" into os.walk, so
symbolic links are not recursed.  Consider a layout on the server that
resembles:

* /repo/pakcages/rpm (contains all mercurial repos)
* /repo/packages/rhel7_rpms (contains symbolic links to repos in
/repo/pakcages/rpm where each symlink is listed in hgsub as
<package>=<package>)
* /repo/packages/rhel8_rpms (contains symbolic links to repos in
/repo/pakcages/rpm where each symlink is listed in hgsub as
<package>=<package>)

With this layout, hgweb will not expose the repos under rhel7_rpms and
rhel8_rpms, so if one were to clone those containers, it would fail since the
subrepos would be inaccessible.

The fix for this is:
             yield root  # found a repository



See the attached screenshot which shows side-by-side how rhel7_rpms looks from
a browser before and after the patch

Patch

diff -r 15d35f2ba474 mercurial/scmutil.py
--- a/mercurial/scmutil.py      Tue Jul 21 22:13:54 2020 +0200
+++ b/mercurial/scmutil.py      Sat Aug 08 22:54:50 2020 -0600
@@ -397,7 +397,7 @@ 
     if (seen_dirs is None) and followsym:
         seen_dirs = []
         adddir(seen_dirs, path)
-    for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
+    for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler,
followlinks=followsym):
         dirs.sort()
         if b'.hg' in dirs: