Comments
Patch
new file mode 100644
@@ -0,0 +1,48 @@
+# compat.py - handlign compatibility settings
+#
+# Copyright 2005-2017 Mercurial Steering Committee
+#
+# 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
+
+import collections
+from . import (
+ util,
+)
+
+# The initialization msut be done with a list and not a dict, as a list
+# is sorted while a dictionary is not.
+COMPAT = util.sortdict([
+ ('latest', {
+ 'diff': {
+ 'git': 'True',
+ 'showfunc': 'True',
+ },
+ 'ui': {
+ 'color': 'auto',
+ 'interface': 'curses',
+ },
+ })],
+)
+
+def modernize(ui):
+ compats = compatlevel(ui)
+ for section, d in compats.items():
+ for key, value in d.items():
+ ui._cfg['defaults'].set(section, key, value)
+
+def compatlevel(ui):
+ if ui.plain('compat'):
+ requested = 'compat'
+ else:
+ requested = ui.config('ui', 'compat', 'compat')
+
+ result = {}
+ for level, configs in COMPAT.items():
+ result.update(configs)
+ if level == requested:
+ # defaults is sorted. We can abort once we reached
+ # the requested level.
+ break
+ return result