Patchwork [stable] subrepo: correctly add newline for git subrepo diffs

login
register
mail settings
Submitter Mathias De Maré
Date Jan. 21, 2015, 8:51 p.m.
Message ID <ea27188a8b907acac56a.1421873466@mathias-Latitude-E6540>
Download mbox | patch
Permalink /patch/7532/
State Accepted
Commit de519517f597abd733961a8c549074eecb6c0ab3
Headers show

Comments

Mathias De Maré - Jan. 21, 2015, 8:51 p.m.
# HG changeset patch
# User Mathias De Maré <mathias.demare@gmail.com>
# Date 1421873247 -3600
#      Mit Jan 21 21:47:27 2015 +0100
# Branch stable
# Node ID ea27188a8b907acac56a71fbe006f6780319836e
# Parent  a43fdf33a6beb697945a3dbb7253f0436ea278a6
subrepo: correctly add newline for git subrepo diffs

Previously, git subrepo diffs did not have a newline at the end.
This caused multiple subrepo diffs to be joined on the same line.
Additionally, the command prompt after the diff still contained
a part of the diff.
Matt Mackall - Jan. 21, 2015, 10:50 p.m.
On Wed, 2015-01-21 at 21:51 +0100, Mathias De Maré wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.demare@gmail.com>
> # Date 1421873247 -3600
> #      Mit Jan 21 21:47:27 2015 +0100
> # Branch stable
> # Node ID ea27188a8b907acac56a71fbe006f6780319836e
> # Parent  a43fdf33a6beb697945a3dbb7253f0436ea278a6
> subrepo: correctly add newline for git subrepo diffs

Queued for stable, thanks.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1648,13 +1648,17 @@  class gitsubrepo(abstractsubrepo):
         if match.anypats():
             return #No support for include/exclude yet
 
+        output = ""
         if match.always():
-            ui.write(self._gitcommand(cmd))
+            output += self._gitcommand(cmd) + '\n'
         elif match.files():
             for f in match.files():
-                ui.write(self._gitcommand(cmd + [f]))
+                output += self._gitcommand(cmd + [f]) + '\n'
         elif match(gitprefix): #Subrepo is matched
-            ui.write(self._gitcommand(cmd))
+            output += self._gitcommand(cmd) + '\n'
+
+        if output.strip():
+            ui.write(output)
 
     @annotatesubrepoerror
     def revert(self, substate, *pats, **opts):
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -112,7 +112,7 @@  clone root, make local change
   @@ -1,2 +1,3 @@
    g
    gg
-  +ggg (no-eol)
+  +ggg
   $ hg commit --subrepos -m ggg
   committing subrepository s
   $ hg debugsub
@@ -695,7 +695,7 @@  check differences made by most recent ch
   +woopwoop
   +
   +foo
-  +bar (no-eol)
+  +bar
 
   $ hg commit --subrepos -m "Added foobar"
   committing subrepository s
@@ -717,7 +717,7 @@  check differences made by most recent ch
   +woopwoop
   +
   +foo
-  +bar (no-eol)
+  +bar
 
 check output when only diffing the subrepository
   $ hg diff -c . --subrepos s
@@ -730,7 +730,7 @@  check output when only diffing the subre
   +woopwoop
   +
   +foo
-  +bar (no-eol)
+  +bar
 
 check output when diffing something else
   $ hg diff -c . --subrepos .hgsubstate --nodates
@@ -760,7 +760,7 @@  add new changes, including whitespace
   --- /dev/null
   +++ b/s/barfoo
   @@ -0,0 +1 @@
-  +foo (no-eol)
+  +foo
   $ hg diff --subrepos s/foobar
   diff --git a/s/foobar b/s/foobar
   index 8a5a5e2..bd5812a 100644
@@ -771,7 +771,7 @@  add new changes, including whitespace
   +woop    woop
    
    foo
-   bar (no-eol)
+   bar
 
 execute a diffstat
 the output contains a regex, because git 1.7.10 and 1.7.11
@@ -779,7 +779,7 @@  the output contains a regex, because git
   $ hg diff --subrepos --stat
   \s*barfoo |\s*1 + (re)
   \s*foobar |\s*2 +- (re)
-   2 files changed, 2 insertions\(\+\), 1 deletions?\(-\) \(no-eol\) (re)
+   2 files changed, 2 insertions\(\+\), 1 deletions?\(-\) (re)
 
 ensure adding include/exclude ignores the subrepo
   $ hg diff --subrepos -I s/foobar