Example #1
0
def _modified_regions(repo, patterns, **kwargs):
    opt_all = kwargs.get('all', False)
    opt_no_ignore = kwargs.get('no_ignore', False)

    # Import the match (repository file name matching helper)
    # function. Different versions of Mercurial keep it in different
    # modules and implement them differently.
    try:
        from mercurial import scmutil
        m = scmutil.match(repo[None], patterns, kwargs)
    except ImportError:
        from mercurial import cmdutil
        m = cmdutil.match(repo, patterns, kwargs)

    modified, added, removed, deleted, unknown, ignore, clean = \
        repo.status(match=m, clean=opt_all)

    if not opt_all:
        try:
            wctx = repo.workingctx()
        except:
            from mercurial import context
            wctx = context.workingctx(repo)

        files = [ (fn, all_regions) for fn in added ] + \
            [ (fn,  modregions(wctx, fn)) for fn in modified ]
    else:
        files = [ (fn, all_regions) for fn in added + modified + clean ]

    for fname, mod_regions in files:
        if opt_no_ignore or not check_ignores(fname):
            yield fname, mod_regions
Example #2
0
def _modified_regions(repo, patterns, **kwargs):
    opt_all = kwargs.get('all', False)
    opt_no_ignore = kwargs.get('no_ignore', False)

    # Import the match (repository file name matching helper)
    # function. Different versions of Mercurial keep it in different
    # modules and implement them differently.
    try:
        from mercurial import scmutil
        m = scmutil.match(repo[None], patterns, kwargs)
    except ImportError:
        from mercurial import cmdutil
        m = cmdutil.match(repo, patterns, kwargs)

    modified, added, removed, deleted, unknown, ignore, clean = \
        repo.status(match=m, clean=opt_all)

    if not opt_all:
        try:
            wctx = repo.workingctx()
        except:
            from mercurial import context
            wctx = context.workingctx(repo)

        files = [ (fn, all_regions) for fn in added ] + \
            [ (fn,  modregions(wctx, fn)) for fn in modified ]
    else:
        files = [(fn, all_regions) for fn in added + modified + clean]

    for fname, mod_regions in files:
        if opt_no_ignore or not check_ignores(fname):
            yield fname, mod_regions
args = parser.parse_args()

git = GitRepo()

opts = {}
repo_base = git.repo_base()
ui = StdioUI()

os.chdir(repo_base)
failing_files = set()
staged_mismatch = set()

for status, fname in git.status(filter="MA", cached=True):
    if args.verbose:
        print("Checking {}...".format(fname))
    if check_ignores(fname):
        continue
    if status == "M":
        regions = git.staged_regions(fname)
    else:
        regions = all_regions

    # Show the appropriate object and dump it to a file
    try:
        status = git.file_from_index(fname)
    except UnicodeDecodeError:
        print("Decoding '" + fname
            + "' throws a UnicodeDecodeError.", file=sys.stderr)
        print("Please check '" + fname
            + "' exclusively uses utf-8 character encoding.", file=sys.stderr)
        sys.exit(1)
Example #4
0
args = parser.parse_args()

git = GitRepo()

opts = {}
repo_base = git.repo_base()
ui = StdioUI()

os.chdir(repo_base)
failing_files = set()
staged_mismatch = set()

for status, fname in git.status(filter="MA", cached=True):
    if args.verbose:
        print "Checking %s..." % fname
    if check_ignores(fname):
        continue
    if status == "M":
        regions = git.staged_regions(fname)
    else:
        regions = all_regions

    # Show they appropriate object and dump it to a file
    status = git.file_from_index(fname)
    f = TemporaryFile()
    f.write(status)

    verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ]
    for v in verifiers:
        f.seek(0)
        # It is prefered that the first check is silent as it is in the