--- a/mercurial/cmdutil.py Mon Sep 20 21:42:11 2010 +0200
+++ b/mercurial/cmdutil.py Mon Sep 20 21:46:39 2010 +0200
@@ -378,7 +378,7 @@
return
# check for overwrites
- exists = os.path.exists(target)
+ exists = os.path.lexists(target)
if not after and exists or after and state in 'mn':
if not opts['force']:
ui.warn(_('%s: not overwriting - file exists\n') %
--- a/tests/test-rename Mon Sep 20 21:42:11 2010 +0200
+++ b/tests/test-rename Mon Sep 20 21:46:39 2010 +0200
@@ -158,6 +158,13 @@
hg update -C
rm d1/ca
+echo "# attempt to overwrite an existing broken symlink"
+ln -s ba d1/ca
+hg rename --traceback d1/ba d1/ca
+hg status -C
+hg update -C
+rm d1/ca
+
echo "# replace a symlink with a file"
ln -s ba d1/ca
hg rename --force d1/ba d1/ca
--- a/tests/test-rename.out Mon Sep 20 21:42:11 2010 +0200
+++ b/tests/test-rename.out Mon Sep 20 21:46:39 2010 +0200
@@ -213,6 +213,10 @@
d1/ba
R d1/ba
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+# attempt to overwrite an existing broken symlink
+d1/ca: not overwriting - file exists
+? d1/ca
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
# replace a symlink with a file
A d1/ca
d1/ba