From patchwork Sun Nov 30 19:08:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [07, of, 17] rebase: instead of using > nullmerge, use the more meaningful >= nullrev From: Mads Kiilerich X-Patchwork-Id: 6911 Message-Id: <848717d552179b367995.1417374514@localhost.localdomain> To: mercurial-devel@selenic.com Date: Sun, 30 Nov 2014 20:08:34 +0100 # HG changeset patch # User Mads Kiilerich # Date 1417374421 -3600 # Sun Nov 30 20:07:01 2014 +0100 # Node ID 848717d552179b3679951aefc0b28235784471ba # Parent 09fe6c1db24cc0c3fd3dceae4063c0a8dcbd11a5 rebase: instead of using > nullmerge, use the more meaningful >= nullrev nullmerge is just a 'random' constant. It is more essential that nullrev comes just before the 'real' revision numbers and that the other constants are smaller. diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -26,8 +26,8 @@ import os, errno # state values: # >= 0 means already rebased to this rev # nullrev = -1 means 'todo' -nullmerge = -2 -revignored = -3 +nullmerge = -2 # revision is ignored when rebasing, use target +revignored = -3 # revision is ignored when rebasing, use nearest ancestor cmdtable = {} command = cmdutil.command(cmdtable) @@ -447,14 +447,14 @@ def rebase(ui, repo, **opts): else: commitmsg = 'Collapsed revision' for rebased in state: - if rebased not in skipped and state[rebased] > nullmerge: + if rebased not in skipped and state[rebased] >= nullrev: commitmsg += '\n* %s' % repo[rebased].description() editopt = True editor = cmdutil.getcommiteditor(edit=editopt, editform=editform) newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg, extrafn=extrafn, editor=editor) for oldrev in state.iterkeys(): - if state[oldrev] > nullmerge: + if state[oldrev] >= nullrev: state[oldrev] = newrev if 'qtip' in repo.tags(): @@ -464,7 +464,7 @@ def rebase(ui, repo, **opts): # Nodeids are needed to reset bookmarks nstate = {} for k, v in state.iteritems(): - if v > nullmerge: + if v >= nullrev: nstate[repo[k].node()] = repo[v].node() # XXX this is the same as dest.node() for the non-continue path -- # this should probably be cleaned up @@ -628,7 +628,7 @@ def rebasenode(repo, rev, p1, state, col def nearestrebased(repo, rev, state): """return the nearest ancestors of rev in the rebase result""" - rebased = [r for r in state if state[r] > nullmerge] + rebased = [r for r in state if state[r] >= nullrev] candidates = repo.revs('max(%ld and (::%d))', rebased, rev) if candidates: return state[candidates.first()] @@ -751,7 +751,7 @@ def storestatus(repo, originalwd, target f.write('%s\n' % (activebookmark or '')) for d, v in state.iteritems(): oldrev = repo[d].hex() - if v > nullmerge: + if v >= nullrev: newrev = repo[v].hex() else: newrev = v @@ -972,7 +972,7 @@ def clearrebased(ui, repo, state, skippe if markers: obsolete.createmarkers(repo, markers) else: - rebased = [rev for rev in state if state[rev] > nullmerge] + rebased = [rev for rev in state if state[rev] >= nullrev] if rebased: stripped = [] for root in repo.set('roots(%ld)', rebased):