hgext3rd/evolve/obshistory.py
changeset 4827 4c6dd20e8cc2
parent 4814 48b30ff742cb
parent 4823 c16fed4908d8
child 4894 f9743b13de6d
child 4915 5113b38cb677
--- a/hgext3rd/evolve/obshistory.py	Thu Jul 25 18:37:16 2019 +0800
+++ b/hgext3rd/evolve/obshistory.py	Tue Sep 03 12:48:47 2019 +0200
@@ -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(b'\n')
                     firstline = False
-                if chunk and chunk != b'\n':
+                if linestart:
                     fm.plain(b'    ')
+                    linestart = False
+                if chunk == b'\n':
+                    linestart = True
                 fm.write(b'patch', b'%s', chunk, label=label)
         else:
             nopatch = b"    (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(b'\n')
                     firstline = False
-                if chunk and chunk != b'\n':
+                if linestart:
                     fm.plain(b'    ')
+                    linestart = False
+                if chunk == b'\n':
+                    linestart = True
                 fm.write(b'patch', b'%s', chunk, label=label)
         else:
             nopatch = b"    (No patch available, %s)" % _patchavailable[1]