##// END OF EJS Templates
hg: allow extra arguments to be passed to repo creation (API)...
hg: allow extra arguments to be passed to repo creation (API) Currently, repository creation is influenced by consulting the ui instance and turning config options into requirements. This means that in order to influence repository creation, you need to define and set a config option and that the option must translate to a requirement stored in the .hg/requires file. This commit introduces a new mechanism to influence repository creation. hg.repository() and hg.peer() have been taught to receive a new optional argument defining extra options to apply to repository creation. This value is passed along to the various instance() functions and can be used to influence repository creation. This will allow us to pass rich data directly to repository creation without having to go through the config layer. It also allows us to be more explicit about the features requested during repository creation and provides a natural point to detect unhandled options influencing repository creation. The new code detects when unknown creation options are present and aborts in that case. .. api:: options can now be passed to influence repository creation The various instance() functions to spawn new peers or repository instances now receive a ``createopts`` argument that can be a dict defining additional options to influence repository creation. localrepo.newreporequirements() also receives this argument. Differential Revision: https://phab.mercurial-scm.org/D4535

File last commit:

r38182:aac4be30 default
r39585:089fc0db 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