[PATCH 2 of 2] subrepo: calculate _relpath for hgsubrepo based on self instead of parent

Matt Harbison matt_harbison at yahoo.com
Wed Apr 15 13:26:20 CDT 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1429112984 14400
#      Wed Apr 15 11:49:44 2015 -0400
# Node ID 5b69b0a606afbc71bc83cbba8e956f52585b8f38
# Parent  7f70e8f8239f813f5041210ff6395fae53e01971
subrepo: calculate _relpath for hgsubrepo based on self instead of parent

Prior to 105758d1b37b, the subrelpath() (now _relpath) for hgsubrepo was
calculated by removing the root path of the outermost repo from the root path of
the subrepo.  Since the root paths use platform specific separators, and the
relative path is printed by various commands, the output of these commands
require a glob (and check-code.py enforces this).

In an effort to be generic to all subrepos, 105758d1b37b started calculating
this path based on the parent repo, and then joining the subrepo path in .hgsub.
One of the tests in test-subrepo.t creates a subrepo inside a directory, so the
path being joined contained '/' instead of '\'.  This made the test fail with a
'~' status, because the glob is unnecessary[1].  Removing them made the test
work, but then check-code complains.  We can't just drop the check-code rule,
because sub-subrepos are still joined with '\'.  Presumably the other subrepo
types have this issue as well, but there likely isn't a test with git or svn
repos inside a subdirectory.

This simply restores the exact _relpath value (and output) for hgsubrepos prior
to 105758d1b37b.


[1] http://www.selenic.com/pipermail/mercurial-devel/2015-April/068720.html

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -959,6 +959,13 @@
         """
         return self._repo.wvfs
 
+    @propertycache
+    def _relpath(self):
+        """return path to this subrepository as seen from outermost repository
+        """
+        # Keep consistent dir separators by avoiding vfs.join(self._path)
+        return reporelpath(self._repo)
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         super(svnsubrepo, self).__init__(ctx, path)


More information about the Mercurial-devel mailing list