author | Martin von Zweigbergk <martinvonz@google.com> |
Fri, 06 Mar 2020 14:35:35 -0800 | |
changeset 5258 | bd443b8237aa |
parent 4814 | 48b30ff742cb |
permissions | -rw-r--r-- |
660
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1 |
'''enable experimental obsolescence feature of Mercurial |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
2 |
|
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 |
OBSOLESCENCE IS AN EXPERIMENTAL FEATURE MAKE SURE YOU UNDERSTOOD THE INVOLVED |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 |
CONCEPT BEFORE USING IT. |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
5 |
|
4235
e30119dfd626
style: fix various flake8 warning
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3510
diff
changeset
|
6 |
! THIS EXTENSION IS INTENDED FOR SERVER SIDE ONLY USAGE ! |
660
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
7 |
|
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
8 |
For client side usages it is recommended to use the evolve extension for |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
9 |
improved user interface.''' |
e6e47c432ffd
hgext: add a simpler extension to enable obsolete on server
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
10 |
|
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
11 |
from __future__ import absolute_import |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
12 |
|
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
13 |
import sys |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
14 |
import os |
1837
c8b07459c9bb
serveronly: clean up imports
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1808
diff
changeset
|
15 |
|
3149
79a926b557f1
compat: drop support for older exchange protocol
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
16 |
from mercurial import obsolete |
79a926b557f1
compat: drop support for older exchange protocol
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3080
diff
changeset
|
17 |
|
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
18 |
try: |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
19 |
from . import ( |
2541
383efcb9ed0f
serveronly: also backport the fixes from 5adb8bdb935e
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2331
diff
changeset
|
20 |
compat, |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
21 |
exthelper, |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
22 |
metadata, |
2331
d49f376598f8
serveronly: also enable the obscache for server only setting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2276
diff
changeset
|
23 |
obscache, |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
24 |
obsexchange, |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
25 |
) |
4760
7e034d44bd4b
py3: also catch ImportError when relative import fails
Martin von Zweigbergk <martinvonz@google.com>
parents:
4744
diff
changeset
|
26 |
except (ValueError, ImportError) as exc: |
7e034d44bd4b
py3: also catch ImportError when relative import fails
Martin von Zweigbergk <martinvonz@google.com>
parents:
4744
diff
changeset
|
27 |
if (isinstance(exc, ValueError) |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
28 |
and str(exc) != b'Attempted relative import in non-package'): |
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
29 |
raise |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
30 |
# extension imported using direct path |
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
31 |
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
32 |
from evolve import ( |
2541
383efcb9ed0f
serveronly: also backport the fixes from 5adb8bdb935e
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2331
diff
changeset
|
33 |
compat, |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
34 |
exthelper, |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
35 |
metadata, |
2331
d49f376598f8
serveronly: also enable the obscache for server only setting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2276
diff
changeset
|
36 |
obscache, |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
37 |
obsexchange, |
2050
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
38 |
) |
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
39 |
|
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
40 |
__version__ = metadata.__version__ |
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
41 |
testedwith = metadata.testedwith |
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
42 |
minimumhgversion = metadata.minimumhgversion |
604ecce27969
serveronly: use the same extensions metadata than evolve
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2047
diff
changeset
|
43 |
buglink = metadata.buglink |
2047
ce39d0f9976d
serveronly: give the sub extension a way to access to the 'evolve' module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2032
diff
changeset
|
44 |
|
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
45 |
eh = exthelper.exthelper() |
2541
383efcb9ed0f
serveronly: also backport the fixes from 5adb8bdb935e
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2331
diff
changeset
|
46 |
eh.merge(compat.eh) |
2331
d49f376598f8
serveronly: also enable the obscache for server only setting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2276
diff
changeset
|
47 |
eh.merge(obscache.eh) |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
48 |
eh.merge(obsexchange.eh) |
4321
00d1963f50e5
exthelper: remove '_' in final_xxx() function names to conform to hg style
Matt Harbison <matt_harbison@yahoo.com>
parents:
4235
diff
changeset
|
49 |
uisetup = eh.finaluisetup |
00d1963f50e5
exthelper: remove '_' in final_xxx() function names to conform to hg style
Matt Harbison <matt_harbison@yahoo.com>
parents:
4235
diff
changeset
|
50 |
extsetup = eh.finalextsetup |
00d1963f50e5
exthelper: remove '_' in final_xxx() function names to conform to hg style
Matt Harbison <matt_harbison@yahoo.com>
parents:
4235
diff
changeset
|
51 |
reposetup = eh.finalreposetup |
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
52 |
cmdtable = eh.cmdtable |
3080
461c9d940519
evolve: registed configitems if available
Boris Feld <boris.feld@octobus.net>
parents:
2541
diff
changeset
|
53 |
configtable = eh.configtable |
1245
580a8f5ea462
discovery: port the new hashing version to simple4server
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1097
diff
changeset
|
54 |
|
2061
302aa8bbb3af
exchange: dispatch all code in 'serveronly' to the appropriate submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2060
diff
changeset
|
55 |
@eh.reposetup |
2276
2d55ae0d6ce7
serveronly: fix reposetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2275
diff
changeset
|
56 |
def default2evolution(ui, repo): |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
57 |
evolveopts = repo.ui.configlist(b'experimental', b'evolution') |
1215
004e21b8d67b
server4simple: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1097
diff
changeset
|
58 |
if not evolveopts: |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
59 |
evolveopts = b'all' |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
60 |
repo.ui.setconfig(b'experimental', b'evolution', evolveopts) |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
61 |
if obsolete.isenabled(repo, b'exchange'): |
3510
3bd642f11313
legacy: respect explicit config for server.bundle1
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3185
diff
changeset
|
62 |
# if no config explicitly set, disable bundle1 |
4814
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
63 |
if not isinstance(repo.ui.config(b'server', b'bundle1'), bytes): |
48b30ff742cb
python3: use format-source to run byteify-strings in .py files
Raphaël Gomès <rgomes@octobus.net>
parents:
4760
diff
changeset
|
64 |
repo.ui.setconfig(b'server', b'bundle1', False) |