hgext/rebase.py
changeset 15917 e66084ef8449
parent 15904 7d28d6a67dd3
child 15923 4b088ae9d47a
equal deleted inserted replaced
15916:c96148346af8 15917:e66084ef8449
    13 For more information:
    13 For more information:
    14 http://mercurial.selenic.com/wiki/RebaseExtension
    14 http://mercurial.selenic.com/wiki/RebaseExtension
    15 '''
    15 '''
    16 
    16 
    17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
    17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
    18 from mercurial import extensions, patch, scmutil
    18 from mercurial import extensions, patch, scmutil, phases
    19 from mercurial.commands import templateopts
    19 from mercurial.commands import templateopts
    20 from mercurial.node import nullrev
    20 from mercurial.node import nullrev
    21 from mercurial.lock import release
    21 from mercurial.lock import release
    22 from mercurial.i18n import _
    22 from mercurial.i18n import _
    23 import os, errno
    23 import os, errno
   370             extrafn(ctx, extra)
   370             extrafn(ctx, extra)
   371         # Commit might fail if unresolved files exist
   371         # Commit might fail if unresolved files exist
   372         newrev = repo.commit(text=commitmsg, user=ctx.user(),
   372         newrev = repo.commit(text=commitmsg, user=ctx.user(),
   373                              date=ctx.date(), extra=extra, editor=editor)
   373                              date=ctx.date(), extra=extra, editor=editor)
   374         repo.dirstate.setbranch(repo[newrev].branch())
   374         repo.dirstate.setbranch(repo[newrev].branch())
       
   375         targetphase = max(ctx.phase(), phases.draft)
       
   376         # retractboundary doesn't overwrite upper phase inherited from parent
       
   377         newnode = repo[newrev].node()
       
   378         phases.retractboundary(repo, targetphase, [newnode])
   375         return newrev
   379         return newrev
   376     except util.Abort:
   380     except util.Abort:
   377         # Invalidate the previous setparents
   381         # Invalidate the previous setparents
   378         repo.dirstate.invalidate()
   382         repo.dirstate.invalidate()
   379         raise
   383         raise
   550             raise
   554             raise
   551         raise util.Abort(_('no rebase in progress'))
   555         raise util.Abort(_('no rebase in progress'))
   552 
   556 
   553 def abort(repo, originalwd, target, state):
   557 def abort(repo, originalwd, target, state):
   554     'Restore the repository to its original state'
   558     'Restore the repository to its original state'
   555     if set(repo.changelog.descendants(target)) - set(state.values()):
   559     descendants = repo.changelog.descendants
       
   560     ispublic = lambda r: repo._phaserev[r] == phases.public
       
   561     if filter(ispublic, descendants(target)):
       
   562         repo.ui.warn(_("warning: immutable rebased changeset detected, "
       
   563                        "can't abort\n"))
       
   564         return -1
       
   565     elif set(descendants(target)) - set(state.values()):
   556         repo.ui.warn(_("warning: new changesets detected on target branch, "
   566         repo.ui.warn(_("warning: new changesets detected on target branch, "
   557                                                     "can't abort\n"))
   567                                                     "can't abort\n"))
   558         return -1
   568         return -1
   559     else:
   569     else:
   560         # Strip from the first rebased revision
   570         # Strip from the first rebased revision