changeset 33831:75fdaf851e83

phabricator: change "readpatch" to be more flexible Previously, `readpatch` and `querydrev` take a same `params` and `stack` parameters. This patch changes `readpatch` so it takes the output of `querydrev`, not the input of `querydrev`. This makes the code more flexible and cleaner. Differential Revision: https://phab.mercurial-scm.org/D124
author Jun Wu <quark@fb.com>
date Mon, 17 Jul 2017 23:14:06 -0700
parents aa6c290a77fa
children 539541779010
files contrib/phabricator.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/phabricator.py	Sun Aug 13 22:46:16 2017 -0700
+++ b/contrib/phabricator.py	Mon Jul 17 23:14:06 2017 -0700
@@ -635,15 +635,12 @@
             meta[r'parent'] = commit[r'parents'][0]
     return meta or {}
 
-def readpatch(repo, params, write, stack=False):
+def readpatch(repo, drevs, write):
     """generate plain-text patch readable by 'hg import'
 
-    write is usually ui.write. params is passed to "differential.query". If
-    stack is True, also write dependent patches.
+    write is usually ui.write. drevs is what "querydrev" returns, results of
+    "differential.query".
     """
-    # Differential Revisions
-    drevs = querydrev(repo, params, stack)
-
     # Prefetch hg:meta property for all diffs
     diffids = sorted(set(max(int(v) for v in drev[r'diffs']) for drev in drevs))
     diffs = callconduit(repo, 'differential.querydiffs', {'ids': diffids})
@@ -683,4 +680,5 @@
         revid = int(revid.split('/')[-1].replace('D', ''))
     except ValueError:
         raise error.Abort(_('invalid Revision ID: %s') % revid)
-    readpatch(repo, {'ids': [revid]}, ui.write, opts.get('stack'))
+    drevs = querydrev(repo, {'ids': [revid]}, opts.get('stack'))
+    readpatch(repo, drevs, ui.write)