Mercurial > hg
comparison hgext/phabricator.py @ 44452:9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Built with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**' | xargs pyupgrade --keep-percent-format --keep-extraneous-parens
and then blackened. pyupgrade comes from
https://github.com/asottile/pyupgrade with a patch to let me preserve
extraneous parens (which we use for marking strings that shouldn't be
translated), and lets us clean up a bunch of idioms that have cruftily
accumulated over the years.
# skip-blame no-op automated code cleanups
Differential Revision: https://phab.mercurial-scm.org/D8255
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 06 Mar 2020 13:27:41 -0500 |
parents | 09f3e003fc2a |
children | bbb170f9396d |
comparison
equal
deleted
inserted
replaced
44449:ff72bd52d56a | 44452:9d2b2df2c2ba |
---|---|
481 diffs = [ | 481 diffs = [ |
482 d for d in alldiffs.values() if int(d[b'revisionID']) == drev | 482 d for d in alldiffs.values() if int(d[b'revisionID']) == drev |
483 ] | 483 ] |
484 | 484 |
485 # "precursors" as known by Phabricator | 485 # "precursors" as known by Phabricator |
486 phprecset = set(getnode(d) for d in diffs) | 486 phprecset = {getnode(d) for d in diffs} |
487 | 487 |
488 # Ignore if precursors (Phabricator and local repo) do not overlap, | 488 # Ignore if precursors (Phabricator and local repo) do not overlap, |
489 # and force is not set (when commit message says nothing) | 489 # and force is not set (when commit message says nothing) |
490 if not force and not bool(phprecset & precset): | 490 if not force and not bool(phprecset & precset): |
491 tagname = b'D%d' % drev | 491 tagname = b'D%d' % drev |
1060 query = {b'constraints': {b'usernames': names}} | 1060 query = {b'constraints': {b'usernames': names}} |
1061 result = callconduit(ui, b'user.search', query) | 1061 result = callconduit(ui, b'user.search', query) |
1062 # username not found is not an error of the API. So check if we have missed | 1062 # username not found is not an error of the API. So check if we have missed |
1063 # some names here. | 1063 # some names here. |
1064 data = result[b'data'] | 1064 data = result[b'data'] |
1065 resolved = set(entry[b'fields'][b'username'].lower() for entry in data) | 1065 resolved = {entry[b'fields'][b'username'].lower() for entry in data} |
1066 unresolved = set(names) - resolved | 1066 unresolved = set(names) - resolved |
1067 if unresolved: | 1067 if unresolved: |
1068 raise error.Abort( | 1068 raise error.Abort( |
1069 _(b'unknown username: %s') % b' '.join(sorted(unresolved)) | 1069 _(b'unknown username: %s') % b' '.join(sorted(unresolved)) |
1070 ) | 1070 ) |
1633 (as bytes, without the "D" prefix) and the bytes are the text of a patch | 1633 (as bytes, without the "D" prefix) and the bytes are the text of a patch |
1634 to be imported. drevs is what "querydrev" returns, results of | 1634 to be imported. drevs is what "querydrev" returns, results of |
1635 "differential.query". | 1635 "differential.query". |
1636 """ | 1636 """ |
1637 # Prefetch hg:meta property for all diffs | 1637 # Prefetch hg:meta property for all diffs |
1638 diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs)) | 1638 diffids = sorted({max(int(v) for v in drev[b'diffs']) for drev in drevs}) |
1639 diffs = callconduit(ui, b'differential.querydiffs', {b'ids': diffids}) | 1639 diffs = callconduit(ui, b'differential.querydiffs', {b'ids': diffids}) |
1640 | 1640 |
1641 patches = [] | 1641 patches = [] |
1642 | 1642 |
1643 # Generate patch for each drev | 1643 # Generate patch for each drev |
1790 @show.showview(b'phabstatus', csettopic=b'work') | 1790 @show.showview(b'phabstatus', csettopic=b'work') |
1791 def phabstatusshowview(ui, repo, displayer): | 1791 def phabstatusshowview(ui, repo, displayer): |
1792 """Phabricator differiential status""" | 1792 """Phabricator differiential status""" |
1793 revs = repo.revs('sort(_underway(), topo)') | 1793 revs = repo.revs('sort(_underway(), topo)') |
1794 drevmap = getdrevmap(repo, revs) | 1794 drevmap = getdrevmap(repo, revs) |
1795 unknownrevs, drevids, revsbydrevid = [], set([]), {} | 1795 unknownrevs, drevids, revsbydrevid = [], set(), {} |
1796 for rev, drevid in pycompat.iteritems(drevmap): | 1796 for rev, drevid in pycompat.iteritems(drevmap): |
1797 if drevid is not None: | 1797 if drevid is not None: |
1798 drevids.add(drevid) | 1798 drevids.add(drevid) |
1799 revsbydrevid.setdefault(drevid, set([])).add(rev) | 1799 revsbydrevid.setdefault(drevid, set()).add(rev) |
1800 else: | 1800 else: |
1801 unknownrevs.append(rev) | 1801 unknownrevs.append(rev) |
1802 | 1802 |
1803 drevs = callconduit(ui, b'differential.query', {b'ids': list(drevids)}) | 1803 drevs = callconduit(ui, b'differential.query', {b'ids': list(drevids)}) |
1804 drevsbyrev = {} | 1804 drevsbyrev = {} |