changeset 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 ea4526f9b1a5
children d2994b5298fb
files mercurial/commands.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Jul 03 20:52:41 2005 -0800
+++ b/mercurial/commands.py	Sun Jul 03 21:14:40 2005 -0800
@@ -586,6 +586,20 @@
             if l[:4] == "--- ": 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 == True:
+                hgpatch = True
+                if t[:7] == "# User ":
+                    user = t[7:]
+                    ui.debug('User: %s\n' % user)
+                if t[:2] <> "# " and t.strip() and not snippet: snippet = t
+        if snippet: text = snippet + '\n' + text
+        ui.debug('text:\n%s\n' % text)
+
         # make sure text isn't empty
         if not text: text = "imported patch %s\n" % patch
 
@@ -605,7 +619,7 @@
 
         if len(files) > 0:
             addremove(ui, repo, *files)
-        repo.commit(files, text)
+        repo.commit(files, text, user)
 
 def init(ui, source=None):
     """create a new repository in the current directory"""