hgext/narrow/narrowrepo.py
author Pulkit Goyal <7895pulkit@gmail.com>
Sun, 11 Apr 2021 00:50:10 +0530
changeset 47404 ebdef6283798
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
rhg: read [paths] for `--repository` value hg parses `-R` and `--repository` CLI arguments "early" in order to know which local repository to load config from. (Config can then affect whether or how to fall back.) The value of of those arguments can be not only a filesystem path, but also an alias configured in the `[paths]` section. This part was missing in rhg and this patch implements that. The current patch still lacks functionality to read config of current repository if we are not at root of repo. That will be fixed in upcoming patches. A new crate `home` is added to get path of home directory. Differential Revision: https://phab.mercurial-scm.org/D10296
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
# narrowrepo.py - repository which supports narrow revlogs, lazy loading
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
#
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
# Copyright 2017 Google, Inc.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
#
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     8
from __future__ import absolute_import
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40074
diff changeset
    10
from mercurial import wireprototypes
39933
d5498db5f86a narrow: move the wireprotocol narrow capability name to core
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39766
diff changeset
    11
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40074
diff changeset
    12
from . import narrowdirstate
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40074
diff changeset
    13
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
36466
a8b4d7673d8e narrow: move checking for narrow requirement into _narrowmatch()
Martin von Zweigbergk <martinvonz@google.com>
parents: 36464
diff changeset
    15
def wraprepo(repo):
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
    """Enables narrow clone functionality on a single local repository."""
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
    class narrowrepository(repo.__class__):
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    19
        def _makedirstate(self):
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    20
            dirstate = super(narrowrepository, self)._makedirstate()
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    21
            return narrowdirstate.wrapdirstate(self, dirstate)
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    22
39528
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    23
        def peer(self):
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    24
            peer = super(narrowrepository, self).peer()
40074
f7011b44d205 wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39934
diff changeset
    25
            peer._caps.add(wireprototypes.NARROWCAP)
f7011b44d205 wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39934
diff changeset
    26
            peer._caps.add(wireprototypes.ELLIPSESCAP)
39528
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    27
            return peer
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    28
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
    repo.__class__ = narrowrepository