changeset 12342:70236d6fd844 stable

rename: do not overwrite existing broken symlinks
author Patrick Mezard <pmezard@gmail.com>
date Mon, 20 Sep 2010 21:46:39 +0200
parents aca8b10bca6e
children 28642f7fc2cf
files mercurial/cmdutil.py tests/test-rename tests/test-rename.out
diffstat 3 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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