1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 00:17:59 +01:00

Add Mercurial hook hack to fix symlinks on Windows®.

This commit is contained in:
Kris Maglione
2010-10-06 15:01:32 -04:00
parent f8dc6097aa
commit 169133e16e
2 changed files with 22 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ syntax: glob
*/bak/* */bak/*
downloads/* downloads/*
*.py[co]
## Editor backup and swap files ## Editor backup and swap files
*~ *~
.#* .#*

View File

@@ -0,0 +1,20 @@
from mercurial import util
import os
def fix_symlinks(repo, hooktype, parent1, **kwargs):
revert = hooktype in ('precommit', 'preupdate')
ctxt = repo[parent1]
for filename in ctxt:
file = ctxt[filename]
if 'l' in file.flags():
path = repo.wjoin(file.path())
try:
os.unlink(path)
except Exception, e:
print repr(e)
if revert:
repo.wwrite(file.path(), file.data(), '')
else:
target = os.path.join(os.path.dirname(path), file.data())
util.copyfiles(target, path, True)