[PATCH] diff: support diffing explicit files in subrepos
Matt Harbison
mharbison72 at gmail.com
Fri Mar 22 02:52:24 UTC 2019
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1553218822 14400
# Thu Mar 21 21:40:22 2019 -0400
# Node ID 7d6f7425815d85ba1ba074d84aa7a002ae8b7097
# Parent 6fef387af1daec6515e67f3e857f025f914ddf9b
diff: support diffing explicit files in subrepos
Most other commands support implied recursion based on file names already.
diff --git a/mercurial/help/subrepos.txt b/mercurial/help/subrepos.txt
--- a/mercurial/help/subrepos.txt
+++ b/mercurial/help/subrepos.txt
@@ -105,8 +105,10 @@ Interaction with Mercurial Commands
Subversion subrepositories will print a warning and abort.
:diff: diff does not recurse in subrepos unless -S/--subrepos is
- specified. Changes are displayed as usual, on the subrepositories
- elements. Subversion subrepositories are currently silently ignored.
+ specified. However, if you specify the full path of a file or
+ directory in a subrepo, it will be diffed even without
+ -S/--subrepos being specified. Subversion subrepositories are
+ currently silently ignored.
:files: files does not recurse into subrepos unless -S/--subrepos is
specified. However, if you specify the full path of a file or
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -129,19 +129,19 @@ def diffordiffstat(ui, repo, diffopts, n
for chunk, label in chunks:
ui.write(chunk, label=label)
- if listsubrepos:
- for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
- tempnode2 = node2
- try:
- if node2 is not None:
- tempnode2 = ctx2.substate[subpath][1]
- except KeyError:
- # A subrepo that existed in node1 was deleted between node1 and
- # node2 (inclusive). Thus, ctx2's substate won't contain that
- # subpath. The best we can do is to ignore it.
- tempnode2 = None
- submatch = matchmod.subdirmatcher(subpath, match)
- subprefix = repo.wvfs.reljoin(prefix, subpath)
+ for subpath, sub in scmutil.itersubrepos(ctx1, ctx2):
+ tempnode2 = node2
+ try:
+ if node2 is not None:
+ tempnode2 = ctx2.substate[subpath][1]
+ except KeyError:
+ # A subrepo that existed in node1 was deleted between node1 and
+ # node2 (inclusive). Thus, ctx2's substate won't contain that
+ # subpath. The best we can do is to ignore it.
+ tempnode2 = None
+ submatch = matchmod.subdirmatcher(subpath, match)
+ subprefix = repo.wvfs.reljoin(prefix, subpath)
+ if listsubrepos or match.exact(subpath) or any(submatch.files()):
sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
stat=stat, fp=fp, prefix=subprefix)
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1875,6 +1875,19 @@ Test that '[paths]' is configured correc
@@ -0,0 +1,1 @@
+bar
+ $ hg diff -X '.hgsub*' --nodates s
+ diff -r 000000000000 s/a
+ --- /dev/null
+ +++ b/s/a
+ @@ -0,0 +1,1 @@
+ +a
+ $ hg diff -X '.hgsub*' --nodates s/a
+ diff -r 000000000000 s/a
+ --- /dev/null
+ +++ b/s/a
+ @@ -0,0 +1,1 @@
+ +a
+
$ cd ..
test for ssh exploit 2017-07-25
More information about the Mercurial-devel
mailing list