Commit Graph

70 Commits

Author SHA1 Message Date
Pulkit Goyal
7d16e8a210 pushvars: add a coreconfigitem for push.pushvars.server
Differential Revision: https://phab.mercurial-scm.org/D359
2017-08-12 04:47:40 +05:30
Boris Feld
7f8b0aa44f config: rename evolution config into stabilization
Use aliases for backward-compatibility. Though I'm not sure how to emit
compatibility warnings with aliases.

Test configuration are updated in the next patch.

The renaming is done according to
https://www.mercurial-scm.org/wiki/CEDVocabulary.

Differential Revision: https://phab.mercurial-scm.org/D248
2017-08-03 11:38:22 +02:00
Pulkit Goyal
3f92988eda morestatus: move fb extension to core by plugging to hg status --verbose
morestatus extension in fbext use to show more context about the state of the
repo like the repository is in a unfinished merge state, or a rebase is going
on, or histedit is going on, listing the files which need to be resolved and
also suggesting ways to handle the situation.

This patch moves the extension directly to core by plugging it into the
--verbose flag of the status command. So now if you are in any unfinished state
and you do hg status -v, it will show you details and help related to the state.

The extension in fbext also shows context about unfinished update state
which is not ported to core as that plug in hooks to update command which need
to be tackled somewhat differently.

The following configuration will turn the behaviour on by default

[commands]
status.verbose = 1

You can also skip considering some states like bisect as follows:

[commands]
status.skipstates=bisect

This patch also adds test for the feature.

.. feature::

   ``hg status -v`` can now show unfinished state. For example, when in
   an unfinished rebase state, ``hg status -v`` might show::

   # The repository is in an unfinished *rebase* state.
   # No unresolved merge conflicts.
   # To continue:                hg rebase --continue
   # To abort:                   hg rebase --abort

Differential Revision: https://phab.mercurial-scm.org/D219
2017-08-03 05:12:35 +05:30
Boris Feld
34737ca53d configitems: register the 'ui.mergemarkertemplate' config 2017-06-30 03:44:56 +02:00
Boris Feld
80b62eed4f configitems: register the 'ui.color' config 2017-07-15 14:14:53 +02:00
Boris Feld
7dff351e4d configitems: register the 'ui.forcecwd' config 2017-06-30 03:44:45 +02:00
Boris Feld
cc925277dc configitems: register the 'ui.fallbackencoding' config 2017-06-30 03:44:43 +02:00
Jun Wu
e47f7dc2fa codemod: register core configitems using a script
This is done by a script [2] using RedBaron [1], a tool designed for doing
code refactoring. All "default" values are decided by the script and are
strongly consistent with the existing code.

There are 2 changes done manually to fix tests:

  [warn] mercurial/exchange.py: experimental.bundle2-output-capture: default needs manual removal
  [warn] mercurial/localrepo.py: experimental.hook-track-tags: default needs manual removal

Since RedBaron is not confident about how to indent things [2].

[1]: https://github.com/PyCQA/redbaron
[2]: https://github.com/PyCQA/redbaron/issues/100
[3]:

#!/usr/bin/env python
# codemod_configitems.py - codemod tool to fill configitems
#
# Copyright 2017 Facebook, Inc.
#
# 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, print_function

import os
import sys

import redbaron

def readpath(path):
    with open(path) as f:
        return f.read()

def writepath(path, content):
    with open(path, 'w') as f:
        f.write(content)

_configmethods = {'config', 'configbool', 'configint', 'configbytes',
                  'configlist', 'configdate'}

def extractstring(rnode):
    """get the string from a RedBaron string or call_argument node"""
    while rnode.type != 'string':
        rnode = rnode.value
    return rnode.value[1:-1]  # unquote, "'str'" -> "str"

def uiconfigitems(red):
    """match *.ui.config* pattern, yield (node, method, args, section, name)"""
    for node in red.find_all('atomtrailers'):
        entry = None
        try:
            obj = node[-3].value
            method = node[-2].value
            args = node[-1]
            section = args[0].value
            name = args[1].value
            if (obj in ('ui', 'self') and method in _configmethods
                and section.type == 'string' and name.type == 'string'):
                entry = (node, method, args, extractstring(section),
                         extractstring(name))
        except Exception:
            pass
        else:
            if entry:
                yield entry

def coreconfigitems(red):
    """match coreconfigitem(...) pattern, yield (node, args, section, name)"""
    for node in red.find_all('atomtrailers'):
        entry = None
        try:
            args = node[1]
            section = args[0].value
            name = args[1].value
            if (node[0].value == 'coreconfigitem' and section.type == 'string'
                and name.type == 'string'):
                entry = (node, args, extractstring(section),
                         extractstring(name))
        except Exception:
            pass
        else:
            if entry:
                yield entry

def registercoreconfig(cfgred, section, name, defaultrepr):
    """insert coreconfigitem to cfgred AST

    section and name are plain string, defaultrepr is a string
    """
    # find a place to insert the "coreconfigitem" item
    entries = list(coreconfigitems(cfgred))
    for node, args, nodesection, nodename in reversed(entries):
        if (nodesection, nodename) < (section, name):
            # insert after this entry
            node.insert_after(
                'coreconfigitem(%r, %r,\n'
                '    default=%s,\n'
                ')' % (section, name, defaultrepr))
            return

def main(argv):
    if not argv:
        print('Usage: codemod_configitems.py FILES\n'
              'For example, FILES could be "{hgext,mercurial}/*/**.py"')
    dirname = os.path.dirname
    reporoot = dirname(dirname(dirname(os.path.abspath(__file__))))

    # register configitems to this destination
    cfgpath = os.path.join(reporoot, 'mercurial', 'configitems.py')
    cfgred = redbaron.RedBaron(readpath(cfgpath))

    # state about what to do
    registered = set((s, n) for n, a, s, n in coreconfigitems(cfgred))
    toregister = {} # {(section, name): defaultrepr}
    coreconfigs = set() # {(section, name)}, whether it's used in core

    # first loop: scan all files before taking any action
    for i, path in enumerate(argv):
        print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
        iscore = ('mercurial' in path) and ('hgext' not in path)
        red = redbaron.RedBaron(readpath(path))
        # find all repo.ui.config* and ui.config* calls, and collect their
        # section, name and default value information.
        for node, method, args, section, name in uiconfigitems(red):
            if section == 'web':
                # [web] section has some weirdness, ignore them for now
                continue
            defaultrepr = None
            key = (section, name)
            if len(args) == 2:
                if key in registered:
                    continue
                if method == 'configlist':
                    defaultrepr = 'list'
                elif method == 'configbool':
                    defaultrepr = 'False'
                else:
                    defaultrepr = 'None'
            elif len(args) >= 3 and (args[2].target is None or
                                     args[2].target.value == 'default'):
                # try to understand the "default" value
                dnode = args[2].value
                if dnode.type == 'name':
                    if dnode.value in {'None', 'True', 'False'}:
                        defaultrepr = dnode.value
                elif dnode.type == 'string':
                    defaultrepr = repr(dnode.value[1:-1])
                elif dnode.type in ('int', 'float'):
                    defaultrepr = dnode.value
            # inconsistent default
            if key in toregister and toregister[key] != defaultrepr:
                defaultrepr = None
            # interesting to rewrite
            if key not in registered:
                if defaultrepr is None:
                    print('[note] %s: %s.%s: unsupported default'
                          % (path, section, name))
                    registered.add(key) # skip checking it again
                else:
                    toregister[key] = defaultrepr
                    if iscore:
                        coreconfigs.add(key)

    # second loop: rewrite files given "toregister" result
    for path in argv:
        # reconstruct redbaron - trade CPU for memory
        red = redbaron.RedBaron(readpath(path))
        changed = False
        for node, method, args, section, name in uiconfigitems(red):
            key = (section, name)
            defaultrepr = toregister.get(key)
            if defaultrepr is None or key not in coreconfigs:
                continue
            if len(args) >= 3 and (args[2].target is None or
                                   args[2].target.value == 'default'):
                try:
                    del args[2]
                    changed = True
                except Exception:
                    # redbaron fails to do the rewrite due to indentation
                    # see https://github.com/PyCQA/redbaron/issues/100
                    print('[warn] %s: %s.%s: default needs manual removal'
                          % (path, section, name))
            if key not in registered:
                print('registering %s.%s' % (section, name))
                registercoreconfig(cfgred, section, name, defaultrepr)
                registered.add(key)
        if changed:
            print('updating %s' % path)
            writepath(path, red.dumps())

    if toregister:
        print('updating configitems.py')
        writepath(cfgpath, cfgred.dumps())

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
2017-07-14 14:22:40 -07:00
Boris Feld
15d613159e configitems: register the 'worker.backgroundclose' config 2017-06-30 03:45:57 +02:00
Boris Feld
3dafe93b4f configitems: register the 'progress.width' config 2017-06-30 03:44:05 +02:00
Boris Feld
98f63065b7 configitems: register the 'color.pagermode' config 2017-07-12 23:36:28 +02:00
Boris Feld
40b893532b configitems: handle case were the default value is not static
In some case, the default of one value is derived from other value. We add a
way to register them anyway and an associated devel-warning.

The registration is very naive for the moment. We might be able to have a
better way for registering each of these cases but it could be done later.
2017-07-12 23:36:10 +02:00
David Demelier
d324b7a9bf configitems: add alias support in config
Aliases define optional alternatives to existing options. For example the old
option ui.user was deprecated and replaced by ui.username. With this mechanism,
it's even possible to create an alias to an option in a different section.

Add ui.user as alias to ui.username as an example of this concept.

The old alternates principle in ui.config is removed as it was used only for
this option.
2017-07-07 08:33:10 +02:00
Pierre-Yves David
9b7f9abb76 configitems: register the 'progress.estimate' config 2017-06-30 03:44:04 +02:00
Pierre-Yves David
c4e9bb4cfa configitems: register the 'progress.clear-complete' config 2017-06-30 03:44:02 +02:00
Pierre-Yves David
6105e69e35 configitems: register the 'progress.assume-tty' config 2017-06-30 03:44:01 +02:00
Pierre-Yves David
d708a01e9b configitems: register the 'format.usestore' config 2017-06-30 03:42:30 +02:00
Pierre-Yves David
52aef201e5 configitems: register the 'format.usegeneraldelta' config 2017-06-30 03:42:29 +02:00
Pierre-Yves David
ef58ebbe2d configitems: register the 'format.usefncache' config 2017-06-30 03:42:28 +02:00
Pierre-Yves David
246ed93984 configitems: register the 'format.obsstore-version' config 2017-06-30 03:42:27 +02:00
Pierre-Yves David
d92cb450c9 configitems: register the 'format.maxchainlen' config 2017-06-30 03:42:26 +02:00
Pierre-Yves David
75e67bea8f configitems: register the 'format.manifestcachesize' config 2017-06-30 03:42:24 +02:00
Pierre-Yves David
0110bc7d63 configitems: register the 'format.generaldelta' config 2017-06-30 03:42:23 +02:00
Pierre-Yves David
66973f9ece configitems: register the 'format.dotencode' config 2017-06-30 03:42:22 +02:00
Pierre-Yves David
2303f924bc configitems: register the 'format.chunkcachesize' config 2017-06-30 03:42:21 +02:00
Pierre-Yves David
6f55ce8db4 configitems: register the 'format.aggressivemergedeltas' config 2017-06-30 03:42:20 +02:00
Pierre-Yves David
540f21db22 configitems: gather comment related to 'worker.backgroundclosemaxqueue'
Thanks to Yuya for pointing this out.
2017-07-05 00:01:30 +02:00
Pierre-Yves David
19171f625e configitems: register the 'worker.numcpus' config 2017-06-30 03:46:01 +02:00
Pierre-Yves David
83aeb84d41 configitems: register the 'worker.backgroundclosethreadcount' config 2017-06-30 03:46:00 +02:00
Pierre-Yves David
ec7068f984 configitems: register the 'worker.backgroundcloseminfilecount' config 2017-06-30 03:45:59 +02:00
Pierre-Yves David
11b3c8d2af configitems: register the 'worker.backgroundclosemaxqueue' config 2017-06-30 03:45:58 +02:00
Pierre-Yves David
97921d9b37 configitems: register the 'patch.eol' config 2017-06-30 03:43:35 +02:00
Pierre-Yves David
014dc08cb1 configitems: register the 'server.zliblevel' config 2017-06-30 03:44:16 +02:00
Pierre-Yves David
8524b4275f configitems: register the 'server.validate' config 2017-06-30 03:44:15 +02:00
Pierre-Yves David
54d53f6ed6 configitems: register the 'server.uncompressedallowsecret' config 2017-06-30 03:44:14 +02:00
Pierre-Yves David
a13e2abdc0 configitems: register the 'server.preferuncompressed' config 2017-06-30 03:44:12 +02:00
Pierre-Yves David
7b7818c09a configitems: register the 'server.maxhttpheaderlen' config 2017-06-30 03:44:11 +02:00
Pierre-Yves David
3369f427a0 configitems: register the 'server.disablefullbundle' config 2017-06-30 03:44:10 +02:00
Pierre-Yves David
8e3b51a1d6 configitems: register the 'server.concurrent-push-mode' config 2017-06-30 03:44:09 +02:00
Pierre-Yves David
109915a00c configitems: register the 'server.compressionengines' config 2017-06-30 03:44:08 +02:00
Pierre-Yves David
834e358808 configitems: register the 'server.bundle1gd' config 2017-06-30 03:44:07 +02:00
Pierre-Yves David
548593d9ae configitems: register the 'server.bundle1' config 2017-06-30 03:44:06 +02:00
Pierre-Yves David
c996e0bf50 configitems: register the 'hostsecurity.disabletls10warning' config 2017-06-30 03:42:43 +02:00
Pierre-Yves David
ce94ce8246 configitems: register the 'hostsecurity.ciphers' config 2017-06-30 03:42:42 +02:00
Pierre-Yves David
c326ab990c config: register the 'devel.legacy.exchange' config 2017-06-28 13:31:51 +02:00
Pierre-Yves David
1084baf8c5 configitems: register the 'bundle.reorder' config 2017-06-30 03:31:35 +02:00
Pierre-Yves David
a0f6321906 configitems: register the 'bundle.mainreporoot' config 2017-06-30 03:31:26 +02:00
Pierre-Yves David
eef4e6d6b1 configitems: register the 'bookmarks.pushing' config 2017-06-30 03:28:28 +02:00
Pierre-Yves David
9554f1d55f configitems: register the 'auth.cookiefile' config 2017-06-30 03:27:18 +02:00
Pierre-Yves David
cfc0e24ec0 configitems: register the 'color.mode' config 2017-06-30 03:32:09 +02:00