# HG changeset patch # User Jun Wu # Date 1499219548 25200 # Node ID 02299a28ba349a370b87122f4a5e550c245a0821 # Parent f7b635716ef2006bd0be8493140b864e64c8615c 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. diff -r f7b635716ef2 -r 02299a28ba34 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', {})