changeset 20597:9155257e6330

rebase: do not raise an UnboundLocalError when called wrong (issue4106) When the base is not found, we should not raise a traceback about a not defined variable. This hides the real problem: the function rebasenode was (probably) called wrong. An AssertionError is raised to highlight that the caller of the function did something wrong. An alternative approach is to only assign None to the variable "base" and let the merge mechanism raise an abort message. This was the behaviour for this case before ad9db007656f. But the only known case for this problem is when an extension calls this function wrong. An AssertionError makes this clearer than an abort message. When a different case is detected, the behaviour can be improved then.
author Simon Heimberg <simohe@besonet.ch>
date Fri, 14 Feb 2014 00:34:20 +0100
parents 004a1744088d
children e57e2da803aa
files hgext/rebase.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Thu Feb 27 19:56:36 2014 -0800
+++ b/hgext/rebase.py	Fri Feb 14 00:34:20 2014 +0100
@@ -516,6 +516,12 @@
             if state.get(p.rev()) == repo[p1].rev():
                 base = p.node()
                 break
+        else: # fallback when base not found
+            base = None
+
+            # Raise because this function is called wrong (see issue 4106)
+            raise AssertionError('no base found to rebase on '
+                                 '(rebasenode called wrong)')
     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