comparison hgext/infinitepush/bundleparts.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children 649d3ac37a12
comparison
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
19 19
20 from . import common 20 from . import common
21 21
22 isremotebooksenabled = common.isremotebooksenabled 22 isremotebooksenabled = common.isremotebooksenabled
23 23
24 scratchbranchparttype = 'b2x:infinitepush' 24 scratchbranchparttype = b'b2x:infinitepush'
25 25
26 26
27 def getscratchbranchparts(repo, peer, outgoing, ui, bookmark): 27 def getscratchbranchparts(repo, peer, outgoing, ui, bookmark):
28 if not outgoing.missing: 28 if not outgoing.missing:
29 raise error.Abort(_('no commits to push')) 29 raise error.Abort(_(b'no commits to push'))
30 30
31 if scratchbranchparttype not in bundle2.bundle2caps(peer): 31 if scratchbranchparttype not in bundle2.bundle2caps(peer):
32 raise error.Abort(_('no server support for %r') % scratchbranchparttype) 32 raise error.Abort(
33 _(b'no server support for %r') % scratchbranchparttype
34 )
33 35
34 _validaterevset( 36 _validaterevset(
35 repo, revsetlang.formatspec('%ln', outgoing.missing), bookmark 37 repo, revsetlang.formatspec(b'%ln', outgoing.missing), bookmark
36 ) 38 )
37 39
38 supportedversions = changegroup.supportedoutgoingversions(repo) 40 supportedversions = changegroup.supportedoutgoingversions(repo)
39 # Explicitly avoid using '01' changegroup version in infinitepush to 41 # Explicitly avoid using '01' changegroup version in infinitepush to
40 # support general delta 42 # support general delta
41 supportedversions.discard('01') 43 supportedversions.discard(b'01')
42 cgversion = min(supportedversions) 44 cgversion = min(supportedversions)
43 _handlelfs(repo, outgoing.missing) 45 _handlelfs(repo, outgoing.missing)
44 cg = changegroup.makestream(repo, outgoing, cgversion, 'push') 46 cg = changegroup.makestream(repo, outgoing, cgversion, b'push')
45 47
46 params = {} 48 params = {}
47 params['cgversion'] = cgversion 49 params[b'cgversion'] = cgversion
48 if bookmark: 50 if bookmark:
49 params['bookmark'] = bookmark 51 params[b'bookmark'] = bookmark
50 # 'prevbooknode' is necessary for pushkey reply part 52 # 'prevbooknode' is necessary for pushkey reply part
51 params['bookprevnode'] = '' 53 params[b'bookprevnode'] = b''
52 bookmarks = repo._bookmarks 54 bookmarks = repo._bookmarks
53 if bookmark in bookmarks: 55 if bookmark in bookmarks:
54 params['bookprevnode'] = nodemod.hex(bookmarks[bookmark]) 56 params[b'bookprevnode'] = nodemod.hex(bookmarks[bookmark])
55 57
56 # Do not send pushback bundle2 part with bookmarks if remotenames extension 58 # Do not send pushback bundle2 part with bookmarks if remotenames extension
57 # is enabled. It will be handled manually in `_push()` 59 # is enabled. It will be handled manually in `_push()`
58 if not isremotebooksenabled(ui): 60 if not isremotebooksenabled(ui):
59 params['pushbackbookmarks'] = '1' 61 params[b'pushbackbookmarks'] = b'1'
60 62
61 parts = [] 63 parts = []
62 64
63 # .upper() marks this as a mandatory part: server will abort if there's no 65 # .upper() marks this as a mandatory part: server will abort if there's no
64 # handler 66 # handler
74 76
75 77
76 def _validaterevset(repo, revset, bookmark): 78 def _validaterevset(repo, revset, bookmark):
77 """Abort if the revs to be pushed aren't valid for a scratch branch.""" 79 """Abort if the revs to be pushed aren't valid for a scratch branch."""
78 if not repo.revs(revset): 80 if not repo.revs(revset):
79 raise error.Abort(_('nothing to push')) 81 raise error.Abort(_(b'nothing to push'))
80 if bookmark: 82 if bookmark:
81 # Allow bundle with many heads only if no bookmark is specified 83 # Allow bundle with many heads only if no bookmark is specified
82 heads = repo.revs('heads(%r)', revset) 84 heads = repo.revs(b'heads(%r)', revset)
83 if len(heads) > 1: 85 if len(heads) > 1:
84 raise error.Abort( 86 raise error.Abort(
85 _('cannot push more than one head to a scratch branch') 87 _(b'cannot push more than one head to a scratch branch')
86 ) 88 )
87 89
88 90
89 def _handlelfs(repo, missing): 91 def _handlelfs(repo, missing):
90 '''Special case if lfs is enabled 92 '''Special case if lfs is enabled
91 93
92 If lfs is enabled then we need to call prepush hook 94 If lfs is enabled then we need to call prepush hook
93 to make sure large files are uploaded to lfs 95 to make sure large files are uploaded to lfs
94 ''' 96 '''
95 try: 97 try:
96 lfsmod = extensions.find('lfs') 98 lfsmod = extensions.find(b'lfs')
97 lfsmod.wrapper.uploadblobsfromrevs(repo, missing) 99 lfsmod.wrapper.uploadblobsfromrevs(repo, missing)
98 except KeyError: 100 except KeyError:
99 # Ignore if lfs extension is not enabled 101 # Ignore if lfs extension is not enabled
100 return 102 return
101 103