##// END OF EJS Templates
resourceutil: force filesystem access to resources when using py2exe...
resourceutil: force filesystem access to resources when using py2exe I don't know why it doesn't work, but it avoids this fatal error on startup: > hg debugshell Traceback (most recent call last): File "hg", line 58, in <module> File "mercurial\dispatch.pyc", line 143, in run File "mercurial\dispatch.pyc", line 232, in dispatch File "mercurial\dispatch.pyc", line 254, in _rundispatch File "mercurial\ui.pyc", line 316, in load File "mercurial\rcutil.pyc", line 98, in rccomponents File "mercurial\rcutil.pyc", line 68, in default_rc_resources File "mercurial\utils\resourceutil.pyc", line 102, in contents File "<frozen zipimport>", line 775, in contents AssertionError I assume the py2 version of py2exe never hit this because `importlib.resources` failed to import. Differential Revision: https://phab.mercurial-scm.org/D12554

File last commit:

r49730:6000f5b2 default
r49947:3e8134f7 default
Show More
common.py
51 lines | 1.2 KiB | text/x-python | PythonLexer
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
import os
from mercurial.node import hex
from mercurial import (
error,
extensions,
pycompat,
)
def isremotebooksenabled(ui):
return b'remotenames' in extensions._extensions and ui.configbool(
b'remotenames', b'bookmarks'
)
def downloadbundle(repo, unknownbinhead):
index = repo.bundlestore.index
store = repo.bundlestore.store
bundleid = index.getbundle(hex(unknownbinhead))
if bundleid is None:
raise error.Abort(b'%s head is not known' % hex(unknownbinhead))
bundleraw = store.read(bundleid)
return _makebundlefromraw(bundleraw)
def _makebundlefromraw(data):
fp = None
fd, bundlefile = pycompat.mkstemp()
try: # guards bundlefile
try: # guards fp
fp = os.fdopen(fd, 'wb')
fp.write(data)
finally:
fp.close()
except Exception:
try:
os.unlink(bundlefile)
except Exception:
# we would rather see the original exception
pass
raise
return bundlefile