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