Show More
@@ -1982,40 +1982,55 b' def handlepushkey(op, inpart):' | |||||
1982 | def handlebookmark(op, inpart): |
|
1982 | def handlebookmark(op, inpart): | |
1983 | """transmit bookmark information |
|
1983 | """transmit bookmark information | |
1984 |
|
1984 | |||
1985 |
The part contains binary encoded bookmark information. |
|
1985 | The part contains binary encoded bookmark information. | |
1986 | information is applied as is to the unbundling repository. Make sure a |
|
1986 | ||
1987 | 'check:bookmarks' part is issued earlier to check for race condition in |
|
1987 | The exact behavior of this part can be controlled by the 'bookmarks' mode | |
1988 | such update. |
|
1988 | on the bundle operation. | |
1989 |
|
1989 | |||
1990 | This behavior is suitable for pushing. Semantic adjustment will be needed |
|
1990 | When mode is 'apply' (the default) the bookmark information is applied as | |
1991 | for pull. |
|
1991 | is to the unbundling repository. Make sure a 'check:bookmarks' part is | |
|
1992 | issued earlier to check for push races in such update. This behavior is | |||
|
1993 | suitable for pushing. | |||
|
1994 | ||||
|
1995 | When mode is 'records', the information is recorded into the 'bookmarks' | |||
|
1996 | records of the bundle operation. This behavior is suitable for pulling. | |||
1992 | """ |
|
1997 | """ | |
1993 | changes = bookmarks.binarydecode(inpart) |
|
1998 | changes = bookmarks.binarydecode(inpart) | |
1994 |
|
1999 | |||
1995 | tr = op.gettransaction() |
|
2000 | pushkeycompat = op.repo.ui.configbool('server', 'bookmarks-pushkey-compat') | |
1996 | bookstore = op.repo._bookmarks |
|
2001 | bookmarksmode = op.modes.get('bookmarks', 'apply') | |
1997 |
|
2002 | |||
1998 | pushkeycompat = op.repo.ui.configbool('server', 'bookmarks-pushkey-compat') |
|
2003 | if bookmarksmode == 'apply': | |
1999 | if pushkeycompat: |
|
2004 | tr = op.gettransaction() | |
2000 | allhooks = [] |
|
2005 | bookstore = op.repo._bookmarks | |
|
2006 | if pushkeycompat: | |||
|
2007 | allhooks = [] | |||
|
2008 | for book, node in changes: | |||
|
2009 | hookargs = tr.hookargs.copy() | |||
|
2010 | hookargs['pushkeycompat'] = '1' | |||
|
2011 | hookargs['namespace'] = 'bookmark' | |||
|
2012 | hookargs['key'] = book | |||
|
2013 | hookargs['old'] = nodemod.hex(bookstore.get(book, '')) | |||
|
2014 | hookargs['new'] = nodemod.hex(node if node is not None else '') | |||
|
2015 | allhooks.append(hookargs) | |||
|
2016 | ||||
|
2017 | for hookargs in allhooks: | |||
|
2018 | op.repo.hook('prepushkey', throw=True, **hookargs) | |||
|
2019 | ||||
|
2020 | bookstore.applychanges(op.repo, op.gettransaction(), changes) | |||
|
2021 | ||||
|
2022 | if pushkeycompat: | |||
|
2023 | def runhook(): | |||
|
2024 | for hookargs in allhooks: | |||
|
2025 | op.repo.hook('prepushkey', **hookargs) | |||
|
2026 | op.repo._afterlock(runhook) | |||
|
2027 | ||||
|
2028 | elif bookmarksmode == 'records': | |||
2001 | for book, node in changes: |
|
2029 | for book, node in changes: | |
2002 | hookargs = tr.hookargs.copy() |
|
2030 | record = {'bookmark': book, 'node': node} | |
2003 | hookargs['pushkeycompat'] = '1' |
|
2031 | op.records.add('bookmarks', record) | |
2004 | hookargs['namespace'] = 'bookmark' |
|
2032 | else: | |
2005 | hookargs['key'] = book |
|
2033 | raise error.ProgrammingError('unkown bookmark mode: %s' % bookmarksmode) | |
2006 | hookargs['old'] = nodemod.hex(bookstore.get(book, '')) |
|
|||
2007 | hookargs['new'] = nodemod.hex(node if node is not None else '') |
|
|||
2008 | allhooks.append(hookargs) |
|
|||
2009 | for hookargs in allhooks: |
|
|||
2010 | op.repo.hook('prepushkey', throw=True, **hookargs) |
|
|||
2011 |
|
||||
2012 | bookstore.applychanges(op.repo, tr, changes) |
|
|||
2013 |
|
||||
2014 | if pushkeycompat: |
|
|||
2015 | def runhook(): |
|
|||
2016 | for hookargs in allhooks: |
|
|||
2017 | op.repo.hook('prepushkey', **hookargs) |
|
|||
2018 | op.repo._afterlock(runhook) |
|
|||
2019 |
|
2034 | |||
2020 | @parthandler('phase-heads') |
|
2035 | @parthandler('phase-heads') | |
2021 | def handlephases(op, inpart): |
|
2036 | def handlephases(op, inpart): |
General Comments 0
You need to be logged in to leave comments.
Login now