diff --git a/hgext/convert/gnuarch.py b/hgext/convert/gnuarch.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_aGdleHQvY29udmVydC9nbnVhcmNoLnB5..e0ee3e822a9acb8d14602abdaa76740734977f2c_aGdleHQvY29udmVydC9nbnVhcmNoLnB5 100644 --- a/hgext/convert/gnuarch.py +++ b/hgext/convert/gnuarch.py @@ -138,7 +138,7 @@ raise util.Abort(_('internal calling inconsistency')) # Raise IOError if necessary (i.e. deleted files). - if not os.path.exists(os.path.join(self.tmppath, name)): + if not os.path.lexists(os.path.join(self.tmppath, name)): raise IOError return self._getfile(name, rev) diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_aGdleHQvY29udmVydC9zdWJ2ZXJzaW9uLnB5..e0ee3e822a9acb8d14602abdaa76740734977f2c_aGdleHQvY29udmVydC9zdWJ2ZXJzaW9uLnB5 100644 --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -1037,7 +1037,7 @@ # our copyfile method expects to record a copy that has # already occurred. Cross the semantic gap. wdest = self.wjoin(dest) - exists = os.path.exists(wdest) + exists = os.path.lexists(wdest) if exists: fd, tempname = tempfile.mkstemp( prefix='hg-copy-', dir=os.path.dirname(wdest)) diff --git a/hgext/mq.py b/hgext/mq.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_aGdleHQvbXEucHk=..e0ee3e822a9acb8d14602abdaa76740734977f2c_aGdleHQvbXEucHk= 100644 --- a/hgext/mq.py +++ b/hgext/mq.py @@ -674,7 +674,7 @@ removed = [] merged = [] for f in files: - if os.path.exists(repo.wjoin(f)): + if os.path.lexists(repo.wjoin(f)): merged.append(f) else: removed.append(f) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_bWVyY3VyaWFsL2NtZHV0aWwucHk=..e0ee3e822a9acb8d14602abdaa76740734977f2c_bWVyY3VyaWFsL2NtZHV0aWwucHk= 100644 --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -422,7 +422,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') % diff --git a/mercurial/context.py b/mercurial/context.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_bWVyY3VyaWFsL2NvbnRleHQucHk=..e0ee3e822a9acb8d14602abdaa76740734977f2c_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644 --- a/mercurial/context.py +++ b/mercurial/context.py @@ -825,7 +825,7 @@ wlock = self._repo.wlock() try: for f in list: - if unlink and os.path.exists(self._repo.wjoin(f)): + if unlink and os.path.lexists(self._repo.wjoin(f)): self._repo.ui.warn(_("%s still exists!\n") % f) elif self._repo.dirstate[f] == 'a': self._repo.dirstate.forget(f) @@ -853,7 +853,7 @@ def copy(self, source, dest): p = self._repo.wjoin(dest) - if not (os.path.exists(p) or os.path.islink(p)): + if not os.path.lexists(p): self._repo.ui.warn(_("%s does not exist!\n") % dest) elif not (os.path.isfile(p) or os.path.islink(p)): self._repo.ui.warn(_("copy failed: %s is not a file or a " diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_bWVyY3VyaWFsL2RpcnN0YXRlLnB5..e0ee3e822a9acb8d14602abdaa76740734977f2c_bWVyY3VyaWFsL2RpcnN0YXRlLnB5 100644 --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -362,7 +362,7 @@ norm_path = os.path.normcase(path) fold_path = self._foldmap.get(norm_path, None) if fold_path is None: - if knownpath or not os.path.exists(os.path.join(self._root, path)): + if knownpath or not os.path.lexists(os.path.join(self._root, path)): fold_path = path else: fold_path = self._foldmap.setdefault(norm_path, diff --git a/mercurial/patch.py b/mercurial/patch.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_bWVyY3VyaWFsL3BhdGNoLnB5..e0ee3e822a9acb8d14602abdaa76740734977f2c_bWVyY3VyaWFsL3BhdGNoLnB5 100644 --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -25,7 +25,7 @@ def copyfile(src, dst, basedir): abssrc, absdst = [util.canonpath(basedir, basedir, x) for x in [src, dst]] - if os.path.exists(absdst): + if os.path.lexists(absdst): raise util.Abort(_("cannot create %s: destination already exists") % dst) @@ -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() diff --git a/mercurial/util.py b/mercurial/util.py index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_bWVyY3VyaWFsL3V0aWwucHk=..e0ee3e822a9acb8d14602abdaa76740734977f2c_bWVyY3VyaWFsL3V0aWwucHk= 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -644,7 +644,7 @@ l = l + 1 name = name[l:] - if not os.path.exists(os.path.join(root, name)): + if not os.path.lexists(os.path.join(root, name)): return None seps = os.sep diff --git a/tests/test-convert-svn-sink b/tests/test-convert-svn-sink index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_dGVzdHMvdGVzdC1jb252ZXJ0LXN2bi1zaW5r..e0ee3e822a9acb8d14602abdaa76740734977f2c_dGVzdHMvdGVzdC1jb252ZXJ0LXN2bi1zaW5r 100755 --- a/tests/test-convert-svn-sink +++ b/tests/test-convert-svn-sink @@ -29,6 +29,7 @@ echo a > a/a mkdir -p a/d1/d2 echo b > a/d1/d2/b +ln -s a/missing a/link echo % add hg --cwd a ci -d '0 0' -A -m 'add a file' @@ -43,6 +44,7 @@ cmp a/a a-hg-wc/a && echo same || echo different hg --cwd a mv a b +hg --cwd a mv link newlink echo % rename hg --cwd a ci -d '2 0' -m 'rename a file' hg --cwd a tip -q diff --git a/tests/test-convert-svn-sink.out b/tests/test-convert-svn-sink.out index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_dGVzdHMvdGVzdC1jb252ZXJ0LXN2bi1zaW5rLm91dA==..e0ee3e822a9acb8d14602abdaa76740734977f2c_dGVzdHMvdGVzdC1jb252ZXJ0LXN2bi1zaW5rLm91dA== 100644 --- a/tests/test-convert-svn-sink.out +++ b/tests/test-convert-svn-sink.out @@ -1,4 +1,5 @@ % add adding a adding d1/d2/b +adding link % modify @@ -4,5 +5,5 @@ % modify -1:e0e2b8a9156b +1:8231f652da37 assuming destination a-hg initializing svn repository 'a-hg' initializing svn working copy 'a-hg-wc' @@ -17,6 +18,7 @@ 2 1 test d1 2 1 test d1/d2 2 1 test d1/d2/b + 2 1 test link <?xml version="1.0"?> <log> <logentry @@ -42,6 +44,8 @@ action="A">/d1/d2</path> <path action="A">/d1/d2/b</path> +<path + action="A">/link</path> </paths> <msg>add a file</msg> </logentry> @@ -49,7 +53,8 @@ a: a d1 +link a-hg-wc: a d1 @@ -52,6 +57,7 @@ a-hg-wc: a d1 +link same % rename @@ -56,6 +62,6 @@ same % rename -2:eb5169441d43 +2:a67e26ccec09 assuming destination a-hg initializing svn working copy 'a-hg-wc' scanning source... @@ -68,6 +74,7 @@ 3 1 test d1 3 1 test d1/d2 3 1 test d1/d2/b + 3 3 test newlink <?xml version="1.0"?> <log> <logentry @@ -81,6 +88,12 @@ copyfrom-path="/a" copyfrom-rev="2" action="A">/b</path> +<path + copyfrom-path="/link" + copyfrom-rev="2" + action="A">/newlink</path> +<path + action="D">/link</path> </paths> <msg>rename a file</msg> </logentry> @@ -88,7 +101,8 @@ a: b d1 +newlink a-hg-wc: b d1 @@ -91,5 +105,6 @@ a-hg-wc: b d1 +newlink % copy @@ -95,5 +110,5 @@ % copy -3:60effef6ab48 +3:0cf087b9ab02 assuming destination a-hg initializing svn working copy 'a-hg-wc' scanning source... @@ -107,6 +122,7 @@ 4 1 test d1 4 1 test d1/d2 4 1 test d1/d2/b + 4 3 test newlink <?xml version="1.0"?> <log> <logentry @@ -126,8 +142,9 @@ b c d1 +newlink a-hg-wc: b c d1 @@ -129,6 +146,7 @@ a-hg-wc: b c d1 +newlink % remove @@ -134,5 +152,5 @@ % remove -4:87bbe3013fb6 +4:07b2e34a5b17 assuming destination a-hg initializing svn working copy 'a-hg-wc' scanning source... @@ -145,6 +163,7 @@ 5 1 test d1 5 1 test d1/d2 5 1 test d1/d2/b + 5 3 test newlink <?xml version="1.0"?> <log> <logentry @@ -161,7 +180,8 @@ a: c d1 +newlink a-hg-wc: c d1 @@ -164,5 +184,6 @@ a-hg-wc: c d1 +newlink % executable @@ -168,5 +189,5 @@ % executable -5:ff42e473c340 +5:31093672760b assuming destination a-hg initializing svn working copy 'a-hg-wc' scanning source... @@ -179,6 +200,7 @@ 6 1 test d1 6 1 test d1/d2 6 1 test d1/d2/b + 6 3 test newlink <?xml version="1.0"?> <log> <logentry diff --git a/tests/test-mq-symlinks.t b/tests/test-mq-symlinks.t index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_dGVzdHMvdGVzdC1tcS1zeW1saW5rcy50..e0ee3e822a9acb8d14602abdaa76740734977f2c_dGVzdHMvdGVzdC1tcS1zeW1saW5rcy50 100644 --- a/tests/test-mq-symlinks.t +++ b/tests/test-mq-symlinks.t @@ -88,3 +88,33 @@ C b C c C s + +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 + popping movelink + now at: link + $ hg qpush + applying movelink + now at: movelink + $ $TESTDIR/readlink.py linkb + linkb -> linkb + +check patch does not overwrite untracked symlinks + + $ hg qpop + popping movelink + now at: link + $ ln -s linkbb linkb + $ hg qpush + applying movelink + patch failed, unable to continue (try -v) + patch failed, rejects left in working dir + errors during apply, please fix and refresh movelink + [2] diff --git a/tests/test-rename.t b/tests/test-rename.t index f00953d9533c30bcc40e7d5ae2635db5f2c88c8e_dGVzdHMvdGVzdC1yZW5hbWUudA==..e0ee3e822a9acb8d14602abdaa76740734977f2c_dGVzdHMvdGVzdC1yZW5hbWUudA== 100644 --- a/tests/test-rename.t +++ b/tests/test-rename.t @@ -372,6 +372,17 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ rm d1/ca +attempt to overwrite an existing broken symlink + + $ ln -s ba d1/ca + $ hg rename --traceback d1/ba d1/ca + d1/ca: not overwriting - file exists + $ hg status -C + ? d1/ca + $ hg update -C + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ rm d1/ca + replace a symlink with a file $ ln -s ba d1/ca