phabricator: do not read a same revision twice
authorJun Wu <quark@fb.com>
Tue, 04 Jul 2017 18:52:28 -0700
changeset 33271 02299a28ba34
parent 33270 f7b635716ef2
child 33272 df90f4d6c609
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.
contrib/phabricator.py
--- 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', {})