hgext/narrow/narrowcopies.py
author Martin von Zweigbergk <martinvonz@google.com>
Thu, 02 Aug 2018 23:50:47 -0700
changeset 38818 e411774a2e0f
parent 36472 d0d5eef57fb0
permissions -rw-r--r--
narrow: move status-filtering to core and to ctx One of my recent changes from repo.status(ctx1, ctx2) to ctx1.status(ctx2) broke some of our Google-internal tests. The problem turned out to be that the narrow extension was overriding repo.status() to make it filter out paths outside the narrowspec. When I changed to ctx1.status(ctx2), then that filtering obviously got lost. ctx.status() seems like a better method to do the filtering in, so this patch moves the filtering into that method, thereby also moving it out of the extension and into core. Differential Revision: https://phab.mercurial-scm.org/D4068

# narrowcopies.py - extensions to mercurial copies module to support narrow
# clones
#
# Copyright 2017 Google, 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

from mercurial import (
    copies,
    extensions,
)

def setup(repo):
    def _computeforwardmissing(orig, a, b, match=None):
        missing = orig(a, b, match)
        narrowmatch = repo.narrowmatch()
        if narrowmatch.always():
            return missing
        missing = [f for f in missing if narrowmatch(f)]
        return missing

    def _checkcopies(orig, srcctx, dstctx, f, base, tca, remotebase, limit,
                     data):
        narrowmatch = repo.narrowmatch()
        if not narrowmatch(f):
            return
        orig(srcctx, dstctx, f, base, tca, remotebase, limit, data)

    extensions.wrapfunction(copies, '_computeforwardmissing',
                            _computeforwardmissing)
    extensions.wrapfunction(copies, '_checkcopies', _checkcopies)