hgext/narrow/narrowcopies.py
branchstable
changeset 40404 956ec6f1320d
parent 40131 535fc8a22365
parent 40403 bf249bb60087
child 40405 4185bc53d1e3
equal deleted inserted replaced
40131:535fc8a22365 40404:956ec6f1320d
     1 # narrowcopies.py - extensions to mercurial copies module to support narrow
       
     2 # clones
       
     3 #
       
     4 # Copyright 2017 Google, Inc.
       
     5 #
       
     6 # This software may be used and distributed according to the terms of the
       
     7 # GNU General Public License version 2 or any later version.
       
     8 
       
     9 from __future__ import absolute_import
       
    10 
       
    11 from mercurial import (
       
    12     copies,
       
    13     extensions,
       
    14 )
       
    15 
       
    16 def setup(repo):
       
    17     def _computeforwardmissing(orig, a, b, match=None):
       
    18         missing = orig(a, b, match)
       
    19         narrowmatch = repo.narrowmatch()
       
    20         if narrowmatch.always():
       
    21             return missing
       
    22         missing = [f for f in missing if narrowmatch(f)]
       
    23         return missing
       
    24 
       
    25     def _checkcopies(orig, srcctx, dstctx, f, base, tca, remotebase, limit,
       
    26                      data):
       
    27         narrowmatch = repo.narrowmatch()
       
    28         if not narrowmatch(f):
       
    29             return
       
    30         orig(srcctx, dstctx, f, base, tca, remotebase, limit, data)
       
    31 
       
    32     extensions.wrapfunction(copies, '_computeforwardmissing',
       
    33                             _computeforwardmissing)
       
    34     extensions.wrapfunction(copies, '_checkcopies', _checkcopies)