D5895: diff: make `hg diff --root=subrepo` work
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Feb 8 03:30:47 EST 2019
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
The root prefix is currently stripped before adding the subrepo
prefix. It seems to me that if you run `hg diff --root=subrepo` and a
subrepo/ path is visited (say "subrepo/foo"), then the path generated
for the diff would initially be just "foo" and we then fail (if the
developer warning is active) to strip the "subrepo/" from the path. It
seems like we should first add the prefix in order to produce a path
that's relative to the top-level repo, and then we can remove the root
prefix from that. There are no tests for this, it seems, and I don't
care enough to add one.
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
@@ -66,6 +66,8 @@
relroot = ''
copysourcematch = None
+ def compose(f, g):
+ return lambda x: f(g(x))
return posixpath.join(prefix, f)
if relroot != '':
@@ -84,11 +86,12 @@
checkroot = (repo.ui.configbool('devel', 'all-warnings') or
- def pathfn(f):
+ def relrootpathfn(f):
if checkroot and not f.startswith(relroot):
"file %s doesn't start with relroot %s" % (f, relroot))
- return posixpath.join(prefix, f[len(relroot):])
+ return f[len(relroot):]
+ pathfn = compose(relrootpathfn, pathfn)
diffopts = diffopts.copy(context=0, noprefix=False)
To: martinvonz, #hg-reviewers
More information about the Mercurial-devel