mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
8a3a99ba21
Summary: Be a better citizen under system python path. Fix all tests issues and change setup.py to use glob pattern to include all extensions. Test Plan: Run tests and `make local`. Also build and install the package and run `hg sl` in major repos. Reviewers: #mercurial, ttung, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, durham, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3534311 Signature: t1:3534311:1468275426:fe122646c8bd6c541e1889e73e9df28f86747ff2
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
# bundle2hooks.py - fix bundle2's support for hooks prior to lock acquisition.
|
|
#
|
|
# Copyright 2012 Facebook
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
'''Hooks arguments are typically stored on the transaction object. However, we
|
|
may want to add hooks arguments without starting a transaction. This allows us
|
|
to queue hook arguments on the bundle2 operation object.
|
|
|
|
'''
|
|
|
|
from mercurial import bundle2
|
|
from mercurial import error
|
|
from mercurial.i18n import _
|
|
|
|
from extutil import replaceclass
|
|
|
|
def reposetup(ui, repo):
|
|
@replaceclass(bundle2, 'bundleoperation')
|
|
class bundleoperationhooked(bundle2.bundleoperation):
|
|
def __init__(self, repo, transactiongetter, *args, **kwargs):
|
|
def gettransaction():
|
|
transaction = transactiongetter()
|
|
|
|
if self.hookargs is not None:
|
|
# the ones added to the transaction supercede those added
|
|
# to the operation.
|
|
self.hookargs.update(transaction.hookargs)
|
|
transaction.hookargs = self.hookargs
|
|
|
|
# mark the hookargs as flushed. further attempts to add to
|
|
# hookargs will result in an abort.
|
|
self.hookargs = None
|
|
|
|
return transaction
|
|
|
|
super(bundleoperationhooked, self).__init__(repo, gettransaction,
|
|
*args, **kwargs)
|
|
|
|
self.hookargs = {}
|
|
|
|
def addhookargs(self, hookargs):
|
|
if self.hookargs is None:
|
|
raise error.Abort(
|
|
_('attempted to add hooks to operation after transaction '
|
|
'started'))
|
|
self.hookargs.update(hookargs)
|