[PATCH] annotate: append newline after non newline-terminated file listings

Ion Savin comp_ at gmx.net
Sun Jan 8 16:27:07 CST 2012


# HG changeset patch
# User Ion Savin <comp_ at gmx.net>
# Date 1326061171 -7200
# Node ID afadfd2e74bf5325aa115710c728f425e6b9cd96
# Parent  f15c646bffc7187c357f3dcc12761513c1ed6609
annotate: append newline after non newline-terminated file listings

The last line of a non newline-terminated file would mix with the first 
line of
the next file in multiple-file listings before this patch.

Possible compatibility issue: no longer possible to tell from the annotate
output if the file is terminated by new line or not.

diff -r f15c646bffc7 -r afadfd2e74bf mercurial/commands.py
--- a/mercurial/commands.py     Thu Jan 05 07:26:22 2012 -0800
+++ b/mercurial/commands.py     Mon Jan 09 00:19:31 2012 +0200
@@ -299,6 +299,9 @@
              for p, l in zip(zip(*pieces), lines):
                  ui.write("%s: %s" % ("".join(p), l[1]))

+            if not lines[-1][1].endswith('\n'):
+                ui.write('\n')
+
  @command('archive',
      [('', 'no-decode', None, _('do not pass files through decoders')),
      ('p', 'prefix', '', _('directory prefix for files in archive'),
diff -r f15c646bffc7 -r afadfd2e74bf tests/test-annotate.t
--- a/tests/test-annotate.t     Thu Jan 05 07:26:22 2012 -0800
+++ b/tests/test-annotate.t     Mon Jan 09 00:19:31 2012 +0200
@@ -255,6 +255,15 @@
    abort: nosuchfile: no such file in rev e9e6b4fa872f
    [255]

+annotate file without '\n' on last line
+
+  $ printf "a\nb" > c
+  $ hg ci -A -m test -u nobody -d '1 0'
+  adding c
+  $ hg annotate c
+  [0-9]+: a (re)
+  [0-9]+: b (re)
+
  Test annotate with whitespace options

    $ cd ..


More information about the Mercurial-devel mailing list