Mercurial > hg
comparison hgext/infinitepush/bundleparts.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | e3bb2a58af1e |
children | 687b865b95ad |
comparison
equal
deleted
inserted
replaced
43075:57875cf423c9 | 43076:2372284d9457 |
---|---|
21 | 21 |
22 isremotebooksenabled = common.isremotebooksenabled | 22 isremotebooksenabled = common.isremotebooksenabled |
23 | 23 |
24 scratchbranchparttype = 'b2x:infinitepush' | 24 scratchbranchparttype = 'b2x:infinitepush' |
25 | 25 |
26 | |
26 def getscratchbranchparts(repo, peer, outgoing, ui, bookmark): | 27 def getscratchbranchparts(repo, peer, outgoing, ui, bookmark): |
27 if not outgoing.missing: | 28 if not outgoing.missing: |
28 raise error.Abort(_('no commits to push')) | 29 raise error.Abort(_('no commits to push')) |
29 | 30 |
30 if scratchbranchparttype not in bundle2.bundle2caps(peer): | 31 if scratchbranchparttype not in bundle2.bundle2caps(peer): |
31 raise error.Abort(_('no server support for %r') % scratchbranchparttype) | 32 raise error.Abort(_('no server support for %r') % scratchbranchparttype) |
32 | 33 |
33 _validaterevset(repo, revsetlang.formatspec('%ln', outgoing.missing), | 34 _validaterevset( |
34 bookmark) | 35 repo, revsetlang.formatspec('%ln', outgoing.missing), bookmark |
36 ) | |
35 | 37 |
36 supportedversions = changegroup.supportedoutgoingversions(repo) | 38 supportedversions = changegroup.supportedoutgoingversions(repo) |
37 # Explicitly avoid using '01' changegroup version in infinitepush to | 39 # Explicitly avoid using '01' changegroup version in infinitepush to |
38 # support general delta | 40 # support general delta |
39 supportedversions.discard('01') | 41 supportedversions.discard('01') |
58 | 60 |
59 parts = [] | 61 parts = [] |
60 | 62 |
61 # .upper() marks this as a mandatory part: server will abort if there's no | 63 # .upper() marks this as a mandatory part: server will abort if there's no |
62 # handler | 64 # handler |
63 parts.append(bundle2.bundlepart( | 65 parts.append( |
64 scratchbranchparttype.upper(), | 66 bundle2.bundlepart( |
65 advisoryparams=params.iteritems(), | 67 scratchbranchparttype.upper(), |
66 data=cg)) | 68 advisoryparams=params.iteritems(), |
69 data=cg, | |
70 ) | |
71 ) | |
67 | 72 |
68 return parts | 73 return parts |
74 | |
69 | 75 |
70 def _validaterevset(repo, revset, bookmark): | 76 def _validaterevset(repo, revset, bookmark): |
71 """Abort if the revs to be pushed aren't valid for a scratch branch.""" | 77 """Abort if the revs to be pushed aren't valid for a scratch branch.""" |
72 if not repo.revs(revset): | 78 if not repo.revs(revset): |
73 raise error.Abort(_('nothing to push')) | 79 raise error.Abort(_('nothing to push')) |
74 if bookmark: | 80 if bookmark: |
75 # Allow bundle with many heads only if no bookmark is specified | 81 # Allow bundle with many heads only if no bookmark is specified |
76 heads = repo.revs('heads(%r)', revset) | 82 heads = repo.revs('heads(%r)', revset) |
77 if len(heads) > 1: | 83 if len(heads) > 1: |
78 raise error.Abort( | 84 raise error.Abort( |
79 _('cannot push more than one head to a scratch branch')) | 85 _('cannot push more than one head to a scratch branch') |
86 ) | |
87 | |
80 | 88 |
81 def _handlelfs(repo, missing): | 89 def _handlelfs(repo, missing): |
82 '''Special case if lfs is enabled | 90 '''Special case if lfs is enabled |
83 | 91 |
84 If lfs is enabled then we need to call prepush hook | 92 If lfs is enabled then we need to call prepush hook |
88 lfsmod = extensions.find('lfs') | 96 lfsmod = extensions.find('lfs') |
89 lfsmod.wrapper.uploadblobsfromrevs(repo, missing) | 97 lfsmod.wrapper.uploadblobsfromrevs(repo, missing) |
90 except KeyError: | 98 except KeyError: |
91 # Ignore if lfs extension is not enabled | 99 # Ignore if lfs extension is not enabled |
92 return | 100 return |
101 | |
93 | 102 |
94 class copiedpart(object): | 103 class copiedpart(object): |
95 """a copy of unbundlepart content that can be consumed later""" | 104 """a copy of unbundlepart content that can be consumed later""" |
96 | 105 |
97 def __init__(self, part): | 106 def __init__(self, part): |