obslog: only indent the first chunk and chunks just after newlines (issue6175) stable
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 30 Aug 2019 11:31:19 +0700
branchstable
changeset 4823 c16fed4908d8
parent 4822 e50596ff2ddb
child 4824 f9d436b64b3f
obslog: only indent the first chunk and chunks just after newlines (issue6175)
CHANGELOG
hgext3rd/evolve/obshistory.py
tests/test-evolve-obshistory-amend.t
tests/test-evolve-phase-divergence.t
--- a/CHANGELOG	Fri Aug 30 11:28:02 2019 +0700
+++ b/CHANGELOG	Fri Aug 30 11:31:19 2019 +0700
@@ -1,6 +1,12 @@
 Changelog
 =========
 
+9.1.1 - in progress
+-------------------
+
+  * obslog: correct spacing of patch output with word-diff=yes (issue6175)
+
+
 9.1.0 -- 2019-07-29
 -------------------
 
--- a/hgext3rd/evolve/obshistory.py	Fri Aug 30 11:28:02 2019 +0700
+++ b/hgext3rd/evolve/obshistory.py	Fri Aug 30 11:31:19 2019 +0700
@@ -604,13 +604,17 @@
             diffopts = patch.diffallopts(repo.ui, {})
             matchfn = scmutil.matchall(repo)
             firstline = True
+            linestart = True
             for chunk, label in patch.diffui(repo, node, succ, matchfn,
                                              opts=diffopts):
                 if firstline:
                     fm.plain('\n')
                     firstline = False
-                if chunk and chunk != '\n':
+                if linestart:
                     fm.plain('    ')
+                    linestart = False
+                if chunk == '\n':
+                    linestart = True
                 fm.write('patch', '%s', chunk, label=label)
         else:
             nopatch = "    (No patch available, %s)" % _patchavailable[1]
@@ -740,13 +744,17 @@
             diffopts = patch.diffallopts(repo.ui, {})
             matchfn = scmutil.matchall(repo)
             firstline = True
+            linestart = True
             for chunk, label in patch.diffui(repo, node, succ, matchfn,
                                              opts=diffopts):
                 if firstline:
                     fm.plain('\n')
                     firstline = False
-                if chunk and chunk != '\n':
+                if linestart:
                     fm.plain('    ')
+                    linestart = False
+                if chunk == '\n':
+                    linestart = True
                 fm.write('patch', '%s', chunk, label=label)
         else:
             nopatch = "    (No patch available, %s)" % _patchavailable[1]
--- a/tests/test-evolve-obshistory-amend.t	Fri Aug 30 11:28:02 2019 +0700
+++ b/tests/test-evolve-obshistory-amend.t	Fri Aug 30 11:31:19 2019 +0700
@@ -109,7 +109,7 @@
       @@ -1,1 +1,2 @@
        A0
       +42
-  
+      
 
   $ hg obslog 4ae3a4151de9 --graph -T'{label("log.summary", shortdescription)} {if(markers, join(markers % "at {date|hgdate} by {user|person} ", " also "))}'
   @  A1
--- a/tests/test-evolve-phase-divergence.t	Fri Aug 30 11:28:02 2019 +0700
+++ b/tests/test-evolve-phase-divergence.t	Fri Aug 30 11:31:19 2019 +0700
@@ -1598,8 +1598,8 @@
           a
           b
           c
-         -    D
-         +    d
+         -D
+         +d
           e
           f
           g
@@ -1610,12 +1610,12 @@
           1
           2
           3
-         -    four
-         +    4
+         -four
+         +4
           5
           6
-         -    7
-         +    seven
+         -7
+         +seven
           8
           nine
          diff -r 3074c7249d20 -r 599454370881 romans
@@ -1623,8 +1623,8 @@
          +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
          @@ -1,5 +1,5 @@
           I
-         -    II
-         +    ii
+         -II
+         +ii
           III
           IV
           V
@@ -1786,8 +1786,8 @@
           a
           b
           c
-         -    D
-         +    d
+         -D
+         +d
           e
           f
           g
@@ -1798,12 +1798,12 @@
           1
           2
           3
-         -    four
-         +    4
+         -four
+         +4
           5
           6
-         -    7
-         +    seven
+         -7
+         +seven
           8
           nine
          diff -r 3074c7249d20 -r 599454370881 romans
@@ -1811,8 +1811,8 @@
          +++ b/romans	Thu Jan 01 00:00:00 1970 +0000
          @@ -1,5 +1,5 @@
           I
-         -    II
-         +    ii
+         -II
+         +ii
           III
           IV
           V