[PATCH 2 of 2] Prevent merged symlink targets from being modified
Steve Borho
steve at borho.org
Mon Oct 1 01:43:04 UTC 2007
# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1191202867 18000
# Node ID 426850ac5be89366496999b827be50775739f550
# Parent f8b4e3545651be6e19adea9480e633d65813fd69
Prevent merged symlink targets from being modified
The merge logic tries to update the executable status of each file after it
has been merged. util.set_exec() is not symlink aware, so it was modifying
the link target. To avoid this problem we skip the call when the merged file
is a symlink.
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -479,7 +479,8 @@ def applyupdates(repo, action, wctx, mct
updated += 1
else:
merged += 1
- util.set_exec(repo.wjoin(fd), "x" in flags)
+ if not util.is_link(repo.wjoin(fd)):
+ util.set_exec(repo.wjoin(fd), "x" in flags)
if f != fd and move and util.lexists(repo.wjoin(f)):
repo.ui.debug(_("removing %s\n") % f)
os.unlink(repo.wjoin(f))
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -965,6 +965,9 @@ if os.name == 'nt':
def set_link(f, mode):
pass
+ def is_link(path):
+ return False
+
def set_binary(fd):
msvcrt.setmode(fd.fileno(), os.O_BINARY)
@@ -1123,6 +1126,9 @@ else:
data = os.readlink(f)
os.unlink(f)
file(f, "w").write(data)
+
+ def is_link(path):
+ return os.path.islink(path)
def set_binary(fd):
pass
More information about the Mercurial-devel
mailing list