Patchwork [evolve-ext] directaccess: inspect trees of len() > 3

login
register
mail settings
Submitter Durham Goode
Date Sept. 29, 2015, 4:56 p.m.
Message ID <abecad535914b59b11c3.1443545803@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/10688/
State Accepted
Headers show

Comments

Durham Goode - Sept. 29, 2015, 4:56 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1443545230 25200
#      Tue Sep 29 09:47:10 2015 -0700
# Node ID abecad535914b59b11c3513e822216a2e4e4f69a
# Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
directaccess: inspect trees of len() > 3

Previously, when inspecting revset AST's we'd only traverse down the tree if it
was length 3 ([op, left, right]). In some situations, like 'or' the tree node
will be greater than length 3 ([op, first, second, ..., nth]). So we need to
traverse all the parts of the node to catch all the symbols.
Pierre-Yves David - Sept. 30, 2015, 1:18 a.m.
On 09/29/2015 09:56 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1443545230 25200
> #      Tue Sep 29 09:47:10 2015 -0700
> # Node ID abecad535914b59b11c3513e822216a2e4e4f69a
> # Parent  a55c691f4cc0b960a02bc94b3296403524c8db84
> directaccess: inspect trees of len() > 3

Nice catch, pushed to main, thanks.

Patch

diff --git a/hgext/directaccess.py b/hgext/directaccess.py
--- a/hgext/directaccess.py
+++ b/hgext/directaccess.py
@@ -152,8 +152,11 @@  def gethashsymbols(tree):
             if hashre.match(entry):
                 result.append(entry)
         return result
-    elif len(tree) == 3:
-        return gethashsymbols(tree[1]) + gethashsymbols(tree[2])
+    elif len(tree) >= 3:
+        results = []
+        for subtree in tree[1:]:
+            results += gethashsymbols(subtree)
+        return results
     else:
         return []
 
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -358,6 +358,13 @@  But only with hash
   [255]
 
 
+Test directaccess in a larger revset
+
+  $ hg log -r '. + .^ + 2db36d8066ff' -T '{node|short}\n'
+  55c73a90e4b4
+  cf5c4f4554ce
+  2db36d8066ff
+
 With severals hidden sha, rebase of one hidden stack onto another one:
   $ hg update -C 0
   0 files updated, 0 files merged, 4 files removed, 0 files unresolved