# HG changeset patch # User Matt Mackall # Date 1318706347 18000 # Node ID 84d4a4ce45fd2dba5533a97f0b846a65f745219c # Parent 6cb6064f1d50c9bdb2371f6dd3fb323ef5e5051c rebase: simplify set generation diff -r 6cb6064f1d50 -r 84d4a4ce45fd hgext/rebase.py --- a/hgext/rebase.py Sat Oct 15 20:12:32 2011 +0200 +++ b/hgext/rebase.py Sat Oct 15 14:19:07 2011 -0500 @@ -15,7 +15,7 @@ ''' from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks -from mercurial import extensions, patch, scmutil +from mercurial import extensions, patch from mercurial.commands import templateopts from mercurial.node import nullrev from mercurial.lock import release @@ -184,31 +184,18 @@ else: dest = repo[destf] - rebaseset = None - if srcf: - revsetargs = ('(%r)::', srcf) - elif revf: - rebaseset = scmutil.revrange(repo, revf) - if not keepf and rebaseset: - try: - repo.set('children(%ld) - %ld', - rebaseset, rebaseset).next() - except StopIteration: - pass # empty revset is what we look for - else: - msg = _("can't remove original changesets with" - " unrebased descendants") - hint = _('use --keep to keep original changesets') - raise util.Abort(msg, hint=hint) + if revf: + revgen = repo.set('%lr', revf) + elif srcf: + revgen = repo.set('(%r)::', srcf) else: base = basef or '.' - revsetargs = ('(children(ancestor(%r, %d)) and ::(%r))::', - base, dest, base) - if rebaseset is None: - rebaseset = [c.rev() for c in repo.set(*revsetargs)] - if rebaseset: - result = buildstate(repo, dest, rebaseset, detachf) - else: + revgen = repo.set('(children(ancestor(%r, %d)) and ::(%r))::', + base, dest, base) + + rebaseset = [c.rev() for c in revgen] + + if not rebaseset: repo.ui.debug('base is ancestor of destination') result = None if not result: @@ -581,7 +568,7 @@ if commonbase == dest: samebranch = root.branch() == dest.branch() if samebranch and root in dest.children(): - repo.ui.debug(_('source is a child of destination')) + repo.ui.debug('source is a child of destination') return None # rebase on ancestor, force detach detach = True