changeset 10762:129e96f7a87a stable

rebase: fix --collapse with --keepbranches (issue2100) This was broken in 38fe86fb16e3.
author Patrick Mezard <pmezard@gmail.com>
date Tue, 23 Mar 2010 20:45:08 +0100
parents 16a13fdb4b36
children 68a7b9ed3c71 95b7a15b2f05
files hgext/rebase.py tests/test-rebase-collapse
diffstat 2 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Mar 23 20:01:30 2010 +0100
+++ b/hgext/rebase.py	Tue Mar 23 20:45:08 2010 +0100
@@ -161,10 +161,7 @@
                                     'resolve then run hg rebase --continue'))
                 updatedirstate(repo, rev, target, p2)
                 if not collapsef:
-                    extra = {'rebase_source': repo[rev].hex()}
-                    if extrafn:
-                        extrafn(repo[rev], extra)
-                    newrev = concludenode(repo, rev, p1, p2, extra=extra)
+                    newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn)
                 else:
                     # Skip commit if we are collapsing
                     repo.dirstate.setparents(repo[p1].node())
@@ -190,7 +187,7 @@
                     commitmsg += '\n* %s' % repo[rebased].description()
             commitmsg = ui.edit(commitmsg, repo.ui.username())
             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
-                                                    extra=extrafn)
+                                  extrafn=extrafn)
 
         if 'qtip' in repo.tags():
             updatemq(repo, state, skipped, **opts)
@@ -266,17 +263,19 @@
                 if v in m2 and v not in m1:
                     repo.dirstate.remove(v)
 
-def concludenode(repo, rev, p1, p2, commitmsg=None, extra=None):
+def concludenode(repo, rev, p1, p2, commitmsg=None, extrafn=None):
     'Commit the changes and store useful information in extra'
     try:
         repo.dirstate.setparents(repo[p1].node(), repo[p2].node())
         if commitmsg is None:
             commitmsg = repo[rev].description()
-        if extra is None:
-            extra = {}
+        ctx = repo[rev]
+        extra = {'rebase_source': ctx.hex()}
+        if extrafn:
+            extrafn(ctx, extra)
         # Commit might fail if unresolved files exist
-        newrev = repo.commit(text=commitmsg, user=repo[rev].user(),
-                             date=repo[rev].date(), extra=extra)
+        newrev = repo.commit(text=commitmsg, user=ctx.user(),
+                             date=ctx.date(), extra=extra)
         repo.dirstate.setbranch(repo[newrev].branch())
         return newrev
     except util.Abort:
--- a/tests/test-rebase-collapse	Tue Mar 23 20:01:30 2010 +0100
+++ b/tests/test-rebase-collapse	Tue Mar 23 20:45:08 2010 +0100
@@ -43,7 +43,7 @@
 hg glog  --template '{rev}: {desc}\n'
 echo '% Rebasing B onto H'
 hg up -C 3
-hg rebase --collapse 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+hg rebase --collapse --keepbranches 2>&1 | sed 's/\(saving bundle to \).*/\1/'
 hg glog  --template '{rev}: {desc}\n'
 echo "Expected A, B, C, D, F, H"
 hg manifest