view contrib/casesmash.py @ 23950:caff3675cba5 stable

log: evaluate filesets on working copy, not its parent When running "hg log 'set:added()'", we create two matchers: one used for producing the revset and one used for finding files to match. In 1fd352aa08fc (graphlog: evaluate FILE/-I/-X filesets on the working dir, 2012-02-26), we started passing a revision argument along from what's currently in cmdutil._makelogrevset() to revset._matchfiles(). When the revision was an empty string, it referred to the working copy. This was subtly done with "repo[rev or None]". Then, in f2aeff8a87b6 (revset: avoid recalculating filesets, 2014-10-22), that conversion from empty string to None was lost. Note that repo[''] is equivalent to repo['.'], not repo[None]. The consequence of this, to the user, is that when running "hg log 'set:added()'", the file matcher matches files added in the working copy, while the revset matcher matches revisions that touch files added in the parent of the working copy. As a result, only revisions that touch any files added in the parent of the working copy will be considered, but they will only be included if they also touch files added in the working copy. Fix the bug by converting '' to None again, but make it a little more explicit this time (plus, we now have tests for it).
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 21 Jan 2015 15:23:13 -0800
parents 9de689d20230
children 42a7301fb4d5
line wrap: on
line source

import os, __builtin__
from mercurial import util

def lowerwrap(scope, funcname):
    f = getattr(scope, funcname)
    def wrap(fname, *args, **kwargs):
        d, base = os.path.split(fname)
        try:
            files = os.listdir(d or '.')
        except OSError:
            files = []
        if base in files:
            return f(fname, *args, **kwargs)
        for fn in files:
            if fn.lower() == base.lower():
                return f(os.path.join(d, fn), *args, **kwargs)
        return f(fname, *args, **kwargs)
    scope.__dict__[funcname] = wrap

def normcase(path):
    return path.lower()

os.path.normcase = normcase

for f in 'file open'.split():
    lowerwrap(__builtin__, f)

for f in "chmod chown open lstat stat remove unlink".split():
    lowerwrap(os, f)

for f in "exists lexists".split():
    lowerwrap(os.path, f)

lowerwrap(util, 'posixfile')