Patchwork [4,of,6] py3: make 'None in lazyancestors' not crash

login
register
mail settings
Submitter Yuya Nishihara
Date July 8, 2018, 12:30 p.m.
Message ID <a6cd4ea3c3ad4e0bdb2f.1531053045@mimosa>
Download mbox | patch
Permalink /patch/32690/
State Accepted
Headers show

Comments

Yuya Nishihara - July 8, 2018, 12:30 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1531037874 -32400
#      Sun Jul 08 17:17:54 2018 +0900
# Node ID a6cd4ea3c3ad4e0bdb2ff40ffc37824e324dc9ed
# Parent  b263133eeb5a5db11706fd146ea68ea7ce6ca632
py3: make 'None in lazyancestors' not crash

This looks somewhat weird, but we have callers like 'torev(n) in futurecommon'
around where torev(n) is dictlike.get(n). I could fix callers, but that would
be unnecessarily verbose.

Patch

diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -339,6 +339,10 @@  class lazyancestors(object):
         seen = self._containsseen
         if target in seen:
             return True
+        # Only integer target is valid, but some callers expect 'None in self'
+        # to be False. So we explicitly allow it.
+        if target is None:
+            return False
 
         parentrevs = self._parentrevs
         visit = self._containsvisit