Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/commands.py @ 607:94744f6fe0e7
[PATCH] Parse and use header data from an hg export'ed changeset
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[PATCH] Parse and use header data from an hg export'ed changeset
From: Andrew Thompson <andrewkt@aktzero.com>
This should make it easier to import changesets that are hg export'ed
from other Mercurial users:
Add a routine to catch the user from an hg export'ed changeset.
Add user to commit call.
Add trap for changelog snippet, which is promoted to the beginning of
the commit text.
manifest hash: cf5b068f4cec411ff8b9fa3db324ab44ed012778
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCyMXAywK+sNU5EO8RAqk5AJ9rC4ZwzcpDfxrNqIBrrTj6eL2mzQCgmZ5O
wSkis2J9Xz2wOZAhjVcxIgQ=
=32D+
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sun, 03 Jul 2005 21:14:40 -0800 |
parents | 8e82fd763be2 |
children | 2acf1f5df2e6 |
comparison
equal
deleted
inserted
replaced
606:ea4526f9b1a5 | 607:94744f6fe0e7 |
---|---|
584 text = "" | 584 text = "" |
585 for l in file(pf): | 585 for l in file(pf): |
586 if l[:4] == "--- ": break | 586 if l[:4] == "--- ": break |
587 text += l | 587 text += l |
588 | 588 |
589 # parse values that exist when importing the result of an hg export | |
590 hgpatch = user = snippet = None | |
591 ui.debug('text:\n') | |
592 for t in text.splitlines(): | |
593 ui.debug(t,'\n') | |
594 if t == '# HG changeset patch' or hgpatch == True: | |
595 hgpatch = True | |
596 if t[:7] == "# User ": | |
597 user = t[7:] | |
598 ui.debug('User: %s\n' % user) | |
599 if t[:2] <> "# " and t.strip() and not snippet: snippet = t | |
600 if snippet: text = snippet + '\n' + text | |
601 ui.debug('text:\n%s\n' % text) | |
602 | |
589 # make sure text isn't empty | 603 # make sure text isn't empty |
590 if not text: text = "imported patch %s\n" % patch | 604 if not text: text = "imported patch %s\n" % patch |
591 | 605 |
592 f = os.popen("patch -p%d < %s" % (strip, pf)) | 606 f = os.popen("patch -p%d < %s" % (strip, pf)) |
593 files = [] | 607 files = [] |
603 sys.stderr.write("patch failed") | 617 sys.stderr.write("patch failed") |
604 sys.exit(1) | 618 sys.exit(1) |
605 | 619 |
606 if len(files) > 0: | 620 if len(files) > 0: |
607 addremove(ui, repo, *files) | 621 addremove(ui, repo, *files) |
608 repo.commit(files, text) | 622 repo.commit(files, text, user) |
609 | 623 |
610 def init(ui, source=None): | 624 def init(ui, source=None): |
611 """create a new repository in the current directory""" | 625 """create a new repository in the current directory""" |
612 | 626 |
613 if source: | 627 if source: |