1'''enable experimental obsolescence feature of Mercurial
2
3OBSOLESCENCE IS AN EXPERIMENTAL FEATURE MAKE SURE YOU UNDERSTOOD THE INVOLVED
4CONCEPT BEFORE USING IT.
5
6! THIS EXTENSION IS INTENDED FOR SERVER SIDE ONLY USAGE !
7
8For client side usages it is recommended to use the evolve extension for
9improved user interface.'''
10
11from __future__ import absolute_import
12
13import sys
14import os
15
16from mercurial import obsolete
17
18try:
19    from . import (
20        compat,
21        exthelper,
22        metadata,
23        obscache,
24        obsexchange,
25    )
26except (ValueError, ImportError) as exc:
27    if (isinstance(exc, ValueError)
28        and str(exc) != b'Attempted relative import in non-package'):
29        raise
30    # extension imported using direct path
31    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
32    from evolve import (
33        compat,
34        exthelper,
35        metadata,
36        obscache,
37        obsexchange,
38    )
39
40__version__ = metadata.__version__
41testedwith = metadata.testedwith
42minimumhgversion = metadata.minimumhgversion
43buglink = metadata.buglink
44
45eh = exthelper.exthelper()
46eh.merge(compat.eh)
47eh.merge(obscache.eh)
48eh.merge(obsexchange.eh)
49uisetup = eh.finaluisetup
50extsetup = eh.finalextsetup
51reposetup = eh.finalreposetup
52cmdtable = eh.cmdtable
53configtable = eh.configtable
54
55@eh.reposetup
56def default2evolution(ui, repo):
57    evolveopts = repo.ui.configlist(b'experimental', b'evolution')
58    if not evolveopts:
59        evolveopts = b'all'
60        repo.ui.setconfig(b'experimental', b'evolution', evolveopts, b'evolve')
61    if obsolete.isenabled(repo, b'exchange'):
62        # if no config explicitly set, disable bundle1
63        if not isinstance(repo.ui.config(b'server', b'bundle1'), bytes):
64            repo.ui.setconfig(b'server', b'bundle1', False, b'evolve')
65