changeset 33271:02299a28ba34

phabricator: do not read a same revision twice It's possible to set up non-linear dependencies in Phabricator like: o D4 |\ | o D3 | | o | D2 |/ o D1 The old `phabread` code will print D1 twice. This patch adds de-duplication to prevent that. Test Plan: Construct the above dependencies in a Phabricator test instance and make sure the old code prints D1 twice while the new code won't.
author Jun Wu <quark@fb.com>
date Tue, 04 Jul 2017 18:52:28 -0700
parents f7b635716ef2
children df90f4d6c609
files contrib/phabricator.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/phabricator.py	Tue Jul 04 16:41:28 2017 -0700
+++ b/contrib/phabricator.py	Tue Jul 04 18:52:28 2017 -0700
@@ -381,11 +381,15 @@
             raise error.Abort(_('cannot get Differential Revision %r') % params)
         return prefetched[key]
 
+    visited = set()
     result = []
     queue = [params]
     while queue:
         params = queue.pop()
         drev = fetch(params)
+        if drev[r'id'] in visited:
+            continue
+        visited.add(drev[r'id'])
         result.append(drev)
         if stack:
             auxiliary = drev.get(r'auxiliary', {})