hgext/rebase.py
changeset 20250 f380b191e085
parent 20249 dc5157841361
child 20313 dcd65ce87260
equal deleted inserted replaced
20249:dc5157841361 20250:f380b191e085
   260                                         'ancestor of destination %s\n') % dest)
   260                                         'ancestor of destination %s\n') % dest)
   261                     else: # can it happen?
   261                     else: # can it happen?
   262                         ui.status(_('nothing to rebase from %s to %s\n') %
   262                         ui.status(_('nothing to rebase from %s to %s\n') %
   263                                   ('+'.join(str(repo[r]) for r in base), dest))
   263                                   ('+'.join(str(repo[r]) for r in base), dest))
   264                     return 1
   264                     return 1
   265             if rebaseset:
   265 
   266                 root = min(rebaseset)
   266             if (not (keepf or obsolete._enabled)
   267             else:
       
   268                 root = None
       
   269 
       
   270             if not rebaseset:
       
   271                 repo.ui.debug('base is ancestor of destination\n')
       
   272                 result = None
       
   273             elif (not (keepf or obsolete._enabled)
       
   274                   and repo.revs('first(children(%ld) - %ld)',
   267                   and repo.revs('first(children(%ld) - %ld)',
   275                                 rebaseset, rebaseset)):
   268                                 rebaseset, rebaseset)):
   276                 raise util.Abort(
   269                 raise util.Abort(
   277                     _("can't remove original changesets with"
   270                     _("can't remove original changesets with"
   278                       " unrebased descendants"),
   271                       " unrebased descendants"),
   279                     hint=_('use --keep to keep original changesets'))
   272                     hint=_('use --keep to keep original changesets'))
   280             else:
   273 
   281                 result = buildstate(repo, dest, rebaseset, collapsef)
   274             result = buildstate(repo, dest, rebaseset, collapsef)
   282 
       
   283             if not result:
   275             if not result:
   284                 # Empty state built, nothing to rebase
   276                 # Empty state built, nothing to rebase
   285                 ui.status(_('nothing to rebase\n'))
   277                 ui.status(_('nothing to rebase\n'))
   286                 return 1
   278                 return 1
   287             elif not keepf and not repo[root].mutable():
   279 
       
   280             root = min(rebaseset)
       
   281             if not keepf and not repo[root].mutable():
   288                 raise util.Abort(_("can't rebase immutable changeset %s")
   282                 raise util.Abort(_("can't rebase immutable changeset %s")
   289                                  % repo[root],
   283                                  % repo[root],
   290                                  hint=_('see hg help phases for details'))
   284                                  hint=_('see hg help phases for details'))
   291             else:
   285 
   292                 originalwd, target, state = result
   286             originalwd, target, state = result
   293                 if collapsef:
   287             if collapsef:
   294                     targetancestors = repo.changelog.ancestors([target],
   288                 targetancestors = repo.changelog.ancestors([target],
   295                                                                inclusive=True)
   289                                                            inclusive=True)
   296                     external = externalparent(repo, state, targetancestors)
   290                 external = externalparent(repo, state, targetancestors)
   297 
   291 
   298         if keepbranchesf:
   292         if keepbranchesf:
   299             # insert _savebranch at the start of extrafns so if
   293             # insert _savebranch at the start of extrafns so if
   300             # there's a user-provided extrafn it can clobber branch if
   294             # there's a user-provided extrafn it can clobber branch if
   301             # desired
   295             # desired
   305                 for rev in state:
   299                 for rev in state:
   306                     branches.add(repo[rev].branch())
   300                     branches.add(repo[rev].branch())
   307                     if len(branches) > 1:
   301                     if len(branches) > 1:
   308                         raise util.Abort(_('cannot collapse multiple named '
   302                         raise util.Abort(_('cannot collapse multiple named '
   309                             'branches'))
   303                             'branches'))
   310 
       
   311 
   304 
   312         # Rebase
   305         # Rebase
   313         if not targetancestors:
   306         if not targetancestors:
   314             targetancestors = repo.changelog.ancestors([target], inclusive=True)
   307             targetancestors = repo.changelog.ancestors([target], inclusive=True)
   315 
   308