# HG changeset patch # User Vadim Gelfer # Date 1147410647 25200 # Node ID e9a0ed9ed4d935dc502edc5172cd634111635cb8 # Parent 90b122730d323922458ceb97d286f794d76670cb revert: fix corner case found by faheem mitha. if file not in dest manifest, remove only if in source manifest. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2277,6 +2277,7 @@ def revert(ui, repo, *pats, **opts): 'you must specify the revision to revert to')) else: node = parent + pmf = None mf = repo.manifest.read(repo.changelog.read(node)[0]) wlock = repo.wlock() @@ -2359,7 +2360,12 @@ def revert(ui, repo, *pats, **opts): if exact: ui.warn(_('no changes needed to %s\n' % rel)) continue if not in_mf: - handle(remove, False) + if pmf is None: + # only need parent manifest in this unlikely case, + # so do not read by default + pmf = repo.manifest.read(repo.changelog.read(parent)[0]) + if abs in pmf: + handle(remove, False) update[abs] = True repo.dirstate.forget(forget[0]) diff --git a/tests/test-revert b/tests/test-revert --- a/tests/test-revert +++ b/tests/test-revert @@ -68,4 +68,16 @@ hg revert echo %% should print executable test -x c && echo executable +echo %% issue 241 +hg init a +cd a +echo a >> a +hg commit -A -d '1 0' -m a +echo a >> a +hg commit -d '2 0' -m a +hg update 0 +mkdir b +echo b > b/b +hg revert -rtip + true diff --git a/tests/test-revert.out b/tests/test-revert.out --- a/tests/test-revert.out +++ b/tests/test-revert.out @@ -51,3 +51,6 @@ non-executable reverting c %% should print executable executable +%% issue 241 +adding a +1 files updated, 0 files merged, 0 files removed, 0 files unresolved