hgext/narrow/narrowrepo.py
author Pulkit Goyal <pulkit@yandex-team.ru>
Sun, 30 Sep 2018 03:42:35 +0530
changeset 39933 d5498db5f86a
parent 39766 9358f5066811
child 39934 a24f4638d6c1
permissions -rw-r--r--
narrow: move the wireprotocol narrow capability name to core We are trying to integrate the whole of narrow logic into core and it will be helpful for upcoming patches to have these capability names in core. The next patch will move the ellipses capability to core also. The exact motivation is to know whether we are cloning a ellipses repo or not and adding an ellipses repo requirement. Differential Revision: https://phab.mercurial-scm.org/D4808

# narrowrepo.py - repository which supports narrow revlogs, lazy loading
#
# 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.

from __future__ import absolute_import

from mercurial import (
    wireprotoserver,
)

from . import (
    narrowdirstate,
    narrowwirepeer,
)

def wraprepo(repo):
    """Enables narrow clone functionality on a single local repository."""

    class narrowrepository(repo.__class__):

        def _makedirstate(self):
            dirstate = super(narrowrepository, self)._makedirstate()
            return narrowdirstate.wrapdirstate(self, dirstate)

        def peer(self):
            peer = super(narrowrepository, self).peer()
            peer._caps.add(wireprotoserver.NARROWCAP)
            peer._caps.add(narrowwirepeer.ELLIPSESCAP)
            return peer

    repo.__class__ = narrowrepository