Mercurial > hg-stable
changeset 22984:e0b5f5e3afe8
histedit: move locks into state
Allow action functions to control the locks. This is necessary for
an implementation of x/exec or similar.
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Wed, 15 Oct 2014 08:38:36 -0700 |
parents | a3a981563ce8 |
children | 0c14b9166da6 |
files | hgext/histedit.py |
diffstat | 1 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Wed Oct 15 08:38:16 2014 -0700 +++ b/hgext/histedit.py Wed Oct 15 08:38:36 2014 -0700 @@ -190,12 +190,14 @@ class histeditstate(object): def __init__(self, repo, parentctx=None, rules=None, keep=None, - topmost=None, replacements=None): + topmost=None, replacements=None, lock=None, wlock=None): self.repo = repo self.rules = rules self.keep = keep self.topmost = topmost self.parentctx = parentctx + self.lock = lock + self.wlock = wlock if replacements is None: self.replacements = [] else: @@ -537,15 +539,15 @@ for intentional "edit" command, but also for resolving unexpected conflicts). """ - lock = wlock = None + state = histeditstate(repo) try: - wlock = repo.wlock() - lock = repo.lock() - _histedit(ui, repo, *freeargs, **opts) + state.wlock = repo.wlock() + state.lock = repo.lock() + _histedit(ui, repo, state, *freeargs, **opts) finally: - release(lock, wlock) + release(state.lock, state.wlock) -def _histedit(ui, repo, *freeargs, **opts): +def _histedit(ui, repo, state, *freeargs, **opts): # TODO only abort if we try and histedit mq patches, not just # blanket if mq patches are applied somewhere mq = getattr(repo, 'mq', None) @@ -660,8 +662,11 @@ parentctx = repo[root].parents()[0] - state = histeditstate(repo, parentctx, rules, keep, topmost, - replacements) + state.parentctx = parentctx + state.rules = rules + state.keep = keep + state.topmost = topmost + state.replacements = replacements while state.rules: state.write()