Mercurial > public > mercurial-scm > hg-stable
comparison contrib/phabricator.py @ 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 | ead6749354e1 |
children | de7c6ec27d99 |
comparison
equal
deleted
inserted
replaced
33270:f7b635716ef2 | 33271:02299a28ba34 |
---|---|
379 prefetched[int(drev[r'id'])] = drev | 379 prefetched[int(drev[r'id'])] = drev |
380 if key not in prefetched: | 380 if key not in prefetched: |
381 raise error.Abort(_('cannot get Differential Revision %r') % params) | 381 raise error.Abort(_('cannot get Differential Revision %r') % params) |
382 return prefetched[key] | 382 return prefetched[key] |
383 | 383 |
384 visited = set() | |
384 result = [] | 385 result = [] |
385 queue = [params] | 386 queue = [params] |
386 while queue: | 387 while queue: |
387 params = queue.pop() | 388 params = queue.pop() |
388 drev = fetch(params) | 389 drev = fetch(params) |
390 if drev[r'id'] in visited: | |
391 continue | |
392 visited.add(drev[r'id']) | |
389 result.append(drev) | 393 result.append(drev) |
390 if stack: | 394 if stack: |
391 auxiliary = drev.get(r'auxiliary', {}) | 395 auxiliary = drev.get(r'auxiliary', {}) |
392 depends = auxiliary.get(r'phabricator:depends-on', []) | 396 depends = auxiliary.get(r'phabricator:depends-on', []) |
393 for phid in depends: | 397 for phid in depends: |