[PATCH] subrepo: correctly handle git subdirectory status change

mathias.demare at gmail.com mathias.demare at gmail.com
Wed May 6 10:34:05 CDT 2015


# HG changeset patch
# User Mathias De Maré <mathias.demare at gmail.com>
# Date 1430925338 -7200
#      Wed May 06 17:15:38 2015 +0200
# Node ID 04a7df0e607eac3e46f0fb580093557a82818432
# Parent  c5d4f9cc8da7bb2068457e96e4f74ff694514ced
subrepo: correctly handle git subdirectory status change

'git diff-index' by default does not recurse into subdirectories
when changes are found. As a result, the directory is shown as changed,
rather than the files in this directory.
Adding '-r' results in recursing until the blobs themselves are checked.

diff -r c5d4f9cc8da7 -r 04a7df0e607e mercurial/subrepo.py
--- a/mercurial/subrepo.py	Tue May 05 12:33:26 2015 -0500
+++ b/mercurial/subrepo.py	Wed May 06 17:15:38 2015 +0200
@@ -1711,7 +1711,7 @@
         modified, added, removed = [], [], []
         self._gitupdatestat()
         if rev2:
-            command = ['diff-tree', rev1, rev2]
+            command = ['diff-tree', '-r', rev1, rev2]
         else:
             command = ['diff-index', rev1]
         out = self._gitcommand(command)
diff -r c5d4f9cc8da7 -r 04a7df0e607e tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t	Tue May 05 12:33:26 2015 -0500
+++ b/tests/test-subrepo-git.t	Wed May 06 17:15:38 2015 +0200
@@ -1105,5 +1105,21 @@
   ? s/c.c
   ? s/cpp.cpp
   ? s/foobar.orig
+  $ hg revert --all -q
+
+make sure we show changed files, rather than changed subtrees
+  $ mkdir s/foo
+  $ touch s/foo/bwuh
+  $ hg add s/foo/bwuh
+  $ hg commit -S -m "add bwuh"
+  committing subrepository s
+  $ hg status -S --change .
+  M .hgsubstate
+  A s/foo/bwuh
+  ? s/barfoo
+  ? s/c.c
+  ? s/cpp.cpp
+  ? s/foobar.orig
+  ? s/snake.python.orig
 
   $ cd ..


More information about the Mercurial-devel mailing list