hgext/narrow/narrowrepo.py
author Boris Feld <boris.feld@octobus.net>
Tue, 16 Oct 2018 15:48:00 +0200
changeset 41798 8c42b4a3d447
parent 40074 f7011b44d205
child 43076 2372284d9457
permissions -rw-r--r--
strip: introduce a soft strip option This is the first user-accessible way to use the archived phase introduced in 4.8. This implements a feature discussed during the Stockholm sprint, using the archived phase for hiding changesets. The archived phase behaves exactly as stripping: changesets are no longer visible, but pulling/unbundling them will make then reappear. The only notable difference is that unlike hard stripping, soft stripping does not affect obsmarkers. The next changeset will make use of the archived phase for history rewriting command. However, having a way to manually trigger the feature first seems a necessary step before exposing users to this phase; there is a way to un-archived changesets (unbundling), so there must be a way to archive them again. Adding a flag to strip is a good way to provide access to the feature without taking a too big risk on the final UI we want. The flag is experimental so it won't be exposed by default. Using the archived phase is faster and less traumatic for the repository than actually stripping changesets.
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
39933
d5498db5f86a narrow: move the wireprotocol narrow capability name to core
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39766
diff changeset
    10
from mercurial import (
40074
f7011b44d205 wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39934
diff changeset
    11
    wireprototypes,
39933
d5498db5f86a narrow: move the wireprotocol narrow capability name to core
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39766
diff changeset
    12
)
d5498db5f86a narrow: move the wireprotocol narrow capability name to core
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39766
diff changeset
    13
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
from . import (
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    15
    narrowdirstate,
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
)
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
36466
a8b4d7673d8e narrow: move checking for narrow requirement into _narrowmatch()
Martin von Zweigbergk <martinvonz@google.com>
parents: 36464
diff changeset
    18
def wraprepo(repo):
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
    """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
    20
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
    class narrowrepository(repo.__class__):
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
38128
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    23
        def _makedirstate(self):
1cba497491be narrow: only wrap dirstate functions once, instead of per-reposetup
Kyle Lippincott <spectral@google.com>
parents: 37380
diff changeset
    24
            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
    25
            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
    26
39528
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    27
        def peer(self):
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    28
            peer = super(narrowrepository, self).peer()
40074
f7011b44d205 wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39934
diff changeset
    29
            peer._caps.add(wireprototypes.NARROWCAP)
f7011b44d205 wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39934
diff changeset
    30
            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
    31
            return peer
2862e9b868c5 narrow: check "narrow" wire protocol capability, not bundle2 capability
Martin von Zweigbergk <martinvonz@google.com>
parents: 38872
diff changeset
    32
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
    repo.__class__ = narrowrepository