Mercurial > hg
comparison mercurial/bundle2.py @ 35261:f392066d127c
bookmark: add pushkey hook compatiblity to the bundle2 part
Currently, pushing a bookmark update triggers a pushkey hooks. It is likely
that users in the wild use such hooks to control bookmark movement. Using a non
push-key mechanism to exchange bookmark means these hooks are no longer called,
possibly breaking existing users setup. So we add explicit call to the pushkey
hooks in the handling of the bundle2 part. This behavior can be disabled with a
new config knob: 'server.bookmarks-pushkey-compat'.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Tue, 17 Oct 2017 12:07:24 +0200 |
parents | af5507203d01 |
children | 1f30cbac34b6 |
comparison
equal
deleted
inserted
replaced
35260:af5507203d01 | 35261:f392066d127c |
---|---|
1987 | 1987 |
1988 This behavior is suitable for pushing. Semantic adjustment will be needed | 1988 This behavior is suitable for pushing. Semantic adjustment will be needed |
1989 for pull. | 1989 for pull. |
1990 """ | 1990 """ |
1991 changes = bookmarks.binarydecode(inpart) | 1991 changes = bookmarks.binarydecode(inpart) |
1992 op.repo._bookmarks.applychanges(op.repo, op.gettransaction(), changes) | 1992 |
1993 tr = op.gettransaction() | |
1994 bookstore = op.repo._bookmarks | |
1995 | |
1996 pushkeycompat = op.repo.ui.configbool('server', 'bookmarks-pushkey-compat') | |
1997 if pushkeycompat: | |
1998 allhooks = [] | |
1999 for book, node in changes: | |
2000 hookargs = tr.hookargs.copy() | |
2001 hookargs['pushkeycompat'] = '1' | |
2002 hookargs['namespace'] = 'bookmark' | |
2003 hookargs['key'] = book | |
2004 hookargs['old'] = nodemod.hex(bookstore.get(book, '')) | |
2005 hookargs['new'] = nodemod.hex(node if node is not None else '') | |
2006 allhooks.append(hookargs) | |
2007 for hookargs in allhooks: | |
2008 op.repo.hook('prepushkey', throw=True, **hookargs) | |
2009 | |
2010 bookstore.applychanges(op.repo, tr, changes) | |
2011 | |
2012 if pushkeycompat: | |
2013 def runhook(): | |
2014 for hookargs in allhooks: | |
2015 op.repo.hook('prepushkey', **hookargs) | |
2016 op.repo._afterlock(runhook) | |
1993 | 2017 |
1994 @parthandler('phase-heads') | 2018 @parthandler('phase-heads') |
1995 def handlephases(op, inpart): | 2019 def handlephases(op, inpart): |
1996 """apply phases from bundle part to repo""" | 2020 """apply phases from bundle part to repo""" |
1997 headsbyphase = phases.binarydecode(inpart) | 2021 headsbyphase = phases.binarydecode(inpart) |