diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -923,7 +923,7 @@ def selectfile(afile_orig, bfile_orig, h 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() diff --git a/tests/test-mq-symlinks b/tests/test-mq-symlinks --- a/tests/test-mq-symlinks +++ b/tests/test-mq-symlinks @@ -55,3 +55,14 @@ hg qrefresh --git 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 diff --git a/tests/test-mq-symlinks.out b/tests/test-mq-symlinks.out --- a/tests/test-mq-symlinks.out +++ b/tests/test-mq-symlinks.out @@ -29,3 +29,9 @@ now at: removesl.patch 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