Mercurial > public > mercurial-scm > hg
comparison mercurial/obsutil.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 | 32048206e7be |
children | 04ef381000a8 |
comparison
equal
deleted
inserted
replaced
44449:ff72bd52d56a | 44452:9d2b2df2c2ba |
---|---|
192 remaining.add(suc) | 192 remaining.add(suc) |
193 | 193 |
194 | 194 |
195 def _filterprunes(markers): | 195 def _filterprunes(markers): |
196 """return a set with no prune markers""" | 196 """return a set with no prune markers""" |
197 return set(m for m in markers if m[1]) | 197 return {m for m in markers if m[1]} |
198 | 198 |
199 | 199 |
200 def exclusivemarkers(repo, nodes): | 200 def exclusivemarkers(repo, nodes): |
201 """set of markers relevant to "nodes" but no other locally-known nodes | 201 """set of markers relevant to "nodes" but no other locally-known nodes |
202 | 202 |
336 has_node = repo.changelog.index.has_node | 336 has_node = repo.changelog.index.has_node |
337 plen = -1 | 337 plen = -1 |
338 # compute the whole set of successors or descendants | 338 # compute the whole set of successors or descendants |
339 while len(foreground) != plen: | 339 while len(foreground) != plen: |
340 plen = len(foreground) | 340 plen = len(foreground) |
341 succs = set(c.node() for c in foreground) | 341 succs = {c.node() for c in foreground} |
342 mutable = [c.node() for c in foreground if c.mutable()] | 342 mutable = [c.node() for c in foreground if c.mutable()] |
343 succs.update(allsuccessors(repo.obsstore, mutable)) | 343 succs.update(allsuccessors(repo.obsstore, mutable)) |
344 known = (n for n in succs if has_node(n)) | 344 known = (n for n in succs if has_node(n)) |
345 foreground = set(repo.set(b'%ln::', known)) | 345 foreground = set(repo.set(b'%ln::', known)) |
346 return set(c.node() for c in foreground) | 346 return {c.node() for c in foreground} |
347 | 347 |
348 | 348 |
349 # effectflag field | 349 # effectflag field |
350 # | 350 # |
351 # Effect-flag is a 1-byte bit field used to store what changed between a | 351 # Effect-flag is a 1-byte bit field used to store what changed between a |
853 | 853 |
854 def markersusers(markers): | 854 def markersusers(markers): |
855 """ Returns a sorted list of markers users without duplicates | 855 """ Returns a sorted list of markers users without duplicates |
856 """ | 856 """ |
857 markersmeta = [dict(m[3]) for m in markers] | 857 markersmeta = [dict(m[3]) for m in markers] |
858 users = set( | 858 users = { |
859 encoding.tolocal(meta[b'user']) | 859 encoding.tolocal(meta[b'user']) |
860 for meta in markersmeta | 860 for meta in markersmeta |
861 if meta.get(b'user') | 861 if meta.get(b'user') |
862 ) | 862 } |
863 | 863 |
864 return sorted(users) | 864 return sorted(users) |
865 | 865 |
866 | 866 |
867 def markersoperations(markers): | 867 def markersoperations(markers): |
868 """ Returns a sorted list of markers operations without duplicates | 868 """ Returns a sorted list of markers operations without duplicates |
869 """ | 869 """ |
870 markersmeta = [dict(m[3]) for m in markers] | 870 markersmeta = [dict(m[3]) for m in markers] |
871 operations = set( | 871 operations = { |
872 meta.get(b'operation') for meta in markersmeta if meta.get(b'operation') | 872 meta.get(b'operation') for meta in markersmeta if meta.get(b'operation') |
873 ) | 873 } |
874 | 874 |
875 return sorted(operations) | 875 return sorted(operations) |
876 | 876 |
877 | 877 |
878 def obsfateprinter(ui, repo, successors, markers, formatctx): | 878 def obsfateprinter(ui, repo, successors, markers, formatctx): |