diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py index af5507203d01d76ccb1d9ec04b1c9827d6017be9_bWVyY3VyaWFsL2J1bmRsZTIucHk=..f392066d127ca624275f7e3bcbabc2ce07ff0164_bWVyY3VyaWFsL2J1bmRsZTIucHk= 100644 --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1989,7 +1989,31 @@ for pull. """ changes = bookmarks.binarydecode(inpart) - op.repo._bookmarks.applychanges(op.repo, op.gettransaction(), changes) + + tr = op.gettransaction() + bookstore = op.repo._bookmarks + + pushkeycompat = op.repo.ui.configbool('server', 'bookmarks-pushkey-compat') + if pushkeycompat: + allhooks = [] + for book, node in changes: + hookargs = tr.hookargs.copy() + hookargs['pushkeycompat'] = '1' + hookargs['namespace'] = 'bookmark' + hookargs['key'] = book + hookargs['old'] = nodemod.hex(bookstore.get(book, '')) + hookargs['new'] = nodemod.hex(node if node is not None else '') + allhooks.append(hookargs) + for hookargs in allhooks: + op.repo.hook('prepushkey', throw=True, **hookargs) + + bookstore.applychanges(op.repo, tr, changes) + + if pushkeycompat: + def runhook(): + for hookargs in allhooks: + op.repo.hook('prepushkey', **hookargs) + op.repo._afterlock(runhook) @parthandler('phase-heads') def handlephases(op, inpart): diff --git a/mercurial/configitems.py b/mercurial/configitems.py index af5507203d01d76ccb1d9ec04b1c9827d6017be9_bWVyY3VyaWFsL2NvbmZpZ2l0ZW1zLnB5..f392066d127ca624275f7e3bcbabc2ce07ff0164_bWVyY3VyaWFsL2NvbmZpZ2l0ZW1zLnB5 100644 --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -841,6 +841,9 @@ coreconfigitem('push', 'pushvars.server', default=False, ) +coreconfigitem('server', 'bookmarks-pushkey-compat', + default=True, +) coreconfigitem('server', 'bundle1', default=True, ) diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt index af5507203d01d76ccb1d9ec04b1c9827d6017be9_bWVyY3VyaWFsL2hlbHAvY29uZmlnLnR4dA==..f392066d127ca624275f7e3bcbabc2ce07ff0164_bWVyY3VyaWFsL2hlbHAvY29uZmlnLnR4dA== 100644 --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1723,6 +1723,14 @@ Controls generic server settings. +``bookmarks-pushkey-compat`` + Trigger pushkey hook when being pushed bookmark updates. This config exist + for compatibility purpose (default to True) + + If you use ``pushkey`` and ``pre-pushkey`` hooks to control bookmark + movement we recommend you migrate them to ``txnclose-bookmark`` and + ``pretxnclose-bookmark``. + ``compressionengines`` List of compression engines and their relative priority to advertise to clients.