hgext/narrow/narrowdirstate.py
changeset 43076 2372284d9457
parent 42456 87a34c767384
child 43077 687b865b95ad
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 from mercurial.i18n import _
    10 from mercurial.i18n import _
    11 from mercurial import (
    11 from mercurial import error
    12     error,
    12 
    13 )
       
    14 
    13 
    15 def wrapdirstate(repo, dirstate):
    14 def wrapdirstate(repo, dirstate):
    16     """Add narrow spec dirstate ignore, block changes outside narrow spec."""
    15     """Add narrow spec dirstate ignore, block changes outside narrow spec."""
    17 
    16 
    18     def _editfunc(fn):
    17     def _editfunc(fn):
    19         def _wrapper(self, *args, **kwargs):
    18         def _wrapper(self, *args, **kwargs):
    20             narrowmatch = repo.narrowmatch()
    19             narrowmatch = repo.narrowmatch()
    21             for f in args:
    20             for f in args:
    22                 if f is not None and not narrowmatch(f) and f not in self:
    21                 if f is not None and not narrowmatch(f) and f not in self:
    23                     raise error.Abort(_("cannot track '%s' - it is outside " +
    22                     raise error.Abort(
    24                         "the narrow clone") % f)
    23                         _(
       
    24                             "cannot track '%s' - it is outside "
       
    25                             + "the narrow clone"
       
    26                         )
       
    27                         % f
       
    28                     )
    25             return fn(self, *args, **kwargs)
    29             return fn(self, *args, **kwargs)
       
    30 
    26         return _wrapper
    31         return _wrapper
    27 
    32 
    28     class narrowdirstate(dirstate.__class__):
    33     class narrowdirstate(dirstate.__class__):
    29         # Prevent adding/editing/copying/deleting files that are outside the
    34         # Prevent adding/editing/copying/deleting files that are outside the
    30         # sparse checkout
    35         # sparse checkout