[PATCH 1 of 2] test-commit-amend: exhibit an --amend weirdness

Patrick Mezard patrick at mezard.eu
Mon Apr 30 13:50:10 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1335810989 -7200
# Branch stable
# Node ID f491a6d33945312e0912e890f643002982d7138c
# Parent  be786c5ac0a852cab965d9e541611f882bdb0bb8
test-commit-amend: exhibit an --amend weirdness

The weirdness is --amend let you replace one file with another with same data
and flags if the new file copy record differ from the one in the parent
revision. In theory, there is no problem with this kind of thing, subversion
supports it, but here we see log and status disagree. The reason is log reads
the copy record from the filelog, while status calls copies.pathcopies() which
eventually invokes some expensiveness argument to discard this case (copies.py,
_forwardcopies(), line 132). Since the next patch will side with pathcopies(),
I prefer to call this behaviour a bug.

diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -287,6 +287,18 @@
   A f
     d
 
+  $ mv f f.orig
+  $ hg rm -A f
+  $ hg ci -m removef
+  $ hg cp a f
+  $ mv f.orig f
+  $ hg ci --amend -m replacef
+  saved backup bundle to $TESTTMP/.hg/strip-backup/0ce2c92dc50d-amend-backup.hg
+  $ hg st --change . --copies
+  M f
+  $ hg log -r . --template "{file_copies}\n"
+  f (a)
+
 Can't rollback an amend:
 
   $ hg rollback


More information about the Mercurial-devel mailing list