diff --git a/.hgignore b/.hgignore index 93349ece..e55fa075 100644 --- a/.hgignore +++ b/.hgignore @@ -14,6 +14,8 @@ syntax: glob */bak/* downloads/* +*.py[co] + ## Editor backup and swap files *~ .#* diff --git a/common/contrib/fix_symlinks.py b/common/contrib/fix_symlinks.py new file mode 100644 index 00000000..6f4bdf28 --- /dev/null +++ b/common/contrib/fix_symlinks.py @@ -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) +