diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py index cf8230b844..428cddcc17 100644 --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -625,6 +625,8 @@ class dirstate(object): dadd = deleted.append cadd = clean.append + lnkkind = stat.S_IFLNK + for fn, st in self.walk(match, subrepos, listunknown, listignored).iteritems(): if fn not in dmap: @@ -640,13 +642,19 @@ class dirstate(object): if not st and state in "nma": dadd(fn) elif state == 'n': + # The "mode & lnkkind != lnkkind or self._checklink" + # lines are an expansion of "islink => checklink" + # where islink means "is this a link?" and checklink + # means "can we check links?". if (size >= 0 and (size != st.st_size or ((mode ^ st.st_mode) & 0100 and self._checkexec)) + and (mode & lnkkind != lnkkind or self._checklink) or size == -2 # other parent or fn in self._copymap): madd(fn) - elif time != int(st.st_mtime): + elif (time != int(st.st_mtime) + and (mode & lnkkind != lnkkind or self._checklink)): ladd(fn) elif listclean: cadd(fn) diff --git a/tests/test-symlink-os-yes-fs-no.py b/tests/test-symlink-os-yes-fs-no.py index f39f3c6e0e..8185c8c84e 100644 --- a/tests/test-symlink-os-yes-fs-no.py +++ b/tests/test-symlink-os-yes-fs-no.py @@ -1,5 +1,5 @@ -import os, sys -from mercurial import hg, ui +import os, sys, time +from mercurial import hg, ui, commands TESTDIR = os.environ["TESTDIR"] @@ -7,11 +7,35 @@ TESTDIR = os.environ["TESTDIR"] if not hasattr(os, "symlink"): sys.exit(80) # SKIPPED_STATUS defined in run-tests.py -# this is what symlink would do on a non-symlink file system +# clone with symlink support +u = ui.ui() +hg.clone(u, os.path.join(TESTDIR, 'test-no-symlinks.hg'), 'test0') + +repo = hg.repository(u, 'test0') + +# wait a bit, or the status call wont update the dirstate +time.sleep(1) +commands.status(u, repo) + +# now disable symlink support -- this is what os.symlink would do on a +# non-symlink file system def symlink_failure(src, dst): raise OSError, (1, "Operation not permitted") os.symlink = symlink_failure -# now try cloning a repo which contains symlinks +# dereference links as if a Samba server has exported this to a +# Windows client +for f in 'test0/a.lnk', 'test0/d/b.lnk': + os.unlink(f) + fp = open(f, 'wb') + fp.write(open(f[:-4]).read()) + fp.close() + +# reload repository +u = ui.ui() +repo = hg.repository(u, 'test0') +commands.status(u, repo) + +# try cloning a repo which contains symlinks u = ui.ui() hg.clone(u, os.path.join(TESTDIR, 'test-no-symlinks.hg'), 'test1') diff --git a/tests/test-symlink-os-yes-fs-no.py.out b/tests/test-symlink-os-yes-fs-no.py.out index 71df4b7f72..700d56c9f2 100644 --- a/tests/test-symlink-os-yes-fs-no.py.out +++ b/tests/test-symlink-os-yes-fs-no.py.out @@ -5,3 +5,10 @@ adding file changes added 1 changesets with 4 changes to 4 files updating to branch default 4 files updated, 0 files merged, 0 files removed, 0 files unresolved +requesting all changes +adding changesets +adding manifests +adding file changes +added 1 changesets with 4 changes to 4 files +updating to branch default +4 files updated, 0 files merged, 0 files removed, 0 files unresolved