##// END OF EJS Templates
localrepo: add requirement when narrow files creation option present...
localrepo: add requirement when narrow files creation option present The previous commit taught hg.clone() to define a creation option when file include or exclude patterns are passed. This commit teaches the new repo creation code to convert that creation option into a repository requirement. While not yet used by the narrow extension, the eventual side-effect of this change is that newly-created repositories will have the narrow requirement from their creation onset. Currently, the requirement is added to the repo at exchange.pull() time via a wrapped function in the narrow extension. Differential Revision: https://phab.mercurial-scm.org/D4537

File last commit:

r38182:aac4be30 default
r39587:261f1e8d default
Show More
common.py
48 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.
from __future__ import absolute_import
import os
from mercurial.node import hex
from mercurial import (
error,
extensions,
pycompat,
)
def isremotebooksenabled(ui):
return ('remotenames' in extensions._extensions and
ui.configbool('remotenames', '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('%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