[PATCH] patch: extract: handle non-tabulator Subject: line continuation

Steffen Daode Nurpmeso sdaoden at googlemail.com
Wed Aug 31 08:15:59 CDT 2011


Heya Mercurial,

i recently had problems with 'hg log' output which showed
"truncated" commit message intros.
I could track down my problem to extract() in mercurial/patch.c,
and it can be solved with the simple change below.

--Steffen
Ciao, sdaoden(*)(gmail.com)
ASCII ribbon campaign           ( ) More nuclear fission plants
  against HTML e-mail            X    can serve more coloured
    and proprietary attachments / \     and sounding animations
-- >8 --
# HG changeset patch
# User Steffen Daode Nurpmeso <sdaoden at gmail.com>
# Date 1314795502 -7200
# Node ID 94a08f2e7825cacf7b4d97acb7916d3326097aa8
# Parent  cc16323e748da5f3583df18d23f24988546714a7
patch: extract: handle non-tabulator Subject: continuation lines

The line content of continued Subject: lines was yet joined via
str.replace('\n\t', ' '), which does not handle continuation via
spaces.  So use a re.sub('\n\s+') regular expression instead to
handle all allowed forms of mail header line continuation.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -188,7 +188,7 @@
                 pend = subject.find(']')
                 if pend >= 0:
                     subject = subject[pend + 1:].lstrip()
-            subject = subject.replace('\n\t', ' ')
+            subject = re.sub(r'\n\s+', ' ', subject)
             ui.debug('Subject: %s\n' % subject)
         if user:
             ui.debug('From: %s\n' % user)


More information about the Mercurial-devel mailing list