##// END OF EJS Templates
infinitepush: drop the scratchbookmarksparttype bundle2 part...
Pulkit Goyal -
r37210:5a9692d0 default
parent child Browse files
Show More
@@ -91,13 +91,11 b' import collections'
91 91 import contextlib
92 92 import errno
93 93 import functools
94 import json
95 94 import logging
96 95 import os
97 96 import random
98 97 import re
99 98 import socket
100 import struct
101 99 import subprocess
102 100 import sys
103 101 import tempfile
@@ -682,19 +680,6 b' def _lookupwrap(orig):'
682 680 return "%s %s\n" % (0, r)
683 681 return _lookup
684 682
685 def _decodebookmarks(stream):
686 sizeofjsonsize = struct.calcsize('>i')
687 size = struct.unpack('>i', stream.read(sizeofjsonsize))[0]
688 unicodedict = json.loads(stream.read(size))
689 # python json module always returns unicode strings. We need to convert
690 # it back to bytes string
691 result = {}
692 for bookmark, node in unicodedict.iteritems():
693 bookmark = bookmark.encode('ascii')
694 node = node.encode('ascii')
695 result[bookmark] = node
696 return result
697
698 683 def _update(orig, ui, repo, node=None, rev=None, **opts):
699 684 if rev and node:
700 685 raise error.Abort(_("please specify just one revision"))
@@ -985,7 +970,6 b' def partgen(pushop, bundler):'
985 970 return handlereply
986 971
987 972 bundle2.capabilities[bundleparts.scratchbranchparttype] = ()
988 bundle2.capabilities[bundleparts.scratchbookmarksparttype] = ()
989 973
990 974 def _getrevs(bundle, oldnode, force, bookmark):
991 975 'extracts and validates the revs to be imported'
@@ -1059,7 +1043,6 b' def processparts(orig, repo, op, unbundl'
1059 1043
1060 1044 bundler = bundle2.bundle20(repo.ui)
1061 1045 cgparams = None
1062 scratchbookpart = None
1063 1046 with bundle2.partiterator(repo, op, unbundler) as parts:
1064 1047 for part in parts:
1065 1048 bundlepart = None
@@ -1084,14 +1067,6 b' def processparts(orig, repo, op, unbundl'
1084 1067 op.records.add(scratchbranchparttype + '_skippushkey', True)
1085 1068 op.records.add(scratchbranchparttype + '_skipphaseheads',
1086 1069 True)
1087 elif part.type == bundleparts.scratchbookmarksparttype:
1088 # Save this for later processing. Details below.
1089 #
1090 # Upstream https://phab.mercurial-scm.org/D1389 and its
1091 # follow-ups stop part.seek support to reduce memory usage
1092 # (https://bz.mercurial-scm.org/5691). So we need to copy
1093 # the part so it can be consumed later.
1094 scratchbookpart = bundleparts.copiedpart(part)
1095 1070 else:
1096 1071 if handleallparts or part.type in partforwardingwhitelist:
1097 1072 # Ideally we would not process any parts, and instead just
@@ -1137,12 +1112,6 b' def processparts(orig, repo, op, unbundl'
1137 1112 # we would rather see the original exception
1138 1113 pass
1139 1114
1140 # The scratch bookmark part is sent as part of a push backup. It needs to be
1141 # processed after the main bundle has been stored, so that any commits it
1142 # references are available in the store.
1143 if scratchbookpart:
1144 bundle2._processpart(op, scratchbookpart)
1145
1146 1115 def storebundle(op, params, bundlefile):
1147 1116 log = _getorcreateinfinitepushlogger(op)
1148 1117 parthandlerstart = time.time()
@@ -1269,26 +1238,6 b' def bundle2scratchbranch(op, part):'
1269 1238
1270 1239 return 1
1271 1240
1272 @bundle2.parthandler(bundleparts.scratchbookmarksparttype)
1273 def bundle2scratchbookmarks(op, part):
1274 '''Handler deletes bookmarks first then adds new bookmarks.
1275 '''
1276 index = op.repo.bundlestore.index
1277 decodedbookmarks = _decodebookmarks(part)
1278 toinsert = {}
1279 todelete = []
1280 for bookmark, node in decodedbookmarks.iteritems():
1281 if node:
1282 toinsert[bookmark] = node
1283 else:
1284 todelete.append(bookmark)
1285 log = _getorcreateinfinitepushlogger(op)
1286 with logservicecall(log, bundleparts.scratchbookmarksparttype), index:
1287 if todelete:
1288 index.deletebookmarks(todelete)
1289 if toinsert:
1290 index.addmanybookmarks(toinsert)
1291
1292 1241 def _maybeaddpushbackpart(op, bookmark, newnode, oldnode, params):
1293 1242 if params.get('pushbackbookmarks'):
1294 1243 if op.reply and 'pushback' in op.reply.capabilities:
@@ -18,11 +18,9 b' from mercurial import ('
18 18
19 19 from . import common
20 20
21 encodebookmarks = common.encodebookmarks
22 21 isremotebooksenabled = common.isremotebooksenabled
23 22
24 23 scratchbranchparttype = 'b2x:infinitepush'
25 scratchbookmarksparttype = 'b2x:infinitepushscratchbookmarks'
26 24
27 25 def getscratchbranchparts(repo, peer, outgoing, confignonforwardmove,
28 26 ui, bookmark, create):
@@ -85,15 +83,6 b' def getscratchbranchparts(repo, peer, ou'
85 83
86 84 return parts
87 85
88 def getscratchbookmarkspart(peer, bookmarks):
89 if scratchbookmarksparttype not in bundle2.bundle2caps(peer):
90 raise error.Abort(
91 _('no server support for %r') % scratchbookmarksparttype)
92
93 return bundle2.bundlepart(
94 scratchbookmarksparttype.upper(),
95 data=encodebookmarks(bookmarks))
96
97 86 def _validaterevset(repo, revset, bookmark):
98 87 """Abort if the revs to be pushed aren't valid for a scratch branch."""
99 88 if not repo.revs(revset):
@@ -5,9 +5,7 b''
5 5
6 6 from __future__ import absolute_import
7 7
8 import json
9 8 import os
10 import struct
11 9 import tempfile
12 10
13 11 from mercurial.node import hex
@@ -21,14 +19,6 b' def isremotebooksenabled(ui):'
21 19 return ('remotenames' in extensions._extensions and
22 20 ui.configbool('remotenames', 'bookmarks'))
23 21
24 def encodebookmarks(bookmarks):
25 encoded = {}
26 for bookmark, node in bookmarks.iteritems():
27 encoded[bookmark] = node
28 dumped = json.dumps(encoded)
29 result = struct.pack('>i', len(dumped)) + dumped
30 return result
31
32 22 def downloadbundle(repo, unknownbinhead):
33 23 index = repo.bundlestore.index
34 24 store = repo.bundlestore.store
General Comments 0
You need to be logged in to leave comments. Login now