view mercurial/scmposix.py @ 24151:38824c53c2f1 stable

revset: mask specific names for named() predicate Before this patch, revset predicate "tag()" and "named('tags')" differ from each other, because the former doesn't include "tip" but the latter does. For equivalence, "named('tags')" shouldn't include the revision corresponded to "tip". But just removing "tip" from the "tags" namespace causes breaking backward compatibility, even though "tip" itself is planned to be eliminated, as mentioned below. http://selenic.com/pipermail/mercurial-devel/2015-February/066157.html To mask specific names ("tip" in this case) for "named()" predicate, this patch introduces "deprecated" into "namespaces", and makes "named()" predicate examine whether each names are masked by the namespace, to which they belong. "named()" will really work correctly after 3.3.1 (see 873eb5db89c8 for detail), and fixing this on STABLE before 3.3.1 can prevent initial users of "named()" from expecting "named('tags')" to include "tip". It is reason why this patch is posted for STABLE, even though problem itself isn't so serious. This may have to be flagged as "(BC)", if applied on DEFAULT.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 05 Feb 2015 14:45:49 +0900
parents 23c995ed466b
children 39087ee88835
line wrap: on
line source

import sys, os
import osutil

def _rcfiles(path):
    rcs = [os.path.join(path, 'hgrc')]
    rcdir = os.path.join(path, 'hgrc.d')
    try:
        rcs.extend([os.path.join(rcdir, f)
                    for f, kind in osutil.listdir(rcdir)
                    if f.endswith(".rc")])
    except OSError:
        pass
    return rcs

def systemrcpath():
    path = []
    if sys.platform == 'plan9':
        root = 'lib/mercurial'
    else:
        root = 'etc/mercurial'
    # old mod_python does not set sys.argv
    if len(getattr(sys, 'argv', [])) > 0:
        p = os.path.dirname(os.path.dirname(sys.argv[0]))
        if p != '/':
            path.extend(_rcfiles(os.path.join(p, root)))
    path.extend(_rcfiles('/' + root))
    return path

def userrcpath():
    if sys.platform == 'plan9':
        return [os.environ['home'] + '/lib/hgrc']
    else:
        return [os.path.expanduser('~/.hgrc')]