Patchwork [07,of,17] rebase: instead of using > nullmerge, use the more meaningful >= nullrev

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 30, 2014, 7:08 p.m.
Message ID <848717d552179b367995.1417374514@localhost.localdomain>
Download mbox | patch
Permalink /patch/6911/
State Changes Requested
Headers show

Comments

Mads Kiilerich - Nov. 30, 2014, 7:08 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# 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.
Pierre-Yves David - Dec. 1, 2014, 7:15 a.m.
On 11/30/2014 11:08 AM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # 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.

Why not. I'm fairly sure you have a second motive behind this change. 
Can you state it?

>
> 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

Can you get this doc in a different patch ?

Patch

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):