# HG changeset patch # User mpm@selenic.com # Date 1119405037 28800 # Node ID 2fe8d66e307590807f41876b2fa1f6aa35f2a630 # Parent af4848f83e683d65c78fa59362da6239a93185b8 [PATCH] (3/4) Removing an added file -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] (3/4) Removing an added file From: Michael A Fetterman Here's an hg changeset that deals with "hg add"ing and then "hg remove"ing a file without ever committing it. Previously, this caused a python exception at commit time. Test case included in the patch. manifest hash: 4d012f3f8b1aa664fed9e8bc2849931b28728acd -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuMPtywK+sNU5EO8RAuxMAKCmeMLqOUBmUfCfbQgYOAysOvKkwgCfcJai 2My0M7KqhwnJSbZXbGIOcow= =N7N0 -----END PGP SIGNATURE----- diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -706,6 +706,9 @@ class localrepository: p = self.wjoin(f) if os.path.isfile(p): self.ui.warn("%s still exists!\n" % f) + elif self.dirstate.state(f) == 'a': + self.ui.warn("%s never committed!\n" % f) + self.dirstate.forget(f) elif f not in self.dirstate: self.ui.warn("%s not tracked!\n" % f) else: diff --git a/tests/test-merge3 b/tests/test-merge3 new file mode 100755 --- /dev/null +++ b/tests/test-merge3 @@ -0,0 +1,10 @@ +#!/bin/sh -x + +hg init +echo This is file a1 > a +hg add a +hg commit -t "commit #0" -d "0 0" -u user +touch b +hg add b +rm b +hg commit -A -t"comment #1" -d "0 0" -u user diff --git a/tests/test-merge3.out b/tests/test-merge3.out new file mode 100644 --- /dev/null +++ b/tests/test-merge3.out @@ -0,0 +1,9 @@ ++ hg init ++ echo This is file a1 ++ hg add a ++ hg commit -t 'commit #0' -d '0 0' -u user ++ touch b ++ hg add b ++ rm b ++ hg commit -A '-tcomment #1' -d '0 0' -u user +b never committed!