##// END OF EJS Templates
repository: teach addgroup() to receive data with missing parents...
repository: teach addgroup() to receive data with missing parents The way the narrow extension works today, the server rewrites outgoing changegroup data to lie about parents when the parents data is missing. It adds the ellipsis flag to the revision so it can be recorded as such in the revlog. In the new wire protocol, such rewriting does not occur on the server (at least not yet anyway). Instead, it is up to the client to recognize when it has received a revision without its parents. This means rewriting will be performed on the client. Furthermore, the mechanism for storing a shallow revision may differ from store to store. For example, the revlog store uses the ellipsis flag to denote a revision's parents have been rewritten. But a non-revlog store may wish to store things differently. And, some stores may not even support receiving shallow revision data! Therefore, it makes sense for the store itself to be making decisions about what to do when they receive revision data without their parents. This commit teaches the addgroup() bulk insert method to accept a boolean argument that indicates whether the incoming data may lack parent revisions. This flag can be set when receiving "shallow" data from a remote. The revlog implementation of this method has been taught to rewrite the missing parent(s) to nullid and to add the ellipsis flag to the revision when a missing parent is encountered. But it only does this if ellipsis flags are enabled on the repo and the incoming data is marked as possibly shallow. An error occurs otherwise. Differential Revision: https://phab.mercurial-scm.org/D5165

File last commit:

r40109:e92454e6 default
r40425:1b183edb default
Show More
__init__.py
71 lines | 2.3 KiB | text/x-python | PythonLexer
# __init__.py - narrowhg extension
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
'''create clones which fetch history data for subset of files (EXPERIMENTAL)'''
from __future__ import absolute_import
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
testedwith = 'ships-with-hg-core'
from mercurial import (
localrepo,
registrar,
repository,
)
from . import (
narrowbundle2,
narrowcommands,
narrowrepo,
narrowtemplates,
narrowwirepeer,
)
configtable = {}
configitem = registrar.configitem(configtable)
# Narrowhg *has* support for serving ellipsis nodes (which are used at
# least by Google's internal server), but that support is pretty
# fragile and has a lot of problems on real-world repositories that
# have complex graph topologies. This could probably be corrected, but
# absent someone needing the full support for ellipsis nodes in
# repositories with merges, it's unlikely this work will get done. As
# of this writining in late 2017, all repositories large enough for
# ellipsis nodes to be a hard requirement also enforce strictly linear
# history for other scaling reasons.
configitem('experimental', 'narrowservebrokenellipses',
default=False,
alias=[('narrow', 'serveellipses')],
)
# Export the commands table for Mercurial to see.
cmdtable = narrowcommands.table
def featuresetup(ui, features):
features.add(repository.NARROW_REQUIREMENT)
def uisetup(ui):
"""Wraps user-facing mercurial commands with narrow-aware versions."""
localrepo.featuresetupfuncs.add(featuresetup)
narrowbundle2.setup()
narrowcommands.setup()
narrowwirepeer.uisetup()
def reposetup(ui, repo):
"""Wraps local repositories with narrow repo support."""
if not repo.local():
return
repo.ui.setconfig('experimental', 'narrow', True, 'narrow-ext')
if repository.NARROW_REQUIREMENT in repo.requirements:
narrowrepo.wraprepo(repo)
narrowwirepeer.reposetup(repo)
templatekeyword = narrowtemplates.templatekeyword
revsetpredicate = narrowtemplates.revsetpredicate