# HG changeset patch # User Matt Mackall # Date 2011-05-26 22:15:35 # Node ID cc8c09855d19f1db34d321f414112c2d693fb000 # Parent 7658221da5511aaceb25ad67e26c61b04f8fff39 dirstate: rename forget to drop It has substantially different semantics from forget at the command layer, so change it to avoid confusion. We can't simply combine it with remove because we need to explicitly drop non-added files in some cases like commit. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1302,7 +1302,7 @@ class queue(object): except OSError, e: if e.errno != errno.ENOENT: raise - repo.dirstate.forget(f) + repo.dirstate.drop(f) for f in m + r: fctx = ctx[f] repo.wwrite(f, fctx.data(), fctx.flags()) @@ -1480,7 +1480,7 @@ class queue(object): for f in mm: repo.dirstate.normallookup(f) for f in forget: - repo.dirstate.forget(f) + repo.dirstate.drop(f) if not msg: if not ph.message: @@ -2617,7 +2617,7 @@ def rename(ui, repo, patch, name=None, * wlock = r.wlock() try: if r.dirstate[patch] == 'a': - r.dirstate.forget(patch) + r.dirstate.drop(patch) r.dirstate.add(name) else: if r.dirstate[name] == 'r': diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4264,7 +4264,7 @@ def revert(ui, repo, *pats, **opts): audit_path = scmutil.pathauditor(repo.root) for f in remove[0]: if repo.dirstate[f] == 'a': - repo.dirstate.forget(f) + repo.dirstate.drop(f) continue audit_path(f) try: diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -842,7 +842,7 @@ class workingctx(changectx): if self._repo.dirstate[f] != 'a': self._repo.ui.warn(_("%s not added!\n") % f) else: - self._repo.dirstate.forget(f) + self._repo.dirstate.drop(f) finally: wlock.release() @@ -863,7 +863,7 @@ class workingctx(changectx): raise for f in list: if self._repo.dirstate[f] == 'a': - self._repo.dirstate.forget(f) + self._repo.dirstate.drop(f) elif f not in self._repo.dirstate: self._repo.ui.warn(_("%s not tracked!\n") % f) else: diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -365,14 +365,11 @@ class dirstate(object): if f in self._copymap: del self._copymap[f] - def forget(self, f): - '''Forget a file.''' + def drop(self, f): + '''Drop a file from the dirstate''' self._dirty = True - try: - self._droppath(f) - del self._map[f] - except KeyError: - self._ui.warn(_("not in dirstate: %s\n") % f) + self._droppath(f) + del self._map[f] def _normalize(self, path, isknown): normed = os.path.normcase(path) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1037,7 +1037,7 @@ class localrepository(repo.repository): for f in changes[0] + changes[1]: self.dirstate.normal(f) for f in changes[2]: - self.dirstate.forget(f) + self.dirstate.drop(f) self.dirstate.setparents(ret) ms.reset() finally: diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -390,12 +390,12 @@ def recordupdates(repo, action, branchme if branchmerge: repo.dirstate.remove(f) else: - repo.dirstate.forget(f) + repo.dirstate.drop(f) elif m == "a": # re-add if not branchmerge: repo.dirstate.add(f) elif m == "f": # forget - repo.dirstate.forget(f) + repo.dirstate.drop(f) elif m == "e": # exec change repo.dirstate.normallookup(f) elif m == "g": # get @@ -425,7 +425,7 @@ def recordupdates(repo, action, branchme if f2 == fd: # file not locally copied/moved repo.dirstate.normallookup(fd) if move: - repo.dirstate.forget(f) + repo.dirstate.drop(f) elif m == "d": # directory rename f2, fd, flag = a[2:] if not f2 and f not in repo.dirstate: @@ -441,7 +441,7 @@ def recordupdates(repo, action, branchme else: repo.dirstate.normal(fd) if f: - repo.dirstate.forget(f) + repo.dirstate.drop(f) def update(repo, node, branchmerge, force, partial, ancestor=None): """