[PATCH 3 of 3 STABLE] revert: look for copies information for all local modifications
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Nov 26 17:30:30 CST 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1416973254 28800
# Tue Nov 25 19:40:54 2014 -0800
# Branch stable
# Node ID 18bcfb55b93d76ad6a9a097e203036ac22504e83
# Parent 1866e1771d90ea39c1abc2bf677f7acd48bca701
revert: look for copies information for all local modifications
Renaming a file over an existing one marks the file as modified. So we
track rename source in modified file too.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2529,16 +2529,20 @@ def revert(ui, repo, ctx, parents, *pats
# or just forget etc)
if parent == node:
dsmodified = modified
dsadded = added
dsremoved = removed
+ # store all local modification, useful later for renames detection
+ localchanges = dsmodified | dsadded
modified, added, removed = set(), set(), set()
else:
changes = repo.status(node1=parent, match=m)
dsmodified = set(changes[0])
dsadded = set(changes[1])
dsremoved = set(changes[2])
+ # store all local modification, useful later for renames detection
+ localchanges = dsmodified | dsadded
# only take into account for removes between wc and target
clean |= dsremoved - removed
dsremoved &= removed
# distinct between dirstate remove and other
@@ -2568,11 +2572,11 @@ def revert(ui, repo, ctx, parents, *pats
dsadded |= mergeadd
dsmodified -= mergeadd
# if f is a rename, update `names` to also revert the source
cwd = repo.getcwd()
- for f in dsadded:
+ for f in localchanges:
src = repo.dirstate.copied(f)
# XXX should we check for rename down to target node?
if src and src not in names and repo.dirstate[src] == 'r':
dsremoved.add(src)
names[src] = (repo.pathto(src, cwd), True)
diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -232,10 +232,16 @@ reverting a rename target should revert
$ hg mv a newa
$ hg revert newa
$ hg st a newa
? newa
+Also true for move overwriting existing file
+
+ $ hg mv --force a b/b
+ $ hg revert b/b
+ $ hg status a b/b
+
$ cd ..
$ hg init ignored
$ cd ignored
$ echo '^ignored$' > .hgignore
More information about the Mercurial-devel
mailing list