Mercurial > hg
comparison mercurial/obsutil.py @ 45942:89a2afe31e82
formating: upgrade to black 20.8b1
This required a couple of small tweaks to un-confuse black, but now it
works. Big formatting changes come from:
* Dramatically improved collection-splitting logic upstream
* Black having a strong (correct IMO) opinion that """ is better than '''
Differential Revision: https://phab.mercurial-scm.org/D9430
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 27 Nov 2020 17:03:29 -0500 |
parents | 04ef381000a8 |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
45941:346af7687c6f | 45942:89a2afe31e82 |
---|---|
379 re.compile(b'^source$'), | 379 re.compile(b'^source$'), |
380 ] | 380 ] |
381 | 381 |
382 | 382 |
383 def metanotblacklisted(metaitem): | 383 def metanotblacklisted(metaitem): |
384 """ Check that the key of a meta item (extrakey, extravalue) does not | 384 """Check that the key of a meta item (extrakey, extravalue) does not |
385 match at least one of the blacklist pattern | 385 match at least one of the blacklist pattern |
386 """ | 386 """ |
387 metakey = metaitem[0] | 387 metakey = metaitem[0] |
388 | 388 |
389 return not any(pattern.match(metakey) for pattern in METABLACKLIST) | 389 return not any(pattern.match(metakey) for pattern in METABLACKLIST) |
437 return False | 437 return False |
438 return True | 438 return True |
439 | 439 |
440 | 440 |
441 def geteffectflag(source, successors): | 441 def geteffectflag(source, successors): |
442 """ From an obs-marker relation, compute what changed between the | 442 """From an obs-marker relation, compute what changed between the |
443 predecessor and the successor. | 443 predecessor and the successor. |
444 """ | 444 """ |
445 effects = 0 | 445 effects = 0 |
446 | 446 |
447 for changectx in successors: | 447 for changectx in successors: |
814 | 814 |
815 return values | 815 return values |
816 | 816 |
817 | 817 |
818 def _getobsfate(successorssets): | 818 def _getobsfate(successorssets): |
819 """ Compute a changeset obsolescence fate based on its successorssets. | 819 """Compute a changeset obsolescence fate based on its successorssets. |
820 Successors can be the tipmost ones or the immediate ones. This function | 820 Successors can be the tipmost ones or the immediate ones. This function |
821 return values are not meant to be shown directly to users, it is meant to | 821 return values are not meant to be shown directly to users, it is meant to |
822 be used by internal functions only. | 822 be used by internal functions only. |
823 Returns one fate from the following values: | 823 Returns one fate from the following values: |
824 - pruned | 824 - pruned |
841 else: | 841 else: |
842 return b'superseded_split' | 842 return b'superseded_split' |
843 | 843 |
844 | 844 |
845 def obsfateverb(successorset, markers): | 845 def obsfateverb(successorset, markers): |
846 """ Return the verb summarizing the successorset and potentially using | 846 """Return the verb summarizing the successorset and potentially using |
847 information from the markers | 847 information from the markers |
848 """ | 848 """ |
849 if not successorset: | 849 if not successorset: |
850 verb = b'pruned' | 850 verb = b'pruned' |
851 elif len(successorset) == 1: | 851 elif len(successorset) == 1: |
854 verb = b'split' | 854 verb = b'split' |
855 return verb | 855 return verb |
856 | 856 |
857 | 857 |
858 def markersdates(markers): | 858 def markersdates(markers): |
859 """returns the list of dates for a list of markers | 859 """returns the list of dates for a list of markers""" |
860 """ | |
861 return [m[4] for m in markers] | 860 return [m[4] for m in markers] |
862 | 861 |
863 | 862 |
864 def markersusers(markers): | 863 def markersusers(markers): |
865 """ Returns a sorted list of markers users without duplicates | 864 """Returns a sorted list of markers users without duplicates""" |
866 """ | |
867 markersmeta = [dict(m[3]) for m in markers] | 865 markersmeta = [dict(m[3]) for m in markers] |
868 users = { | 866 users = { |
869 encoding.tolocal(meta[b'user']) | 867 encoding.tolocal(meta[b'user']) |
870 for meta in markersmeta | 868 for meta in markersmeta |
871 if meta.get(b'user') | 869 if meta.get(b'user') |
873 | 871 |
874 return sorted(users) | 872 return sorted(users) |
875 | 873 |
876 | 874 |
877 def markersoperations(markers): | 875 def markersoperations(markers): |
878 """ Returns a sorted list of markers operations without duplicates | 876 """Returns a sorted list of markers operations without duplicates""" |
879 """ | |
880 markersmeta = [dict(m[3]) for m in markers] | 877 markersmeta = [dict(m[3]) for m in markers] |
881 operations = { | 878 operations = { |
882 meta.get(b'operation') for meta in markersmeta if meta.get(b'operation') | 879 meta.get(b'operation') for meta in markersmeta if meta.get(b'operation') |
883 } | 880 } |
884 | 881 |
885 return sorted(operations) | 882 return sorted(operations) |
886 | 883 |
887 | 884 |
888 def obsfateprinter(ui, repo, successors, markers, formatctx): | 885 def obsfateprinter(ui, repo, successors, markers, formatctx): |
889 """ Build a obsfate string for a single successorset using all obsfate | 886 """Build a obsfate string for a single successorset using all obsfate |
890 related function defined in obsutil | 887 related function defined in obsutil |
891 """ | 888 """ |
892 quiet = ui.quiet | 889 quiet = ui.quiet |
893 verbose = ui.verbose | 890 verbose = ui.verbose |
894 normal = not verbose and not quiet | 891 normal = not verbose and not quiet |
948 ), | 945 ), |
949 } | 946 } |
950 | 947 |
951 | 948 |
952 def _getfilteredreason(repo, changeid, ctx): | 949 def _getfilteredreason(repo, changeid, ctx): |
953 """return a human-friendly string on why a obsolete changeset is hidden | 950 """return a human-friendly string on why a obsolete changeset is hidden""" |
954 """ | |
955 successors = successorssets(repo, ctx.node()) | 951 successors = successorssets(repo, ctx.node()) |
956 fate = _getobsfate(successors) | 952 fate = _getobsfate(successors) |
957 | 953 |
958 # Be more precise in case the revision is superseded | 954 # Be more precise in case the revision is superseded |
959 if fate == b'pruned': | 955 if fate == b'pruned': |