##// END OF EJS Templates
strip: add a delayedstrip method that works in a transaction...
strip: add a delayedstrip method that works in a transaction For long, the fact that strip does not work inside a transaction and some code has to work with both obsstore and fallback to strip lead to duplicated code like: with repo.transaction(): .... if obsstore: obsstore.createmarkers(...) if not obsstore: repair.strip(...) Things get more complex when you want to call something which may call strip under the hood. Like you cannot simply write: with repo.transaction(): .... rebasemod.rebase(...) # may call "strip", so this doesn't work But you do want rebase to run inside a same transaction if possible, so the code may look like: with repo.transaction(): .... if obsstore: rebasemod.rebase(...) obsstore.createmarkers(...) if not obsstore: rebasemod.rebase(...) repair.strip(...) That's ugly and error-prone. Ideally it's possible to just write: with repo.transaction(): rebasemod.rebase(...) saferemovenodes(...) This patch is the first step towards that. It adds a "delayedstrip" method to repair.py which maintains a postclose callback in the transaction object.

File last commit:

r33061:c41cbe98 default
r33087:fcd1c483 default
Show More
configitems.py
50 lines | 1.3 KiB | text/x-python | PythonLexer
# configitems.py - centralized declaration of configuration option
#
# Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from . import (
error,
)
class configitem(object):
"""represent a known config item
:section: the official config section where to find this item,
:name: the official name within the section,
:default: default value for this item,
"""
def __init__(self, section, name, default=None):
self.section = section
self.name = name
self.default = default
coreitems = {}
def coreconfigitem(*args, **kwargs):
item = configitem(*args, **kwargs)
section = coreitems.setdefault(item.section, {})
if item.name in section:
msg = "duplicated config item registration for '%s.%s'"
raise error.ProgrammingError(msg % (item.section, item.name))
section[item.name] = item
# Registering actual config items
coreconfigitem('patch', 'fuzz',
default=2,
)
coreconfigitem('ui', 'clonebundleprefers',
default=[],
)
coreconfigitem('ui', 'interactive',
default=None,
)
coreconfigitem('ui', 'quiet',
default=False,
)