[PATCH] rebase: do not raise an UnboundLocalError when called with wrong rev (issue4106)

Simon Heimberg simohe at besonet.ch
Thu Feb 13 17:41:45 CST 2014


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1392334460 -3600
# Node ID 0ed5bb67f3403b8e0655ee5ff2a7aeb32e307837
# Parent  0f1ef9e9e904c18f1ac96aef3a0e0d3aa5f1190c
rebase: do not raise an UnboundLocalError when called with wrong rev (issue4106)

When the base is not found, we should not raise a traceback about a not defined
variable. This hides the real problem, that the function was called with wrong
revisions.

Lets assign None to the variable "base" and the merge mechanism raise an
error. The error message makes sense for the problem described in issue4106.
Raising an AssertionError instead would be an alternative, because the error
only happens when the function is called with wrong revisions.

diff -r 0f1ef9e9e904 -r 0ed5bb67f340 hgext/rebase.py
--- a/hgext/rebase.py	Don Feb 06 15:56:25 2014 -0800
+++ b/hgext/rebase.py	Fre Feb 14 00:34:20 2014 +0100
@@ -513,6 +513,11 @@
             if state.get(p.rev()) == repo[p1].rev():
                 base = p.node()
                 break
+        else:
+            # fallback when base not found (unnormal, see issue 4106)
+            #
+            # Let the merge mechanism find the base itself or raise an error.
+            base = None
     if base is not None:
         repo.ui.debug("   detach base %d:%s\n" % (repo[base].rev(), repo[base]))
     # When collapsing in-place, the parent is the common ancestor, we


More information about the Mercurial-devel mailing list