patch: fix target when patching broken symlinks (issue2368) stable
authorPatrick Mezard <pmezard@gmail.com>
Mon, 20 Sep 2010 21:42:11 +0200
branchstable
changeset 12340 b0bb72460c44
parent 12320 40c40c6f20b8
child 12341 aca8b10bca6e
patch: fix target when patching broken symlinks (issue2368)
mercurial/patch.py
tests/test-mq-symlinks
tests/test-mq-symlinks.out
--- a/mercurial/patch.py	Fri Sep 17 10:21:02 2010 -0500
+++ b/mercurial/patch.py	Mon Sep 20 21:42:11 2010 +0200
@@ -923,7 +923,7 @@
     if afile == bfile:
         goodb = gooda
     else:
-        goodb = not nullb and os.path.exists(bfile)
+        goodb = not nullb and os.path.lexists(bfile)
     createfunc = hunk.createfile
     missing = not goodb and not gooda and not createfunc()
 
--- a/tests/test-mq-symlinks	Fri Sep 17 10:21:02 2010 -0500
+++ b/tests/test-mq-symlinks	Mon Sep 20 21:42:11 2010 +0200
@@ -55,3 +55,14 @@
 hg qpop
 hg qpush
 hg st -c
+
+echo '% replace broken symlink with another broken symlink'
+ln -s linka linka
+hg add linka
+hg qnew link
+hg mv linka linkb
+ln -sf linkb linkb
+hg qnew movelink
+hg qpop
+hg qpush
+$TESTDIR/readlink.py linkb
--- a/tests/test-mq-symlinks.out	Fri Sep 17 10:21:02 2010 -0500
+++ b/tests/test-mq-symlinks.out	Mon Sep 20 21:42:11 2010 +0200
@@ -29,3 +29,9 @@
 C b
 C c
 C s
+% replace broken symlink with another broken symlink
+popping movelink
+now at: link
+applying movelink
+now at: movelink
+linkb -> linkb