Commits

Patrick Mézard committed 70236d6

rename: do not overwrite existing broken symlinks

  • Participants
  • Parent commits aca8b10
  • Branches stable

Comments (0)

Files changed (3)

File mercurial/cmdutil.py

             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') %

File tests/test-rename

 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

File tests/test-rename.out

   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