# HG changeset patch # User Dov Feldstern # Date 1213551521 -10800 # Node ID 9a4de1ed0417f34ab05c6b09654e9b59699faee9 # Parent 76021ec849c876bde6fc85485e81cc4d835036fd fix symlinks on symlink-capable os but non-symlink-capable filesystem 1. write a symlink directly as a symlink (currently it's being written as a file, and only then switched to a symlink by set_flags); note that writing as a symlink already makes sure that the fs supports symlinks. 2. set_flags should only switch a file to a symlink on a symlink-capable fs. diff -r 76021ec849c8 -r 9a4de1ed0417 hgext/convert/subversion.py --- a/hgext/convert/subversion.py Sun Jun 15 13:05:39 2008 +0200 +++ b/hgext/convert/subversion.py Sun Jun 15 20:38:41 2008 +0300 @@ -978,7 +978,7 @@ fp = open(hook, 'w') fp.write(pre_revprop_change) fp.close() - util.set_flags(hook, "x") + util.set_flags(hook, "x", self.wopener._can_symlink) xport = transport.SvnRaTransport(url=geturl(path)) self.uuid = svn.ra.get_uuid(xport.ra) @@ -1005,7 +1005,8 @@ # systematically is just as expensive and much simpler. was_exec = 'x' not in flags - util.set_flags(self.wjoin(filename), flags) + util.set_flags(self.wjoin(filename), flags, + self.wopener._can_symlink) if was_exec: if 'x' not in flags: self.delexec.append(filename) diff -r 76021ec849c8 -r 9a4de1ed0417 mercurial/localrepo.py --- a/mercurial/localrepo.py Sun Jun 15 13:05:39 2008 +0200 +++ b/mercurial/localrepo.py Sun Jun 15 20:38:41 2008 +0300 @@ -569,8 +569,11 @@ os.unlink(self.wjoin(filename)) except OSError: pass - self.wopener(filename, 'w').write(data) - util.set_flags(self.wjoin(filename), flags) + if 'l' in flags: + self.wopener.symlink(data, filename) + else: + self.wopener(filename, 'w').write(data) + util.set_flags(self.wjoin(filename), flags, self.wopener._can_symlink) def wwritedata(self, filename, data): return self._filter("decode", filename, data) diff -r 76021ec849c8 -r 9a4de1ed0417 mercurial/merge.py --- a/mercurial/merge.py Sun Jun 15 13:05:39 2008 +0200 +++ b/mercurial/merge.py Sun Jun 15 20:38:41 2008 +0300 @@ -338,7 +338,7 @@ repo.ui.warn(" %s\n" % nf) elif m == "e": # exec flags = a[2] - util.set_flags(repo.wjoin(f), flags) + util.set_flags(repo.wjoin(f), flags, repo.wopener._can_symlink) return updated, merged, removed, unresolved diff -r 76021ec849c8 -r 9a4de1ed0417 mercurial/patch.py --- a/mercurial/patch.py Sun Jun 15 13:05:39 2008 +0200 +++ b/mercurial/patch.py Sun Jun 15 20:38:41 2008 +0300 @@ -1106,7 +1106,7 @@ if ctype == 'ADD' and not os.path.exists(dst): repo.wwrite(gp.path, '', flags) else: - util.set_flags(dst, flags) + util.set_flags(dst, flags, repo.wopener._can_symlink) cmdutil.addremove(repo, cfiles) files = patches.keys() files.extend([r for r in removes if r not in files]) diff -r 76021ec849c8 -r 9a4de1ed0417 mercurial/util.py --- a/mercurial/util.py Sun Jun 15 13:05:39 2008 +0200 +++ b/mercurial/util.py Sun Jun 15 20:38:41 2008 +0300 @@ -1075,7 +1075,7 @@ '''return False if pid dead, True if running or not known''' return True - def set_flags(f, flags): + def set_flags(f, flags, can_symlink): pass def set_binary(fd): @@ -1222,12 +1222,12 @@ """check whether a file is executable""" return (os.lstat(f).st_mode & 0100 != 0) - def set_flags(f, flags): + def set_flags(f, flags, can_symlink): s = os.lstat(f).st_mode x = "x" in flags l = "l" in flags if l: - if not stat.S_ISLNK(s): + if can_symlink and not stat.S_ISLNK(s): # switch file to link data = file(f).read() os.unlink(f)