##// END OF EJS Templates
bookmark: use the 'bookmarks' bundle2 part to push bookmark update (issue5165)...
Boris Feld -
r35265:a1e70c1d default
parent child Browse files
Show More
@@ -897,9 +897,45 b' def _pushb2bookmarks(pushop, bundler):'
897 if 'bookmarks' in pushop.stepsdone:
897 if 'bookmarks' in pushop.stepsdone:
898 return
898 return
899 b2caps = bundle2.bundle2caps(pushop.remote)
899 b2caps = bundle2.bundle2caps(pushop.remote)
900 if 'pushkey' in b2caps:
900
901 legacy = pushop.repo.ui.configlist('devel', 'legacy.exchange')
902 legacybooks = 'bookmarks' in legacy
903
904 if not legacybooks and 'bookmarks' in b2caps:
905 return _pushb2bookmarkspart(pushop, bundler)
906 elif 'pushkey' in b2caps:
901 return _pushb2bookmarkspushkey(pushop, bundler)
907 return _pushb2bookmarkspushkey(pushop, bundler)
902
908
909 def _bmaction(old, new):
910 """small utility for bookmark pushing"""
911 if not old:
912 return 'export'
913 elif not new:
914 return 'delete'
915 return 'update'
916
917 def _pushb2bookmarkspart(pushop, bundler):
918 pushop.stepsdone.add('bookmarks')
919 if not pushop.outbookmarks:
920 return
921
922 allactions = []
923 data = []
924 for book, old, new in pushop.outbookmarks:
925 new = bin(new)
926 data.append((book, new))
927 allactions.append((book, _bmaction(old, new)))
928 checkdata = bookmod.binaryencode(data)
929 bundler.newpart('bookmarks', data=checkdata)
930
931 def handlereply(op):
932 ui = pushop.ui
933 # if success
934 for book, action in allactions:
935 ui.status(bookmsgmap[action][0] % book)
936
937 return handlereply
938
903 def _pushb2bookmarkspushkey(pushop, bundler):
939 def _pushb2bookmarkspushkey(pushop, bundler):
904 pushop.stepsdone.add('bookmarks')
940 pushop.stepsdone.add('bookmarks')
905 part2book = []
941 part2book = []
@@ -1,4 +1,12 b''
1 #testcases b2-pushkey b2-binary
1 #testcases b2-pushkey b2-binary
2
3 #if b2-pushkey
4 $ cat << EOF >> $HGRCPATH
5 > [devel]
6 > legacy.exchange=bookmarks
7 > EOF
8 #endif
9
2 #require serve
10 #require serve
3
11
4 $ cat << EOF >> $HGRCPATH
12 $ cat << EOF >> $HGRCPATH
@@ -250,10 +258,11 b' delete a remote bookmark'
250 bundle2-output: header chunk size: 19
258 bundle2-output: header chunk size: 19
251 bundle2-output: payload chunk size: 48
259 bundle2-output: payload chunk size: 48
252 bundle2-output: closing payload chunk
260 bundle2-output: closing payload chunk
253 bundle2-output: bundle part: "pushkey"
261 bundle2-output: bundle part: "bookmarks"
254 bundle2-output-part: "pushkey" (params: 4 mandatory) empty payload
262 bundle2-output-part: "bookmarks" 23 bytes payload
255 bundle2-output: part 3: "PUSHKEY"
263 bundle2-output: part 3: "BOOKMARKS"
256 bundle2-output: header chunk size: 90
264 bundle2-output: header chunk size: 16
265 bundle2-output: payload chunk size: 23
257 bundle2-output: closing payload chunk
266 bundle2-output: closing payload chunk
258 bundle2-output: end of bundle
267 bundle2-output: end of bundle
259 bundle2-input: start processing of HG20 stream
268 bundle2-input: start processing of HG20 stream
@@ -287,40 +296,29 b' delete a remote bookmark'
287 bundle2-input: payload chunk size: 48
296 bundle2-input: payload chunk size: 48
288 bundle2-input: payload chunk size: 0
297 bundle2-input: payload chunk size: 0
289 bundle2-input-part: total payload size 48
298 bundle2-input-part: total payload size 48
290 bundle2-input: part header size: 90
299 bundle2-input: part header size: 16
291 bundle2-input: part type: "PUSHKEY"
300 bundle2-input: part type: "BOOKMARKS"
292 bundle2-input: part id: "3"
301 bundle2-input: part id: "3"
293 bundle2-input: part parameters: 4
302 bundle2-input: part parameters: 0
294 bundle2-input: found a handler for part pushkey
303 bundle2-input: found a handler for part bookmarks
295 bundle2-input-part: "pushkey" (params: 4 mandatory) supported
304 bundle2-input-part: "bookmarks" supported
296 pushing key for "bookmarks:W"
305 bundle2-input: payload chunk size: 23
297 bundle2-input: payload chunk size: 0
306 bundle2-input: payload chunk size: 0
307 bundle2-input-part: total payload size 23
298 bundle2-input: part header size: 0
308 bundle2-input: part header size: 0
299 bundle2-input: end of bundle2 stream
309 bundle2-input: end of bundle2 stream
300 bundle2-input-bundle: 3 parts total
310 bundle2-input-bundle: 3 parts total
301 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
311 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
302 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
312 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
303 bundle2-output-bundle: "HG20", 1 parts total
313 bundle2-output-bundle: "HG20", 0 parts total
304 bundle2-output: start emission of HG20 stream
314 bundle2-output: start emission of HG20 stream
305 bundle2-output: bundle parameter:
315 bundle2-output: bundle parameter:
306 bundle2-output: start of parts
316 bundle2-output: start of parts
307 bundle2-output: bundle part: "reply:pushkey"
308 bundle2-output-part: "reply:pushkey" (params: 0 advisory) empty payload
309 bundle2-output: part 0: "REPLY:PUSHKEY"
310 bundle2-output: header chunk size: 43
311 bundle2-output: closing payload chunk
312 bundle2-output: end of bundle
317 bundle2-output: end of bundle
313 bundle2-input: start processing of HG20 stream
318 bundle2-input: start processing of HG20 stream
314 bundle2-input: reading bundle2 stream parameters
319 bundle2-input: reading bundle2 stream parameters
315 bundle2-input-bundle: no-transaction
320 bundle2-input-bundle: no-transaction
316 bundle2-input: start extraction of bundle2 parts
321 bundle2-input: start extraction of bundle2 parts
317 bundle2-input: part header size: 43
318 bundle2-input: part type: "REPLY:PUSHKEY"
319 bundle2-input: part id: "0"
320 bundle2-input: part parameters: 2
321 bundle2-input: found a handler for part reply:pushkey
322 bundle2-input-part: "reply:pushkey" (params: 0 advisory) supported
323 bundle2-input: payload chunk size: 0
324 bundle2-input: part header size: 0
322 bundle2-input: part header size: 0
325 bundle2-input: end of bundle2 stream
323 bundle2-input: end of bundle2 stream
326 bundle2-input-bundle: 0 parts total
324 bundle2-input-bundle: 0 parts total
@@ -1088,8 +1086,7 b' Local push'
1088 pushing to $TESTTMP/issue4455-dest (glob)
1086 pushing to $TESTTMP/issue4455-dest (glob)
1089 searching for changes
1087 searching for changes
1090 no changes found
1088 no changes found
1091 pushkey-abort: prepushkey hook exited with status 1
1089 abort: prepushkey hook exited with status 1
1092 abort: exporting bookmark @ failed!
1093 [255]
1090 [255]
1094
1091
1095 #endif
1092 #endif
@@ -1128,8 +1125,8 b' Using ssh'
1128 pushing to ssh://user@dummy/issue4455-dest
1125 pushing to ssh://user@dummy/issue4455-dest
1129 searching for changes
1126 searching for changes
1130 no changes found
1127 no changes found
1131 remote: pushkey-abort: prepushkey hook exited with status 1
1128 remote: prepushkey hook exited with status 1
1132 abort: exporting bookmark @ failed!
1129 abort: push failed on remote
1133 [255]
1130 [255]
1134
1131
1135 #endif
1132 #endif
@@ -1168,8 +1165,8 b' Using http'
1168 pushing to ssh://user@dummy/issue4455-dest
1165 pushing to ssh://user@dummy/issue4455-dest
1169 searching for changes
1166 searching for changes
1170 no changes found
1167 no changes found
1171 remote: pushkey-abort: prepushkey hook exited with status 1
1168 remote: prepushkey hook exited with status 1
1172 abort: exporting bookmark @ failed!
1169 abort: push failed on remote
1173 [255]
1170 [255]
1174
1171
1175 #endif
1172 #endif
@@ -253,9 +253,6 b' push'
253 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
253 remote: added 1 changesets with 0 changes to 0 files (-1 heads)
254 remote: 1 new obsolescence markers
254 remote: 1 new obsolescence markers
255 remote: pre-close-tip:eea13746799a public book_eea1
255 remote: pre-close-tip:eea13746799a public book_eea1
256 remote: pushkey: lock state after "bookmarks"
257 remote: lock: free
258 remote: wlock: free
259 remote: postclose-tip:eea13746799a public book_eea1
256 remote: postclose-tip:eea13746799a public book_eea1
260 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_NODE_LAST=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/other
257 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_NODE_LAST=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/other
261 updating bookmark book_eea1
258 updating bookmark book_eea1
@@ -339,9 +336,6 b' push over ssh'
339 remote: added 1 changesets with 1 changes to 1 files
336 remote: added 1 changesets with 1 changes to 1 files
340 remote: 1 new obsolescence markers
337 remote: 1 new obsolescence markers
341 remote: pre-close-tip:5fddd98957c8 draft book_5fdd
338 remote: pre-close-tip:5fddd98957c8 draft book_5fdd
342 remote: pushkey: lock state after "bookmarks"
343 remote: lock: free
344 remote: wlock: free
345 remote: postclose-tip:5fddd98957c8 draft book_5fdd
339 remote: postclose-tip:5fddd98957c8 draft book_5fdd
346 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_NODE_LAST=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_TXNNAME=serve HG_URL=remote:ssh:$LOCALIP
340 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_NODE_LAST=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_TXNNAME=serve HG_URL=remote:ssh:$LOCALIP
347 updating bookmark book_5fdd
341 updating bookmark book_5fdd
@@ -390,9 +384,6 b' push over http'
390 remote: added 1 changesets with 1 changes to 1 files
384 remote: added 1 changesets with 1 changes to 1 files
391 remote: 1 new obsolescence markers
385 remote: 1 new obsolescence markers
392 remote: pre-close-tip:32af7686d403 public book_32af
386 remote: pre-close-tip:32af7686d403 public book_32af
393 remote: pushkey: lock state after "bookmarks"
394 remote: lock: free
395 remote: wlock: free
396 remote: postclose-tip:32af7686d403 public book_32af
387 remote: postclose-tip:32af7686d403 public book_32af
397 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=32af7686d403cf45b5d95f2d70cebea587ac806a HG_NODE_LAST=32af7686d403cf45b5d95f2d70cebea587ac806a HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_TXNNAME=serve HG_URL=remote:http:$LOCALIP: (glob)
388 remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose.env HG_HOOKTYPE=txnclose HG_NEW_OBSMARKERS=1 HG_NODE=32af7686d403cf45b5d95f2d70cebea587ac806a HG_NODE_LAST=32af7686d403cf45b5d95f2d70cebea587ac806a HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_TXNNAME=serve HG_URL=remote:http:$LOCALIP: (glob)
398 updating bookmark book_32af
389 updating bookmark book_32af
@@ -244,7 +244,6 b' pushkey hook'
244 no changes found
244 no changes found
245 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
245 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
246 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
246 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
247 pushkey hook: HG_HOOKNAME=pushkey HG_HOOKTYPE=pushkey HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
248 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
247 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
249 exporting bookmark foo
248 exporting bookmark foo
250 [1]
249 [1]
@@ -281,9 +280,8 b' test that prepushkey can prevent incomin'
281 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
280 listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
282 no changes found
281 no changes found
283 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
282 pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
284 prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
283 prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmark HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
285 pushkey-abort: prepushkey hook exited with status 1
284 abort: prepushkey hook exited with status 1
286 abort: exporting bookmark baz failed!
287 [255]
285 [255]
288 $ cd ../a
286 $ cd ../a
289
287
General Comments 0
You need to be logged in to leave comments. Login now