mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
dirstate: rename drop to untrack
Summary: dirstate.drop() is used in two different situations. 1. To make a tracked file become untracked, and 2. To remove a file from the dirstate entirely. In the treestate case, this difference matters, so let's split drop into two functions, one to mark something as untracked, and the other to remove it entirely. In this first patch we just rename drop to untrack. The next patch will introduce the new delete function. Reviewed By: ikostia Differential Revision: D10317738 fbshipit-source-id: 85950ab1b1a10cd481edcfbba6da445b3dbf6397
This commit is contained in:
parent
cd49463e2c
commit
a0fdd80720
@ -55,4 +55,4 @@ def extsetup(ui):
|
||||
extensions.wrapfunction(dirstatecl, "add", _checkdirstate)
|
||||
extensions.wrapfunction(dirstatecl, "remove", _checkdirstate)
|
||||
extensions.wrapfunction(dirstatecl, "merge", _checkdirstate)
|
||||
extensions.wrapfunction(dirstatecl, "drop", _checkdirstate)
|
||||
extensions.wrapfunction(dirstatecl, "untrack", _checkdirstate)
|
||||
|
@ -1026,7 +1026,7 @@ def _wraprepo(ui, repo):
|
||||
|
||||
# Fix dirstate
|
||||
for file in dropped:
|
||||
dirstate.drop(file)
|
||||
dirstate.untrack(file)
|
||||
|
||||
self.localvfs.unlink("tempsparse")
|
||||
self.invalidatesignaturecache()
|
||||
@ -2184,7 +2184,7 @@ def _refresh(ui, repo, origstatus, origsparsematch, force):
|
||||
|
||||
for file in dropped:
|
||||
prog.value += 1
|
||||
dirstate.drop(file)
|
||||
dirstate.untrack(file)
|
||||
|
||||
for file in lookup:
|
||||
prog.value += 1
|
||||
|
@ -136,7 +136,7 @@ class state(object):
|
||||
dmap = ds._map
|
||||
changed = bool(self._droplist) or bool(self._lastisfresh)
|
||||
for path in self._droplist:
|
||||
dmap.dropfile(path, None, real=True)
|
||||
dmap.untrackfile(path, None, real=True)
|
||||
self._droplist = []
|
||||
for path in notefiles:
|
||||
changed |= ds.needcheck(path)
|
||||
|
@ -122,7 +122,7 @@ def _fixdirstate(repo, oldctx, newctx, status):
|
||||
for f in s.added:
|
||||
if ds[f] == "r":
|
||||
# added + removed -> unknown
|
||||
ds.drop(f)
|
||||
ds.untrack(f)
|
||||
elif ds[f] != "a":
|
||||
ds.add(f)
|
||||
|
||||
|
@ -3638,7 +3638,7 @@ def amend(ui, repo, old, extra, pats, opts):
|
||||
# to "removed" in the dirstate.
|
||||
removedfiles = set(wctx.removed()) & filestoamend
|
||||
for f in removedfiles:
|
||||
dirstate.drop(f)
|
||||
dirstate.untrack(f)
|
||||
|
||||
return newid
|
||||
|
||||
@ -4134,11 +4134,11 @@ def _performrevert(repo, parents, ctx, actions, interactive=False, tobackup=None
|
||||
_("forget added file %s (Yn)?$$ &Yes $$ &No") % f
|
||||
)
|
||||
if choice == 0:
|
||||
repo.dirstate.drop(f)
|
||||
repo.dirstate.untrack(f)
|
||||
else:
|
||||
excluded_files.append(repo.wjoin(f))
|
||||
else:
|
||||
repo.dirstate.drop(f)
|
||||
repo.dirstate.untrack(f)
|
||||
for f in actions["remove"][0]:
|
||||
audit_path(f)
|
||||
if interactive:
|
||||
|
@ -1619,7 +1619,7 @@ class committablectx(basectx):
|
||||
for f in self.modified() + self.added():
|
||||
self._repo.dirstate.normal(f)
|
||||
for f in self.removed():
|
||||
self._repo.dirstate.drop(f)
|
||||
self._repo.dirstate.untrack(f)
|
||||
self._repo.dirstate.setparents(node)
|
||||
|
||||
# write changes out explicitly, because nesting wlock at
|
||||
@ -1739,7 +1739,7 @@ class workingctx(committablectx):
|
||||
elif self._repo.dirstate[f] != "a":
|
||||
self._repo.dirstate.remove(f)
|
||||
else:
|
||||
self._repo.dirstate.drop(f)
|
||||
self._repo.dirstate.untrack(f)
|
||||
return rejected
|
||||
|
||||
def undelete(self, list):
|
||||
|
@ -597,10 +597,12 @@ class dirstate(object):
|
||||
return self.normallookup(f)
|
||||
return self.otherparent(f)
|
||||
|
||||
def drop(self, f):
|
||||
"""Drop a file from the dirstate"""
|
||||
def untrack(self, f):
|
||||
"""Stops tracking a file in the dirstate. This is useful during
|
||||
operations that want to stop tracking a file, but still have it show up
|
||||
as untracked (like hg forget)."""
|
||||
oldstate = self[f]
|
||||
if self._map.dropfile(f, oldstate):
|
||||
if self._map.untrackfile(f, oldstate):
|
||||
self._dirty = True
|
||||
if not self._istreestate:
|
||||
self._updatedfiles.add(f)
|
||||
@ -708,7 +710,7 @@ class dirstate(object):
|
||||
if f in allfiles:
|
||||
self.normallookup(f)
|
||||
else:
|
||||
self.drop(f)
|
||||
self.untrack(f)
|
||||
|
||||
self._dirty = True
|
||||
|
||||
@ -1349,7 +1351,7 @@ class dirstatemap(object):
|
||||
where state is a single character representing 'normal', 'added',
|
||||
'removed', or 'merged'. It is read by treating the dirstate as a
|
||||
dict. File state is updated by calling the `addfile`, `removefile` and
|
||||
`dropfile` methods.
|
||||
`untrackfile` methods.
|
||||
|
||||
- `copymap` maps destination filenames to their source filename.
|
||||
|
||||
@ -1458,10 +1460,10 @@ class dirstatemap(object):
|
||||
self._insert_tuple(f, "r", 0, size, 0)
|
||||
self.nonnormalset.add(f)
|
||||
|
||||
def dropfile(self, f, oldstate):
|
||||
def untrackfile(self, f, oldstate):
|
||||
"""
|
||||
Remove a file from the dirstate. Returns True if the file was
|
||||
previously recorded.
|
||||
Remove a file from the dirstate, leaving it untracked. Returns True if
|
||||
the file was previously recorded.
|
||||
"""
|
||||
exists = self._map.pop(f, None) is not None
|
||||
if exists:
|
||||
|
@ -1800,12 +1800,12 @@ def recordupdates(repo, actions, branchmerge):
|
||||
if branchmerge:
|
||||
repo.dirstate.remove(f)
|
||||
else:
|
||||
repo.dirstate.drop(f)
|
||||
repo.dirstate.untrack(f)
|
||||
prog.value += 1
|
||||
|
||||
# forget (must come first)
|
||||
for f, args, msg in actions.get("f", []):
|
||||
repo.dirstate.drop(f)
|
||||
repo.dirstate.untrack(f)
|
||||
prog.value += 1
|
||||
|
||||
# resolve path conflicts
|
||||
@ -1818,7 +1818,7 @@ def recordupdates(repo, actions, branchmerge):
|
||||
if f0 == origf0:
|
||||
repo.dirstate.remove(f0)
|
||||
else:
|
||||
repo.dirstate.drop(f0)
|
||||
repo.dirstate.untrack(f0)
|
||||
prog.value += 1
|
||||
|
||||
# re-add
|
||||
@ -1874,7 +1874,7 @@ def recordupdates(repo, actions, branchmerge):
|
||||
if f2 == f: # file not locally copied/moved
|
||||
repo.dirstate.normallookup(f)
|
||||
if move:
|
||||
repo.dirstate.drop(f1)
|
||||
repo.dirstate.untrack(f1)
|
||||
prog.value += 1
|
||||
|
||||
# directory rename, move local
|
||||
@ -1886,7 +1886,7 @@ def recordupdates(repo, actions, branchmerge):
|
||||
repo.dirstate.copy(f0, f)
|
||||
else:
|
||||
repo.dirstate.normal(f)
|
||||
repo.dirstate.drop(f0)
|
||||
repo.dirstate.untrack(f0)
|
||||
prog.value += 1
|
||||
|
||||
# directory rename, get
|
||||
|
@ -321,7 +321,7 @@ py_class!(class treedirstatemap |py| {
|
||||
Ok(py.None())
|
||||
}
|
||||
|
||||
def dropfile(&self, filename: PyBytes) -> PyResult<bool> {
|
||||
def untrackfile(&self, filename: PyBytes) -> PyResult<bool> {
|
||||
let mut dirstate = self.dirstate(py).borrow_mut();
|
||||
dirstate
|
||||
.drop_file(filename.data(py))
|
||||
|
@ -266,7 +266,7 @@ def prunetemporaryincludes(repo):
|
||||
|
||||
# Fix dirstate
|
||||
for file in dropped:
|
||||
dirstate.drop(file)
|
||||
dirstate.untrack(file)
|
||||
|
||||
repo.localvfs.unlink("tempsparse")
|
||||
repo._sparsesignaturecache.clear()
|
||||
@ -534,7 +534,7 @@ def refreshwdir(repo, origstatus, origsparsematch, force=False):
|
||||
dirstate.normal(file)
|
||||
|
||||
for file in dropped:
|
||||
dirstate.drop(file)
|
||||
dirstate.untrack(file)
|
||||
|
||||
for file in lookup:
|
||||
# File exists on disk, and we're bringing it back in an unknown state.
|
||||
|
@ -250,7 +250,7 @@ class treedirstatemap(object):
|
||||
if size == -2 and self._otherparentset is not None:
|
||||
self._otherparentset.add(f)
|
||||
|
||||
def dropfile(self, f, oldstate):
|
||||
def untrackfile(self, f, oldstate):
|
||||
"""
|
||||
Drops a file from the dirstate. Returns True if it was previously
|
||||
recorded.
|
||||
@ -259,7 +259,7 @@ class treedirstatemap(object):
|
||||
self._nonnormalset.discard(f)
|
||||
if self._otherparentset is not None:
|
||||
self._otherparentset.discard(f)
|
||||
return self._rmap.dropfile(f)
|
||||
return self._rmap.untrackfile(f)
|
||||
|
||||
def clearambiguoustimes(self, files, now):
|
||||
"""Mark files with an mtime of `now` as being out of date.
|
||||
|
@ -217,7 +217,11 @@ class treestatemap(object):
|
||||
size = 0
|
||||
self._tree.insert(f, state, mode, size, mtime, copied)
|
||||
|
||||
def dropfile(self, f, oldstate, real=False):
|
||||
def untrackfile(self, f, oldstate, real=False):
|
||||
"""
|
||||
Removes the state marking a file as tracked, but leaves it in the
|
||||
treestate for future inspection.
|
||||
"""
|
||||
if real or not self._clock:
|
||||
# If watchman clock is not set, watchman is not used, drop
|
||||
# untracked files directly. This is also correct if watchman
|
||||
|
@ -19,7 +19,7 @@
|
||||
> if opts.get('normal_lookup'):
|
||||
> repo.dirstate.normallookup(file)
|
||||
> else:
|
||||
> repo.dirstate.drop(file)
|
||||
> repo.dirstate.untrack(file)
|
||||
>
|
||||
> repo.dirstate.write(repo.currenttransaction())
|
||||
> finally:
|
||||
|
Loading…
Reference in New Issue
Block a user