##// END OF EJS Templates
On importing the result of 'hg export', parse while reading and drop headers....
Thomas Arendsen Hein -
r701:80ed193e default
parent child Browse files
Show More
@@ -614,31 +614,32 b' def import_(ui, repo, patch1, *patches, '
614 ui.status("applying %s\n" % patch)
614 ui.status("applying %s\n" % patch)
615 pf = os.path.join(d, patch)
615 pf = os.path.join(d, patch)
616
616
617 text = ""
617 text = []
618 for l in file(pf):
618 user = None
619 if l.startswith("--- ") or l.startswith("diff -r"):
619 hgpatch = False
620 for line in file(pf):
621 line = line.rstrip()
622 if line.startswith("--- ") or line.startswith("diff -r"):
620 break
623 break
621 text += l
624 elif hgpatch:
622
625 # parse values when importing the result of an hg export
623 # parse values that exist when importing the result of an hg export
626 if line.startswith("# User "):
624 hgpatch = user = snippet = None
627 user = line[7:]
625 ui.debug('text:\n')
628 ui.debug('User: %s\n' % user)
626 for t in text.splitlines():
629 elif not line.startswith("# ") and line:
627 ui.debug(t, '\n')
630 text.append(line)
628 if t == '# HG changeset patch' or hgpatch:
631 hgpatch = False
632 elif line == '# HG changeset patch':
629 hgpatch = True
633 hgpatch = True
630 if t.startswith("# User "):
634 else:
631 user = t[7:]
635 text.append(line)
632 ui.debug('User: %s\n' % user)
633 if not t.startswith("# ") and t.strip() and not snippet:
634 snippet = t
635 if snippet:
636 text = snippet + '\n' + text
637 ui.debug('text:\n%s\n' % text)
638
636
639 # make sure text isn't empty
637 # make sure text isn't empty
640 if not text:
638 if not text:
641 text = "imported patch %s\n" % patch
639 text = "imported patch %s\n" % patch
640 else:
641 text = "%s\n" % '\n'.join(text)
642 ui.debug('text:\n%s\n' % text)
642
643
643 f = os.popen("patch -p%d < %s" % (strip, pf))
644 f = os.popen("patch -p%d < %s" % (strip, pf))
644 files = []
645 files = []
General Comments 0
You need to be logged in to leave comments. Login now