hgext/rebase.py
branchstable
changeset 10762 129e96f7a87a
parent 10672 c2e1e637d4da
child 10763 68a7b9ed3c71
child 11188 b5c0f6a11430
equal deleted inserted replaced
10761:16a13fdb4b36 10762:129e96f7a87a
   159                     if stats and stats[3] > 0:
   159                     if stats and stats[3] > 0:
   160                         raise util.Abort(_('fix unresolved conflicts with hg '
   160                         raise util.Abort(_('fix unresolved conflicts with hg '
   161                                     'resolve then run hg rebase --continue'))
   161                                     'resolve then run hg rebase --continue'))
   162                 updatedirstate(repo, rev, target, p2)
   162                 updatedirstate(repo, rev, target, p2)
   163                 if not collapsef:
   163                 if not collapsef:
   164                     extra = {'rebase_source': repo[rev].hex()}
   164                     newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn)
   165                     if extrafn:
       
   166                         extrafn(repo[rev], extra)
       
   167                     newrev = concludenode(repo, rev, p1, p2, extra=extra)
       
   168                 else:
   165                 else:
   169                     # Skip commit if we are collapsing
   166                     # Skip commit if we are collapsing
   170                     repo.dirstate.setparents(repo[p1].node())
   167                     repo.dirstate.setparents(repo[p1].node())
   171                     newrev = None
   168                     newrev = None
   172                 # Update the state
   169                 # Update the state
   188             for rebased in state:
   185             for rebased in state:
   189                 if rebased not in skipped and state[rebased] != nullmerge:
   186                 if rebased not in skipped and state[rebased] != nullmerge:
   190                     commitmsg += '\n* %s' % repo[rebased].description()
   187                     commitmsg += '\n* %s' % repo[rebased].description()
   191             commitmsg = ui.edit(commitmsg, repo.ui.username())
   188             commitmsg = ui.edit(commitmsg, repo.ui.username())
   192             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
   189             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
   193                                                     extra=extrafn)
   190                                   extrafn=extrafn)
   194 
   191 
   195         if 'qtip' in repo.tags():
   192         if 'qtip' in repo.tags():
   196             updatemq(repo, state, skipped, **opts)
   193             updatemq(repo, state, skipped, **opts)
   197 
   194 
   198         if not keepf:
   195         if not keepf:
   264             if v in m1 or v in m2:
   261             if v in m1 or v in m2:
   265                 repo.dirstate.copy(v, k)
   262                 repo.dirstate.copy(v, k)
   266                 if v in m2 and v not in m1:
   263                 if v in m2 and v not in m1:
   267                     repo.dirstate.remove(v)
   264                     repo.dirstate.remove(v)
   268 
   265 
   269 def concludenode(repo, rev, p1, p2, commitmsg=None, extra=None):
   266 def concludenode(repo, rev, p1, p2, commitmsg=None, extrafn=None):
   270     'Commit the changes and store useful information in extra'
   267     'Commit the changes and store useful information in extra'
   271     try:
   268     try:
   272         repo.dirstate.setparents(repo[p1].node(), repo[p2].node())
   269         repo.dirstate.setparents(repo[p1].node(), repo[p2].node())
   273         if commitmsg is None:
   270         if commitmsg is None:
   274             commitmsg = repo[rev].description()
   271             commitmsg = repo[rev].description()
   275         if extra is None:
   272         ctx = repo[rev]
   276             extra = {}
   273         extra = {'rebase_source': ctx.hex()}
       
   274         if extrafn:
       
   275             extrafn(ctx, extra)
   277         # Commit might fail if unresolved files exist
   276         # Commit might fail if unresolved files exist
   278         newrev = repo.commit(text=commitmsg, user=repo[rev].user(),
   277         newrev = repo.commit(text=commitmsg, user=ctx.user(),
   279                              date=repo[rev].date(), extra=extra)
   278                              date=ctx.date(), extra=extra)
   280         repo.dirstate.setbranch(repo[newrev].branch())
   279         repo.dirstate.setbranch(repo[newrev].branch())
   281         return newrev
   280         return newrev
   282     except util.Abort:
   281     except util.Abort:
   283         # Invalidate the previous setparents
   282         # Invalidate the previous setparents
   284         repo.dirstate.invalidate()
   283         repo.dirstate.invalidate()