##// END OF EJS Templates
dirstate: add a `set_tracked` method for "hg add"-like usage...
marmoute -
r48393:f927ad5a default
parent child Browse files
Show More
@@ -162,6 +162,9 b' class largefilesdirstate(dirstate.dirsta'
162 162 def __getitem__(self, key):
163 163 return super(largefilesdirstate, self).__getitem__(unixpath(key))
164 164
165 def set_tracked(self, f):
166 return super(largefilesdirstate, self).set_tracked(unixpath(f))
167
165 168 def normal(self, f):
166 169 return super(largefilesdirstate, self).normal(unixpath(f))
167 170
@@ -38,6 +38,10 b' def wrapdirstate(repo, dirstate):'
38 38 return super(narrowdirstate, self).normal(*args, **kwargs)
39 39
40 40 @_editfunc
41 def set_tracked(self, *args):
42 return super(narrowdirstate, self).set_tracked(*args)
43
44 @_editfunc
41 45 def add(self, *args):
42 46 return super(narrowdirstate, self).add(*args)
43 47
@@ -256,6 +256,7 b' def _setupdirstate(ui):'
256 256 # Prevent adding files that are outside the sparse checkout
257 257 editfuncs = [
258 258 b'normal',
259 b'set_tracked',
259 260 b'add',
260 261 b'normallookup',
261 262 b'copy',
@@ -83,6 +83,17 b' def requires_parents_change(func):'
83 83 return wrap
84 84
85 85
86 def requires_no_parents_change(func):
87 def wrap(self, *args, **kwargs):
88 if not self.pendingparentchange():
89 msg = 'calling `%s` inside of a parentchange context'
90 msg %= func.__name__
91 raise error.ProgrammingError(msg)
92 return func(self, *args, **kwargs)
93
94 return wrap
95
96
86 97 @interfaceutil.implementer(intdirstate.idirstate)
87 98 class dirstate(object):
88 99 def __init__(
@@ -451,6 +462,24 b' class dirstate(object):'
451 462 def copies(self):
452 463 return self._map.copymap
453 464
465 @requires_no_parents_change
466 def set_tracked(self, filename):
467 """a "public" method for generic code to mark a file as tracked
468
469 This function is to be called outside of "update/merge" case. For
470 example by a command like `hg add X`.
471
472 return True the file was previously untracked, False otherwise.
473 """
474 entry = self._map.get(filename)
475 if entry is None:
476 self._add(filename)
477 return True
478 elif not entry.tracked:
479 self.normallookup(filename)
480 return True
481 return False
482
454 483 @requires_parents_change
455 484 def update_file_reference(
456 485 self,
General Comments 0
You need to be logged in to leave comments. Login now