Mercurial > hg-stable
changeset 701:80ed193efff7
On importing the result of 'hg export', parse while reading and drop headers.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On importing the result of 'hg export', parse while reading and drop headers.
manifest hash: 385cb4205bb6e4291a412d740400de44bd2e4014
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFC1otNW7P1GVgWeRoRAiSpAJ4jGhjyEnI2aqCM6pgC8KWSWRkDugCgkVMK
rd/YNziDK3TNRhI3yKNrLVw=
=w6ht
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 14 Jul 2005 16:57:01 +0100 |
parents | d01b93efecd6 |
children | a1099c50a622 |
files | mercurial/commands.py |
diffstat | 1 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Jul 14 16:23:13 2005 +0100 +++ b/mercurial/commands.py Thu Jul 14 16:57:01 2005 +0100 @@ -614,31 +614,32 @@ ui.status("applying %s\n" % patch) pf = os.path.join(d, patch) - text = "" - for l in file(pf): - if l.startswith("--- ") or l.startswith("diff -r"): + text = [] + user = None + hgpatch = False + for line in file(pf): + line = line.rstrip() + if line.startswith("--- ") or line.startswith("diff -r"): break - text += l - - # parse values that exist when importing the result of an hg export - hgpatch = user = snippet = None - ui.debug('text:\n') - for t in text.splitlines(): - ui.debug(t, '\n') - if t == '# HG changeset patch' or hgpatch: + elif hgpatch: + # parse values when importing the result of an hg export + if line.startswith("# User "): + user = line[7:] + ui.debug('User: %s\n' % user) + elif not line.startswith("# ") and line: + text.append(line) + hgpatch = False + elif line == '# HG changeset patch': hgpatch = True - if t.startswith("# User "): - user = t[7:] - ui.debug('User: %s\n' % user) - if not t.startswith("# ") and t.strip() and not snippet: - snippet = t - if snippet: - text = snippet + '\n' + text - ui.debug('text:\n%s\n' % text) + else: + text.append(line) # make sure text isn't empty if not text: text = "imported patch %s\n" % patch + else: + text = "%s\n" % '\n'.join(text) + ui.debug('text:\n%s\n' % text) f = os.popen("patch -p%d < %s" % (strip, pf)) files = []