[PATCH 10 of 10] phabricator: do not read a same revision twice

Jun Wu quark at fb.com
Tue Jul 4 21:58:35 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1499219548 25200
#      Tue Jul 04 18:52:28 2017 -0700
# Node ID 6f1f74ecc788edf66ab9b0e8717724b97666f037
# Parent  0e2c9cf54e09bacb4a019bc51693a9fecf1051a3
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 6f1f74ecc788
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 --git a/contrib/phabricator.py b/contrib/phabricator.py
--- a/contrib/phabricator.py
+++ b/contrib/phabricator.py
@@ -382,4 +382,5 @@ def querydrev(repo, params, stack=False)
         return prefetched[key]
 
+    visited = set()
     result = []
     queue = [params]
@@ -387,4 +388,7 @@ def querydrev(repo, params, stack=False)
         params = queue.pop()
         drev = fetch(params)
+        if drev[r'id'] in visited:
+            continue
+        visited.add(drev[r'id'])
         result.append(drev)
         if stack:


More information about the Mercurial-devel mailing list