hgext/narrow/narrowdirstate.py
changeset 42456 87a34c767384
parent 40087 1d09ba0d2ed3
child 43076 2372284d9457
equal deleted inserted replaced
42455:5ca136bbd3f6 42456:87a34c767384
    14 
    14 
    15 def wrapdirstate(repo, dirstate):
    15 def wrapdirstate(repo, dirstate):
    16     """Add narrow spec dirstate ignore, block changes outside narrow spec."""
    16     """Add narrow spec dirstate ignore, block changes outside narrow spec."""
    17 
    17 
    18     def _editfunc(fn):
    18     def _editfunc(fn):
    19         def _wrapper(self, *args):
    19         def _wrapper(self, *args, **kwargs):
    20             narrowmatch = repo.narrowmatch()
    20             narrowmatch = repo.narrowmatch()
    21             for f in args:
    21             for f in args:
    22                 if f is not None and not narrowmatch(f) and f not in self:
    22                 if f is not None and not narrowmatch(f) and f not in self:
    23                     raise error.Abort(_("cannot track '%s' - it is outside " +
    23                     raise error.Abort(_("cannot track '%s' - it is outside " +
    24                         "the narrow clone") % f)
    24                         "the narrow clone") % f)
    25             return fn(self, *args)
    25             return fn(self, *args, **kwargs)
    26         return _wrapper
    26         return _wrapper
    27 
    27 
    28     class narrowdirstate(dirstate.__class__):
    28     class narrowdirstate(dirstate.__class__):
    29         # Prevent adding/editing/copying/deleting files that are outside the
    29         # Prevent adding/editing/copying/deleting files that are outside the
    30         # sparse checkout
    30         # sparse checkout
    31         @_editfunc
    31         @_editfunc
    32         def normal(self, *args):
    32         def normal(self, *args, **kwargs):
    33             return super(narrowdirstate, self).normal(*args)
    33             return super(narrowdirstate, self).normal(*args, **kwargs)
    34 
    34 
    35         @_editfunc
    35         @_editfunc
    36         def add(self, *args):
    36         def add(self, *args):
    37             return super(narrowdirstate, self).add(*args)
    37             return super(narrowdirstate, self).add(*args)
    38 
    38