Mercurial > hg-stable
changeset 12645:d7452292f9d3
import: don't strip '#' lines from patch descriptions (issue 2417)
Previously no '# ' lines came through the parser.
Now only the first '# ' lines are processed, from '# HG changeset patch' and to
the first line not starting with '# '.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 08 Oct 2010 23:39:44 -0500 |
parents | 0490d2223882 |
children | 624859bf4314 |
files | mercurial/patch.py tests/test-patch.t |
diffstat | 2 files changed, 51 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Fri Oct 08 22:36:11 2010 -0500 +++ b/mercurial/patch.py Fri Oct 08 23:39:44 2010 -0500 @@ -224,6 +224,7 @@ m = diffre.search(payload) if m: hgpatch = False + hgpatchheader = False ignoretext = False ui.debug('found patch at byte %d\n' % m.start(0)) @@ -232,12 +233,12 @@ for line in payload[:m.start(0)].splitlines(): if line.startswith('# HG changeset patch'): ui.debug('patch generated by hg export\n') - hgpatch = True + hgpatchheader = True # drop earlier commit message content cfp.seek(0) cfp.truncate() subject = None - elif hgpatch: + elif hgpatchheader: if line.startswith('# User '): user = line[7:] ui.debug('From: %s\n' % user) @@ -249,9 +250,12 @@ nodeid = line[10:] elif line.startswith("# Parent "): parents.append(line[10:]) + elif not line.startswith("# "): + hgpatchheader = False + hgpatch = True elif line == '---' and gitsendmail: ignoretext = True - if not line.startswith('# ') and not ignoretext: + if not hgpatchheader and not ignoretext: cfp.write(line) cfp.write('\n') message = cfp.getvalue()
--- a/tests/test-patch.t Fri Oct 08 22:36:11 2010 -0500 +++ b/tests/test-patch.t Fri Oct 08 23:39:44 2010 -0500 @@ -39,3 +39,47 @@ applying ../a.diff Using custom patch + +Issue2417: hg import with # comments in description + +Prepare source repo and patch: + + $ rm $HGRCPATH + $ hg init c + $ cd c + $ echo 0 > a + $ hg ci -A -m 0 a -d '0 0' + $ echo 1 >> a + $ cat << eof > log + > 1 + > # comment for 1 + > eof + $ hg ci -l log -d '0 0' + $ hg export -o p 1 + $ cd .. + +Clone and apply patch: + + $ hg clone -r 0 c d + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + updating to branch default + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cd d + $ hg import ../c/p + applying ../c/p + $ hg log -v -r 1 + changeset: 1:89bf2f6d8088 + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + files: a + description: + 1 + # comment for 1 + + + $ cd ..