mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 17:37:57 +01:00
Add Mercurial hook hack to fix symlinks on Windows®.
This commit is contained in:
20
common/contrib/fix_symlinks.py
Normal file
20
common/contrib/fix_symlinks.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user