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.
--- 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', {})