hgext/sparse.py
changeset 42456 87a34c767384
parent 41988 f9344d04909e
child 43076 2372284d9457
equal deleted inserted replaced
42455:5ca136bbd3f6 42456:87a34c767384
   226     # Prevent adding files that are outside the sparse checkout
   226     # Prevent adding files that are outside the sparse checkout
   227     editfuncs = ['normal', 'add', 'normallookup', 'copy', 'remove', 'merge']
   227     editfuncs = ['normal', 'add', 'normallookup', 'copy', 'remove', 'merge']
   228     hint = _('include file with `hg debugsparse --include <pattern>` or use ' +
   228     hint = _('include file with `hg debugsparse --include <pattern>` or use ' +
   229              '`hg add -s <file>` to include file directory while adding')
   229              '`hg add -s <file>` to include file directory while adding')
   230     for func in editfuncs:
   230     for func in editfuncs:
   231         def _wrapper(orig, self, *args):
   231         def _wrapper(orig, self, *args, **kwargs):
   232             sparsematch = self._sparsematcher
   232             sparsematch = self._sparsematcher
   233             if not sparsematch.always():
   233             if not sparsematch.always():
   234                 for f in args:
   234                 for f in args:
   235                     if (f is not None and not sparsematch(f) and
   235                     if (f is not None and not sparsematch(f) and
   236                         f not in self):
   236                         f not in self):
   237                         raise error.Abort(_("cannot add '%s' - it is outside "
   237                         raise error.Abort(_("cannot add '%s' - it is outside "
   238                                             "the sparse checkout") % f,
   238                                             "the sparse checkout") % f,
   239                                           hint=hint)
   239                                           hint=hint)
   240             return orig(self, *args)
   240             return orig(self, *args, **kwargs)
   241         extensions.wrapfunction(dirstate.dirstate, func, _wrapper)
   241         extensions.wrapfunction(dirstate.dirstate, func, _wrapper)
   242 
   242 
   243 @command('debugsparse', [
   243 @command('debugsparse', [
   244     ('I', 'include', False, _('include files in the sparse checkout')),
   244     ('I', 'include', False, _('include files in the sparse checkout')),
   245     ('X', 'exclude', False, _('exclude files in the sparse checkout')),
   245     ('X', 'exclude', False, _('exclude files in the sparse checkout')),