diff hgext/histedit.py @ 18437:358c23e8f1c6

histedit: record histedit source (issue3681) Have histedit record the hex of the original changeset as already done by: - graft - commit --amend - rebase My main motivation for adding this is to prevent the creation of obsolescence cycle (see issue3681). Note that commit created during edit are not affected yet.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 16 Jan 2013 19:14:22 +0100
parents b38c10502af9
children 35513c59f376
line wrap: on
line diff
--- a/hgext/histedit.py	Wed Jan 16 19:11:06 2013 +0100
+++ b/hgext/histedit.py	Wed Jan 16 19:14:22 2013 +0100
@@ -181,12 +181,15 @@
 
     This function ensure we apply the same treatement to all changesets.
 
-    No such treatment is done yet.
+    - Add a 'histedit_source' entry in extra.
 
     Note that fold have its own separated logic because its handling is a bit
     different and not easily factored out of the fold method.
     """
     def commitfunc(**kwargs):
+        extra = kwargs.get('extra', {}).copy()
+        extra['histedit_source'] = src.hex()
+        kwargs['extra'] = extra
         return repo.commit(**kwargs)
     return commitfunc
 
@@ -270,7 +273,7 @@
         message = first.description()
     user = commitopts.get('user')
     date = commitopts.get('date')
-    extra = first.extra()
+    extra = commitopts.get('extra')
 
     parents = (first.p1().node(), first.p2().node())
     new = context.memctx(repo,
@@ -348,6 +351,12 @@
     commitopts['message'] = newmessage
     # date
     commitopts['date'] = max(ctx.date(), oldctx.date())
+    extra = ctx.extra().copy()
+    # histedit_source
+    # note: ctx is likely a temporary commit but that the best we can do here
+    #       This is sufficient to solve issue3681 anyway
+    extra['histedit_source'] = '%s,%s' % (ctx.hex(), oldctx.hex())
+    commitopts['extra'] = extra
     n = collapse(repo, ctx, repo[newnode], commitopts)
     if n is None:
         return ctx, []