mercurial/repository.py
author Matt Harbison <matt_harbison@yahoo.com>
Wed, 26 Sep 2018 22:21:25 -0400
changeset 39884 9c8eff5cfa1b
parent 39876 a269fa55467e
child 39997 2f80eaf38ed4
permissions -rw-r--r--
py3: mask out None type when printing in `debuglocks` Apparently, %b doesn't allow None.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# repository.py - Interfaces and base classes for repositories and peers.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com>
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
#
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
from __future__ import absolute_import
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
    10
from .i18n import _
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
    11
from . import (
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
    12
    error,
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
    13
)
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    14
from .utils import (
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    15
    interfaceutil,
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    16
)
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
    17
38835
a232e6744ba3 narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents: 38556
diff changeset
    18
# When narrowing is finalized and no longer subject to format changes,
a232e6744ba3 narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents: 38556
diff changeset
    19
# we should move this to just "narrow" or similar.
a232e6744ba3 narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents: 38556
diff changeset
    20
NARROW_REQUIREMENT = 'narrowhg-experimental'
a232e6744ba3 narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents: 38556
diff changeset
    21
39850
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    22
# Local repository feature string.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    23
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    24
# Revlogs are being used for file storage.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    25
REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage'
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    26
# The storage part of the repository is shared from an external source.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    27
REPO_FEATURE_SHARED_STORAGE = b'sharedstore'
39851
1f7b3b980af8 lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39850
diff changeset
    28
# LFS supported for backing file storage.
1f7b3b980af8 lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39850
diff changeset
    29
REPO_FEATURE_LFS = b'lfs'
39850
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
    30
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    31
class ipeerconnection(interfaceutil.Interface):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
    """Represents a "connection" to a repository.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
    This is the base interface for representing a connection to a repository.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
    It holds basic properties and methods applicable to all peer types.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
    This is not a complete interface definition and should not be used
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
    outside of this module.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
    """
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    40
    ui = interfaceutil.Attribute("""ui.ui instance""")
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    42
    def url():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
        """Returns a URL string representing this peer.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
        Currently, implementations expose the raw URL used to construct the
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
        instance. It may contain credentials as part of the URL. The
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
        expectations of the value aren't well-defined and this could lead to
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
        data leakage.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
        TODO audit/clean consumers and more clearly define the contents of this
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
        value.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    52
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    54
    def local():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
        """Returns a local repository instance.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    57
        If the peer represents a local repository, returns an object that
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
        can be used to interface with it. Otherwise returns ``None``.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    61
    def peer():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
        """Returns an object conforming to this interface.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
        Most implementations will ``return self``.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    67
    def canpush():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    68
        """Returns a boolean indicating if this peer can be pushed to."""
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    69
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    70
    def close():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    71
        """Close the connection to this peer.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    72
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
        This is called when the peer will no longer be used. Resources
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
        associated with the peer should be cleaned up.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    77
class ipeercapabilities(interfaceutil.Interface):
37610
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    78
    """Peer sub-interface related to capabilities."""
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    79
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    80
    def capable(name):
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    81
        """Determine support for a named capability.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    82
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    83
        Returns ``False`` if capability not supported.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    84
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    85
        Returns ``True`` if boolean capability is supported. Returns a string
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    86
        if capability support is non-boolean.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    87
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    88
        Capability strings may or may not map to wire protocol capabilities.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    89
        """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    90
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    91
    def requirecap(name, purpose):
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    92
        """Require a capability to be present.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    93
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    94
        Raises a ``CapabilityError`` if the capability isn't present.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    95
        """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    96
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    97
class ipeercommands(interfaceutil.Interface):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    98
    """Client-side interface for communicating over the wire protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    99
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   100
    This interface is used as a gateway to the Mercurial wire protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   101
    methods commonly call wire protocol commands of the same name.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   102
    """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   103
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   104
    def branchmap():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   105
        """Obtain heads in named branches.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   106
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   107
        Returns a dict mapping branch name to an iterable of nodes that are
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   108
        heads on that branch.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   109
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   110
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   111
    def capabilities():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   112
        """Obtain capabilities of the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   113
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   114
        Returns a set of string capabilities.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   115
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   116
37649
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   117
    def clonebundles():
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   118
        """Obtains the clone bundles manifest for the repo.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   119
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   120
        Returns the manifest as unparsed bytes.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   121
        """
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   122
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   123
    def debugwireargs(one, two, three=None, four=None, five=None):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   124
        """Used to facilitate debugging of arguments passed over the wire."""
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   125
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   126
    def getbundle(source, **kwargs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   127
        """Obtain remote repository data as a bundle.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   128
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   129
        This command is how the bulk of repository data is transferred from
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   130
        the peer to the local repository
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   131
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   132
        Returns a generator of bundle data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   133
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   134
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   135
    def heads():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   136
        """Determine all known head revisions in the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   137
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   138
        Returns an iterable of binary nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   139
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   140
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   141
    def known(nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   142
        """Determine whether multiple nodes are known.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   143
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   144
        Accepts an iterable of nodes whose presence to check for.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   145
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   146
        Returns an iterable of booleans indicating of the corresponding node
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   147
        at that index is known to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   148
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   149
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   150
    def listkeys(namespace):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   151
        """Obtain all keys in a pushkey namespace.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   152
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   153
        Returns an iterable of key names.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   154
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   155
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   156
    def lookup(key):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   157
        """Resolve a value to a known revision.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   158
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   159
        Returns a binary node of the resolved revision on success.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   160
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   161
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   162
    def pushkey(namespace, key, old, new):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   163
        """Set a value using the ``pushkey`` protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   164
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   165
        Arguments correspond to the pushkey namespace and key to operate on and
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   166
        the old and new values for that key.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   167
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   168
        Returns a string with the peer result. The value inside varies by the
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   169
        namespace.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   170
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   171
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   172
    def stream_out():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   173
        """Obtain streaming clone data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   174
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   175
        Successful result should be a generator of data chunks.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   176
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   177
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   178
    def unbundle(bundle, heads, url):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   179
        """Transfer repository data to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   180
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   181
        This is how the bulk of data during a push is transferred.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   182
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   183
        Returns the integer number of heads added to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   184
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   185
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   186
class ipeerlegacycommands(interfaceutil.Interface):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   187
    """Interface for implementing support for legacy wire protocol commands.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   188
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   189
    Wire protocol commands transition to legacy status when they are no longer
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   190
    used by modern clients. To facilitate identifying which commands are
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   191
    legacy, the interfaces are split.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   192
    """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   193
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   194
    def between(pairs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   195
        """Obtain nodes between pairs of nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   196
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   197
        ``pairs`` is an iterable of node pairs.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   198
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   199
        Returns an iterable of iterables of nodes corresponding to each
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   200
        requested pair.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   201
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   202
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   203
    def branches(nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   204
        """Obtain ancestor changesets of specific nodes back to a branch point.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   205
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   206
        For each requested node, the peer finds the first ancestor node that is
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   207
        a DAG root or is a merge.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   208
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   209
        Returns an iterable of iterables with the resolved values for each node.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   210
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   211
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37633
diff changeset
   212
    def changegroup(nodes, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   213
        """Obtain a changegroup with data for descendants of specified nodes."""
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   214
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37633
diff changeset
   215
    def changegroupsubset(bases, heads, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   216
        pass
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   217
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   218
class ipeercommandexecutor(interfaceutil.Interface):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   219
    """Represents a mechanism to execute remote commands.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   220
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   221
    This is the primary interface for requesting that wire protocol commands
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   222
    be executed. Instances of this interface are active in a context manager
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   223
    and have a well-defined lifetime. When the context manager exits, all
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   224
    outstanding requests are waited on.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   225
    """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   226
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   227
    def callcommand(name, args):
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   228
        """Request that a named command be executed.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   229
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   230
        Receives the command name and a dictionary of command arguments.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   231
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   232
        Returns a ``concurrent.futures.Future`` that will resolve to the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   233
        result of that command request. That exact value is left up to
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   234
        the implementation and possibly varies by command.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   235
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   236
        Not all commands can coexist with other commands in an executor
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   237
        instance: it depends on the underlying wire protocol transport being
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   238
        used and the command itself.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   239
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   240
        Implementations MAY call ``sendcommands()`` automatically if the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   241
        requested command can not coexist with other commands in this executor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   242
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   243
        Implementations MAY call ``sendcommands()`` automatically when the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   244
        future's ``result()`` is called. So, consumers using multiple
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   245
        commands with an executor MUST ensure that ``result()`` is not called
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   246
        until all command requests have been issued.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   247
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   248
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   249
    def sendcommands():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   250
        """Trigger submission of queued command requests.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   251
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   252
        Not all transports submit commands as soon as they are requested to
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   253
        run. When called, this method forces queued command requests to be
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   254
        issued. It will no-op if all commands have already been sent.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   255
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   256
        When called, no more new commands may be issued with this executor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   257
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   258
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   259
    def close():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   260
        """Signal that this command request is finished.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   261
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   262
        When called, no more new commands may be issued. All outstanding
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   263
        commands that have previously been issued are waited on before
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   264
        returning. This not only includes waiting for the futures to resolve,
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   265
        but also waiting for all response data to arrive. In other words,
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   266
        calling this waits for all on-wire state for issued command requests
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   267
        to finish.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   268
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   269
        When used as a context manager, this method is called when exiting the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   270
        context manager.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   271
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   272
        This method may call ``sendcommands()`` if there are buffered commands.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   273
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   274
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   275
class ipeerrequests(interfaceutil.Interface):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   276
    """Interface for executing commands on a peer."""
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   277
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   278
    def commandexecutor():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   279
        """A context manager that resolves to an ipeercommandexecutor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   280
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   281
        The object this resolves to can be used to issue command requests
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   282
        to the peer.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   283
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   284
        Callers should call its ``callcommand`` method to issue command
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   285
        requests.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   286
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   287
        A new executor should be obtained for each distinct set of commands
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   288
        (possibly just a single command) that the consumer wants to execute
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   289
        as part of a single operation or round trip. This is because some
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   290
        peers are half-duplex and/or don't support persistent connections.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   291
        e.g. in the case of HTTP peers, commands sent to an executor represent
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   292
        a single HTTP request. While some peers may support multiple command
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   293
        sends over the wire per executor, consumers need to code to the least
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   294
        capable peer. So it should be assumed that command executors buffer
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   295
        called commands until they are told to send them and that each
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   296
        command executor could result in a new connection or wire-level request
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   297
        being issued.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   298
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   299
37650
62ebfda864de repository: remove ipeercommands from ipeerbase
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37649
diff changeset
   300
class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   301
    """Unified interface for peer repositories.
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   302
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   303
    All peer instances must conform to this interface.
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   304
    """
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   305
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   306
@interfaceutil.implementer(ipeerbase)
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   307
class peer(object):
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   308
    """Base class for peer repositories."""
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   309
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   310
    def capable(self, name):
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   311
        caps = self.capabilities()
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   312
        if name in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   313
            return True
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   314
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   315
        name = '%s=' % name
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   316
        for cap in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   317
            if cap.startswith(name):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   318
                return cap[len(name):]
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   319
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   320
        return False
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   321
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   322
    def requirecap(self, name, purpose):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   323
        if self.capable(name):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   324
            return
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   325
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   326
        raise error.CapabilityError(
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   327
            _('cannot %s; remote repository does not support the %r '
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   328
              'capability') % (purpose, name))
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   329
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   330
class iverifyproblem(interfaceutil.Interface):
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   331
    """Represents a problem with the integrity of the repository.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   332
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   333
    Instances of this interface are emitted to describe an integrity issue
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   334
    with a repository (e.g. corrupt storage, missing data, etc).
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   335
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   336
    Instances are essentially messages associated with severity.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   337
    """
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   338
    warning = interfaceutil.Attribute(
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   339
        """Message indicating a non-fatal problem.""")
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   340
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   341
    error = interfaceutil.Attribute(
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   342
        """Message indicating a fatal problem.""")
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   343
39872
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   344
    node = interfaceutil.Attribute(
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   345
        """Revision encountering the problem.
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   346
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   347
        ``None`` means the problem doesn't apply to a single revision.
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   348
        """)
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   349
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   350
class irevisiondelta(interfaceutil.Interface):
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   351
    """Represents a delta between one revision and another.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   352
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   353
    Instances convey enough information to allow a revision to be exchanged
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   354
    with another repository.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   355
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   356
    Instances represent the fulltext revision data or a delta against
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   357
    another revision. Therefore the ``revision`` and ``delta`` attributes
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   358
    are mutually exclusive.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   359
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   360
    Typically used for changegroup generation.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   361
    """
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   362
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   363
    node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   364
        """20 byte node of this revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   365
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   366
    p1node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   367
        """20 byte node of 1st parent of this revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   368
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   369
    p2node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   370
        """20 byte node of 2nd parent of this revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   371
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   372
    linknode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   373
        """20 byte node of the changelog revision this node is linked to.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   374
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   375
    flags = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   376
        """2 bytes of integer flags that apply to this revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   377
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   378
    basenode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   379
        """20 byte node of the revision this data is a delta against.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   380
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   381
        ``nullid`` indicates that the revision is a full revision and not
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   382
        a delta.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   383
        """)
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   384
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   385
    baserevisionsize = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   386
        """Size of base revision this delta is against.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   387
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   388
        May be ``None`` if ``basenode`` is ``nullid``.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   389
        """)
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   390
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   391
    revision = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   392
        """Raw fulltext of revision data for this node.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   393
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   394
    delta = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   395
        """Delta between ``basenode`` and ``node``.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   396
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   397
        Stored in the bdiff delta format.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   398
        """)
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   399
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   400
class ifilerevisionssequence(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   401
    """Contains index data for all revisions of a file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   402
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   403
    Types implementing this behave like lists of tuples. The index
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   404
    in the list corresponds to the revision number. The values contain
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   405
    index metadata.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   406
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   407
    The *null* revision (revision number -1) is always the last item
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   408
    in the index.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   409
    """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   410
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   411
    def __len__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   412
        """The total number of revisions."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   413
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   414
    def __getitem__(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   415
        """Returns the object having a specific revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   416
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   417
        Returns an 8-tuple with the following fields:
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   418
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   419
        offset+flags
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   420
           Contains the offset and flags for the revision. 64-bit unsigned
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   421
           integer where first 6 bytes are the offset and the next 2 bytes
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   422
           are flags. The offset can be 0 if it is not used by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   423
        compressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   424
            Size of the revision data in the store. It can be 0 if it isn't
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   425
            needed by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   426
        uncompressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   427
            Fulltext size. It can be 0 if it isn't needed by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   428
        base revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   429
            Revision number of revision the delta for storage is encoded
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   430
            against. -1 indicates not encoded against a base revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   431
        link revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   432
            Revision number of changelog revision this entry is related to.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   433
        p1 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   434
            Revision number of 1st parent. -1 if no 1st parent.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   435
        p2 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   436
            Revision number of 2nd parent. -1 if no 1st parent.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   437
        node
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   438
            Binary node value for this revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   439
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   440
        Negative values should index off the end of the sequence. ``-1``
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   441
        should return the null revision. ``-2`` should return the most
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   442
        recent revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   443
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   444
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   445
    def __contains__(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   446
        """Whether a revision number exists."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   447
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   448
    def insert(self, i, entry):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   449
        """Add an item to the index at specific revision."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   450
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   451
class ifileindex(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   452
    """Storage interface for index data of a single file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   453
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   454
    File storage data is divided into index metadata and data storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   455
    This interface defines the index portion of the interface.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   456
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   457
    The index logically consists of:
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   458
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   459
    * A mapping between revision numbers and nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   460
    * DAG data (storing and querying the relationship between nodes).
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   461
    * Metadata to facilitate storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   462
    """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   463
    def __len__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   464
        """Obtain the number of revisions stored for this file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   465
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   466
    def __iter__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   467
        """Iterate over revision numbers for this file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   468
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   469
    def revs(start=0, stop=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   470
        """Iterate over revision numbers for this file, with control."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   471
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   472
    def parents(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   473
        """Returns a 2-tuple of parent nodes for a revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   474
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   475
        Values will be ``nullid`` if the parent is empty.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   476
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   477
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   478
    def parentrevs(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   479
        """Like parents() but operates on revision numbers."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   480
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   481
    def rev(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   482
        """Obtain the revision number given a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   483
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   484
        Raises ``error.LookupError`` if the node is not known.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   485
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   486
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   487
    def node(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   488
        """Obtain the node value given a revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   489
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   490
        Raises ``IndexError`` if the node is not known.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   491
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   492
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   493
    def lookup(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   494
        """Attempt to resolve a value to a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   495
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   496
        Value can be a binary node, hex node, revision number, or a string
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   497
        that can be converted to an integer.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   498
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   499
        Raises ``error.LookupError`` if a node could not be resolved.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   500
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   501
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   502
    def linkrev(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   503
        """Obtain the changeset revision number a revision is linked to."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   504
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   505
    def iscensored(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   506
        """Return whether a revision's content has been censored."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   507
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   508
    def commonancestorsheads(node1, node2):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   509
        """Obtain an iterable of nodes containing heads of common ancestors.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   510
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   511
        See ``ancestor.commonancestorsheads()``.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   512
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   513
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   514
    def descendants(revs):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   515
        """Obtain descendant revision numbers for a set of revision numbers.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   516
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   517
        If ``nullrev`` is in the set, this is equivalent to ``revs()``.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   518
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   519
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   520
    def heads(start=None, stop=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   521
        """Obtain a list of nodes that are DAG heads, with control.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   522
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   523
        The set of revisions examined can be limited by specifying
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   524
        ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   525
        iterable of nodes. DAG traversal starts at earlier revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   526
        ``start`` and iterates forward until any node in ``stop`` is
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   527
        encountered.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   528
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   529
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   530
    def children(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   531
        """Obtain nodes that are children of a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   532
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   533
        Returns a list of nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   534
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   535
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   536
class ifiledata(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   537
    """Storage interface for data storage of a specific file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   538
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   539
    This complements ``ifileindex`` and provides an interface for accessing
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   540
    data for a tracked file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   541
    """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   542
    def size(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   543
        """Obtain the fulltext size of file data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   544
39875
d909c44d29e1 filelog: stop proxying rawsize() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39873
diff changeset
   545
        Any metadata is excluded from size measurements.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   546
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   547
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   548
    def checkhash(fulltext, node, p1=None, p2=None, rev=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   549
        """Validate the stored hash of a given fulltext and node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   550
39776
cb65d4b7e429 error: introduce StorageError
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39764
diff changeset
   551
        Raises ``error.StorageError`` is hash validation fails.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   552
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   553
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   554
    def revision(node, raw=False):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   555
        """"Obtain fulltext data for a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   556
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   557
        By default, any storage transformations are applied before the data
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   558
        is returned. If ``raw`` is True, non-raw storage transformations
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   559
        are not applied.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   560
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   561
        The fulltext data may contain a header containing metadata. Most
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   562
        consumers should use ``read()`` to obtain the actual file data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   563
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   564
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   565
    def read(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   566
        """Resolve file fulltext data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   567
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   568
        This is similar to ``revision()`` except any metadata in the data
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   569
        headers is stripped.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   570
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   571
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   572
    def renamed(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   573
        """Obtain copy metadata for a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   574
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   575
        Returns ``False`` if no copy metadata is stored or a 2-tuple of
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   576
        (path, node) from which this revision was copied.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   577
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   578
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   579
    def cmp(node, fulltext):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   580
        """Compare fulltext to another revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   581
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   582
        Returns True if the fulltext is different from what is stored.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   583
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   584
        This takes copy metadata into account.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   585
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   586
        TODO better document the copy metadata and censoring logic.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   587
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   588
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   589
    def revdiff(rev1, rev2):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   590
        """Obtain a delta between two revision numbers.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   591
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   592
        Operates on raw data in the store (``revision(node, raw=True)``).
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   593
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   594
        The returned data is the result of ``bdiff.bdiff`` on the raw
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   595
        revision data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   596
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   597
39862
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   598
    def emitrevisions(nodes,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   599
                      nodesorder=None,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   600
                      revisiondata=False,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   601
                      assumehaveparentrevisions=False,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   602
                      deltaprevious=False):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   603
        """Produce ``irevisiondelta`` for revisions.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   604
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   605
        Given an iterable of nodes, emits objects conforming to the
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   606
        ``irevisiondelta`` interface that describe revisions in storage.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   607
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   608
        This method is a generator.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   609
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   610
        The input nodes may be unordered. Implementations must ensure that a
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   611
        node's parents are emitted before the node itself. Transitively, this
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   612
        means that a node may only be emitted once all its ancestors in
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   613
        ``nodes`` have also been emitted.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   614
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   615
        By default, emits "index" data (the ``node``, ``p1node``, and
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   616
        ``p2node`` attributes). If ``revisiondata`` is set, revision data
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   617
        will also be present on the emitted objects.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   618
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   619
        With default argument values, implementations can choose to emit
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   620
        either fulltext revision data or a delta. When emitting deltas,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   621
        implementations must consider whether the delta's base revision
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   622
        fulltext is available to the receiver.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   623
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   624
        The base revision fulltext is guaranteed to be available if any of
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   625
        the following are met:
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   626
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   627
        * Its fulltext revision was emitted by this method call.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   628
        * A delta for that revision was emitted by this method call.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   629
        * ``assumehaveparentrevisions`` is True and the base revision is a
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   630
          parent of the node.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   631
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   632
        ``nodesorder`` can be used to control the order that revisions are
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   633
        emitted. By default, revisions can be reordered as long as they are
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   634
        in DAG topological order (see above). If the value is ``nodes``,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   635
        the iteration order from ``nodes`` should be used. If the value is
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   636
        ``storage``, then the native order from the backing storage layer
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   637
        is used. (Not all storage layers will have strong ordering and behavior
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   638
        of this mode is storage-dependent.) ``nodes`` ordering can force
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   639
        revisions to be emitted before their ancestors, so consumers should
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   640
        use it with care.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   641
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   642
        The ``linknode`` attribute on the returned ``irevisiondelta`` may not
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   643
        be set and it is the caller's responsibility to resolve it, if needed.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   644
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   645
        If ``deltaprevious`` is True and revision data is requested, all
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   646
        revision data should be emitted as deltas against the revision
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   647
        emitted just prior. The initial revision should be a delta against
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   648
        its 1st parent.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   649
        """
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
   650
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   651
class ifilemutation(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   652
    """Storage interface for mutation events of a tracked file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   653
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   654
    def add(filedata, meta, transaction, linkrev, p1, p2):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   655
        """Add a new revision to the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   656
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   657
        Takes file data, dictionary of metadata, a transaction, linkrev,
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   658
        and parent nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   659
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   660
        Returns the node that was added.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   661
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   662
        May no-op if a revision matching the supplied data is already stored.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   663
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   664
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   665
    def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   666
                    flags=0, cachedelta=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   667
        """Add a new revision to the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   668
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   669
        This is similar to ``add()`` except it operates at a lower level.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   670
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   671
        The data passed in already contains a metadata header, if any.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   672
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   673
        ``node`` and ``flags`` can be used to define the expected node and
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   674
        the flags to use with storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   675
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   676
        ``add()`` is usually called when adding files from e.g. the working
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   677
        directory. ``addrevision()`` is often called by ``add()`` and for
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   678
        scenarios where revision data has already been computed, such as when
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   679
        applying raw data from a peer repo.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   680
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   681
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   682
    def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   683
        """Process a series of deltas for storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   684
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   685
        ``deltas`` is an iterable of 7-tuples of
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   686
        (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   687
        to add.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   688
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   689
        The ``delta`` field contains ``mpatch`` data to apply to a base
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   690
        revision, identified by ``deltabase``. The base node can be
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   691
        ``nullid``, in which case the header from the delta can be ignored
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   692
        and the delta used as the fulltext.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   693
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   694
        ``addrevisioncb`` should be called for each node as it is committed.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   695
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   696
        Returns a list of nodes that were processed. A node will be in the list
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   697
        even if it existed in the store previously.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   698
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   699
39778
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   700
    def censorrevision(tr, node, tombstone=b''):
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   701
        """Remove the content of a single revision.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   702
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   703
        The specified ``node`` will have its content purged from storage.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   704
        Future attempts to access the revision data for this node will
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   705
        result in failure.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   706
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   707
        A ``tombstone`` message can optionally be stored. This message may be
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   708
        displayed to users when they attempt to access the missing revision
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   709
        data.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   710
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   711
        Storage backends may have stored deltas against the previous content
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   712
        in this revision. As part of censoring a revision, these storage
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   713
        backends are expected to rewrite any internally stored deltas such
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   714
        that they no longer reference the deleted content.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   715
        """
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
   716
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   717
    def getstrippoint(minlink):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   718
        """Find the minimum revision that must be stripped to strip a linkrev.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   719
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   720
        Returns a 2-tuple containing the minimum revision number and a set
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   721
        of all revisions numbers that would be broken by this strip.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   722
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   723
        TODO this is highly revlog centric and should be abstracted into
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   724
        a higher-level deletion API. ``repair.strip()`` relies on this.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   725
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   726
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   727
    def strip(minlink, transaction):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   728
        """Remove storage of items starting at a linkrev.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   729
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   730
        This uses ``getstrippoint()`` to determine the first node to remove.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   731
        Then it effectively truncates storage for all revisions after that.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   732
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   733
        TODO this is highly revlog centric and should be abstracted into a
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   734
        higher-level deletion API.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   735
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   736
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   737
class ifilestorage(ifileindex, ifiledata, ifilemutation):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   738
    """Complete storage interface for a single tracked file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   739
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   740
    def files():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   741
        """Obtain paths that are backing storage for this file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   742
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   743
        TODO this is used heavily by verify code and there should probably
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   744
        be a better API for that.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   745
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   746
39869
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   747
    def storageinfo(exclusivefiles=False, sharedfiles=False,
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   748
                    revisionscount=False, trackedsize=False,
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   749
                    storedsize=False):
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   750
        """Obtain information about storage for this file's data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   751
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   752
        Returns a dict describing storage for this tracked path. The keys
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   753
        in the dict map to arguments of the same. The arguments are bools
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   754
        indicating whether to calculate and obtain that data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   755
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   756
        exclusivefiles
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   757
           Iterable of (vfs, path) describing files that are exclusively
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   758
           used to back storage for this tracked path.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   759
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   760
        sharedfiles
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   761
           Iterable of (vfs, path) describing files that are used to back
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   762
           storage for this tracked path. Those files may also provide storage
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   763
           for other stored entities.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   764
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   765
        revisionscount
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   766
           Number of revisions available for retrieval.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   767
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   768
        trackedsize
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   769
           Total size in bytes of all tracked revisions. This is a sum of the
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   770
           length of the fulltext of all revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   771
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   772
        storedsize
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   773
           Total size in bytes used to store data for all tracked revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   774
           This is commonly less than ``trackedsize`` due to internal usage
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   775
           of deltas rather than fulltext revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   776
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   777
        Not all storage backends may support all queries are have a reasonable
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   778
        value to use. In that case, the value should be set to ``None`` and
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   779
        callers are expected to handle this special value.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   780
        """
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
   781
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   782
    def verifyintegrity(state):
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   783
        """Verifies the integrity of file storage.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   784
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   785
        ``state`` is a dict holding state of the verifier process. It can be
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   786
        used to communicate data between invocations of multiple storage
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   787
        primitives.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   788
39872
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   789
        If individual revisions cannot have their revision content resolved,
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   790
        the method is expected to set the ``skipread`` key to a set of nodes
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   791
        that encountered problems.
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
   792
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   793
        The method yields objects conforming to the ``iverifyproblem``
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   794
        interface.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   795
        """
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
   796
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   797
class idirs(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   798
    """Interface representing a collection of directories from paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   799
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   800
    This interface is essentially a derived data structure representing
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   801
    directories from a collection of paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   802
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   803
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   804
    def addpath(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   805
        """Add a path to the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   806
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   807
        All directories in the path will be added to the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   808
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   809
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   810
    def delpath(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   811
        """Remove a path from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   812
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   813
        If the removal was the last path in a particular directory, the
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   814
        directory is removed from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   815
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   816
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   817
    def __iter__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   818
        """Iterate over the directories in this collection of paths."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   819
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   820
    def __contains__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   821
        """Whether a specific directory is in this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   822
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   823
class imanifestdict(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   824
    """Interface representing a manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   825
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   826
    A manifest is effectively a dict mapping paths to entries. Each entry
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   827
    consists of a binary node and extra flags affecting that entry.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   828
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   829
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   830
    def __getitem__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   831
        """Returns the binary node value for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   832
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   833
        Raises ``KeyError`` if the path does not exist in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   834
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   835
        Equivalent to ``self.find(path)[0]``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   836
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   837
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   838
    def find(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   839
        """Returns the entry for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   840
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   841
        Returns a 2-tuple of (node, flags).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   842
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   843
        Raises ``KeyError`` if the path does not exist in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   844
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   845
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   846
    def __len__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   847
        """Return the number of entries in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   848
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   849
    def __nonzero__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   850
        """Returns True if the manifest has entries, False otherwise."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   851
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   852
    __bool__ = __nonzero__
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   853
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   854
    def __setitem__(path, node):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   855
        """Define the node value for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   856
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   857
        If the path is already in the manifest, its flags will be copied to
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   858
        the new entry.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   859
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   860
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   861
    def __contains__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   862
        """Whether a path exists in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   863
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   864
    def __delitem__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   865
        """Remove a path from the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   866
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   867
        Raises ``KeyError`` if the path is not in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   868
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   869
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   870
    def __iter__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   871
        """Iterate over paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   872
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   873
    def iterkeys():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   874
        """Iterate over paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   875
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   876
    def keys():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   877
        """Obtain a list of paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   878
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   879
    def filesnotin(other, match=None):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   880
        """Obtain the set of paths in this manifest but not in another.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   881
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   882
        ``match`` is an optional matcher function to be applied to both
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   883
        manifests.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   884
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   885
        Returns a set of paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   886
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   887
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   888
    def dirs():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   889
        """Returns an object implementing the ``idirs`` interface."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   890
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   891
    def hasdir(dir):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   892
        """Returns a bool indicating if a directory is in this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   893
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   894
    def matches(match):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   895
        """Generate a new manifest filtered through a matcher.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   896
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   897
        Returns an object conforming to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   898
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   899
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   900
    def walk(match):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   901
        """Generator of paths in manifest satisfying a matcher.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   902
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   903
        This is equivalent to ``self.matches(match).iterkeys()`` except a new
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   904
        manifest object is not created.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   905
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   906
        If the matcher has explicit files listed and they don't exist in
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   907
        the manifest, ``match.bad()`` is called for each missing file.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   908
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   909
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   910
    def diff(other, match=None, clean=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   911
        """Find differences between this manifest and another.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   912
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   913
        This manifest is compared to ``other``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   914
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   915
        If ``match`` is provided, the two manifests are filtered against this
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   916
        matcher and only entries satisfying the matcher are compared.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   917
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   918
        If ``clean`` is True, unchanged files are included in the returned
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   919
        object.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   920
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   921
        Returns a dict with paths as keys and values of 2-tuples of 2-tuples of
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   922
        the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   923
        represents the node and flags for this manifest and ``(node2, flag2)``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   924
        are the same for the other manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   925
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   926
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   927
    def setflag(path, flag):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   928
        """Set the flag value for a given path.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   929
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   930
        Raises ``KeyError`` if the path is not already in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   931
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   932
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   933
    def get(path, default=None):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   934
        """Obtain the node value for a path or a default value if missing."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   935
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   936
    def flags(path, default=''):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   937
        """Return the flags value for a path or a default value if missing."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   938
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   939
    def copy():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   940
        """Return a copy of this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   941
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   942
    def items():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   943
        """Returns an iterable of (path, node) for items in this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   944
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   945
    def iteritems():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   946
        """Identical to items()."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   947
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   948
    def iterentries():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   949
        """Returns an iterable of (path, node, flags) for this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   950
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   951
        Similar to ``iteritems()`` except items are a 3-tuple and include
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   952
        flags.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   953
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   954
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   955
    def text():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   956
        """Obtain the raw data representation for this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   957
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   958
        Result is used to create a manifest revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   959
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   960
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   961
    def fastdelta(base, changes):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   962
        """Obtain a delta between this manifest and another given changes.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   963
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   964
        ``base`` in the raw data representation for another manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   965
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   966
        ``changes`` is an iterable of ``(path, to_delete)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   967
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   968
        Returns a 2-tuple containing ``bytearray(self.text())`` and the
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   969
        delta between ``base`` and this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   970
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   971
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   972
class imanifestrevisionbase(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   973
    """Base interface representing a single revision of a manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   974
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   975
    Should not be used as a primary interface: should always be inherited
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   976
    as part of a larger interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   977
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   978
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   979
    def new():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   980
        """Obtain a new manifest instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   981
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   982
        Returns an object conforming to the ``imanifestrevisionwritable``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   983
        interface. The instance will be associated with the same
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   984
        ``imanifestlog`` collection as this instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   985
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   986
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   987
    def copy():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   988
        """Obtain a copy of this manifest instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   989
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   990
        Returns an object conforming to the ``imanifestrevisionwritable``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   991
        interface. The instance will be associated with the same
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   992
        ``imanifestlog`` collection as this instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   993
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   994
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   995
    def read():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   996
        """Obtain the parsed manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   997
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   998
        The returned object conforms to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   999
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1000
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1001
class imanifestrevisionstored(imanifestrevisionbase):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1002
    """Interface representing a manifest revision committed to storage."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1003
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1004
    def node():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1005
        """The binary node for this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1006
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1007
    parents = interfaceutil.Attribute(
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1008
        """List of binary nodes that are parents for this manifest revision."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1009
    )
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1010
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1011
    def readdelta(shallow=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1012
        """Obtain the manifest data structure representing changes from parent.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1013
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1014
        This manifest is compared to its 1st parent. A new manifest representing
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1015
        those differences is constructed.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1016
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1017
        The returned object conforms to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1018
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1019
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1020
    def readfast(shallow=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1021
        """Calls either ``read()`` or ``readdelta()``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1022
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1023
        The faster of the two options is called.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1024
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1025
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1026
    def find(key):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1027
        """Calls self.read().find(key)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1028
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1029
        Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1030
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1031
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1032
class imanifestrevisionwritable(imanifestrevisionbase):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1033
    """Interface representing a manifest revision that can be committed."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1034
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1035
    def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1036
        """Add this revision to storage.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1037
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1038
        Takes a transaction object, the changeset revision number it will
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1039
        be associated with, its parent nodes, and lists of added and
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1040
        removed paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1041
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1042
        If match is provided, storage can choose not to inspect or write out
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1043
        items that do not match. Storage is still required to be able to provide
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1044
        the full manifest in the future for any directories written (these
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1045
        manifests should not be "narrowed on disk").
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1046
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1047
        Returns the binary node of the created revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1048
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1049
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1050
class imanifeststorage(interfaceutil.Interface):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1051
    """Storage interface for manifest data."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1052
39315
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1053
    tree = interfaceutil.Attribute(
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1054
        """The path to the directory this manifest tracks.
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1055
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1056
        The empty bytestring represents the root manifest.
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1057
        """)
57c3864f3aad manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39314
diff changeset
  1058
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1059
    index = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1060
        """An ``ifilerevisionssequence`` instance.""")
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1061
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1062
    indexfile = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1063
        """Path of revlog index file.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1064
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1065
        TODO this is revlog specific and should not be exposed.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1066
        """)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1067
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1068
    opener = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1069
        """VFS opener to use to access underlying files used for storage.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1070
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1071
        TODO this is revlog specific and should not be exposed.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1072
        """)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1073
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1074
    version = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1075
        """Revlog version number.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1076
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1077
        TODO this is revlog specific and should not be exposed.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1078
        """)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1079
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1080
    _generaldelta = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1081
        """Whether generaldelta storage is being used.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1082
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1083
        TODO this is revlog specific and should not be exposed.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1084
        """)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1085
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1086
    fulltextcache = interfaceutil.Attribute(
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1087
        """Dict with cache of fulltexts.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1088
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1089
        TODO this doesn't feel appropriate for the storage interface.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1090
        """)
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1091
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1092
    def __len__():
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1093
        """Obtain the number of revisions stored for this manifest."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1094
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1095
    def __iter__():
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1096
        """Iterate over revision numbers for this manifest."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1097
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1098
    def rev(node):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1099
        """Obtain the revision number given a binary node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1100
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1101
        Raises ``error.LookupError`` if the node is not known.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1102
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1103
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1104
    def node(rev):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1105
        """Obtain the node value given a revision number.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1106
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1107
        Raises ``error.LookupError`` if the revision is not known.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1108
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1109
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1110
    def lookup(value):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1111
        """Attempt to resolve a value to a node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1112
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1113
        Value can be a binary node, hex node, revision number, or a bytes
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1114
        that can be converted to an integer.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1115
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1116
        Raises ``error.LookupError`` if a ndoe could not be resolved.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1117
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1118
        TODO this is only used by debug* commands and can probably be deleted
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1119
        easily.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1120
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1121
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1122
    def parents(node):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1123
        """Returns a 2-tuple of parent nodes for a node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1124
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1125
        Values will be ``nullid`` if the parent is empty.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1126
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1127
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1128
    def parentrevs(rev):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1129
        """Like parents() but operates on revision numbers."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1130
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1131
    def linkrev(rev):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1132
        """Obtain the changeset revision number a revision is linked to."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1133
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1134
    def revision(node, _df=None, raw=False):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1135
        """Obtain fulltext data for a node."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1136
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1137
    def revdiff(rev1, rev2):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1138
        """Obtain a delta between two revision numbers.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1139
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1140
        The returned data is the result of ``bdiff.bdiff()`` on the raw
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1141
        revision data.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1142
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1143
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1144
    def cmp(node, fulltext):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1145
        """Compare fulltext to another revision.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1146
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1147
        Returns True if the fulltext is different from what is stored.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1148
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1149
39862
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1150
    def emitrevisions(nodes,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1151
                      nodesorder=None,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1152
                      revisiondata=False,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1153
                      assumehaveparentrevisions=False):
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1154
        """Produce ``irevisiondelta`` describing revisions.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1155
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1156
        See the documentation for ``ifiledata`` for more.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1157
        """
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
  1158
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1159
    def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1160
        """Process a series of deltas for storage.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1161
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1162
        See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1163
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1164
39858
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1165
    def rawsize(rev):
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1166
        """Obtain the size of tracked data.
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1167
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1168
        Is equivalent to ``len(m.revision(node, raw=True))``.
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1169
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1170
        TODO this method is only used by upgrade code and may be removed.
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1171
        """
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
  1172
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1173
    def getstrippoint(minlink):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1174
        """Find minimum revision that must be stripped to strip a linkrev.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1175
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1176
        See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1177
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1178
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1179
    def strip(minlink, transaction):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1180
        """Remove storage of items starting at a linkrev.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1181
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1182
        See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1183
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1184
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1185
    def checksize():
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1186
        """Obtain the expected sizes of backing files.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1187
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1188
        TODO this is used by verify and it should not be part of the interface.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1189
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1190
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1191
    def files():
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1192
        """Obtain paths that are backing storage for this manifest.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1193
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1194
        TODO this is used by verify and there should probably be a better API
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1195
        for this functionality.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1196
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1197
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1198
    def deltaparent(rev):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1199
        """Obtain the revision that a revision is delta'd against.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1200
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1201
        TODO delta encoding is an implementation detail of storage and should
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1202
        not be exposed to the storage interface.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1203
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1204
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1205
    def clone(tr, dest, **kwargs):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1206
        """Clone this instance to another."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1207
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1208
    def clearcaches(clear_persisted_data=False):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1209
        """Clear any caches associated with this instance."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1210
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1211
    def dirlog(d):
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1212
        """Obtain a manifest storage instance for a tree."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1213
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1214
    def add(m, transaction, link, p1, p2, added, removed, readtree=None,
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1215
            match=None):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1216
        """Add a revision to storage.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1217
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1218
        ``m`` is an object conforming to ``imanifestdict``.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1219
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1220
        ``link`` is the linkrev revision number.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1221
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1222
        ``p1`` and ``p2`` are the parent revision numbers.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1223
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1224
        ``added`` and ``removed`` are iterables of added and removed paths,
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1225
        respectively.
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1226
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1227
        ``readtree`` is a function that can be used to read the child tree(s)
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1228
        when recursively writing the full tree structure when using
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1229
        treemanifets.
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1230
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1231
        ``match`` is a matcher that can be used to hint to storage that not all
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1232
        paths must be inspected; this is an optimization and can be safely
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1233
        ignored. Note that the storage must still be able to reproduce a full
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
  1234
        manifest including files that did not match.
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1235
        """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
  1236
39869
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1237
    def storageinfo(exclusivefiles=False, sharedfiles=False,
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1238
                    revisionscount=False, trackedsize=False,
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1239
                    storedsize=False):
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1240
        """Obtain information about storage for this manifest's data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1241
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1242
        See ``ifilestorage.storageinfo()`` for a description of this method.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1243
        This one behaves the same way, except for manifest data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1244
        """
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
  1245
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1246
class imanifestlog(interfaceutil.Interface):
39240
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1247
    """Interface representing a collection of manifest snapshots.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1248
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1249
    Represents the root manifest in a repository.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1250
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1251
    Also serves as a means to access nested tree manifests and to cache
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1252
    tree manifests.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
  1253
    """
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1254
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1255
    def __getitem__(node):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1256
        """Obtain a manifest instance for a given binary node.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1257
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1258
        Equivalent to calling ``self.get('', node)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1259
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1260
        The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1261
        interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1262
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1263
39235
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
  1264
    def get(tree, node, verify=True):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1265
        """Retrieve the manifest instance for a given directory and binary node.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1266
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1267
        ``node`` always refers to the node of the root manifest (which will be
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1268
        the only manifest if flat manifests are being used).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1269
39235
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
  1270
        If ``tree`` is the empty string, the root manifest is returned.
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
  1271
        Otherwise the manifest for the specified directory will be returned
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
  1272
        (requires tree manifests).
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1273
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1274
        If ``verify`` is True, ``LookupError`` is raised if the node is not
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1275
        known.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1276
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1277
        The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1278
        interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1279
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1280
39244
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1281
    def getstorage(tree):
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1282
        """Retrieve an interface to storage for a particular tree.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1283
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1284
        If ``tree`` is the empty bytestring, storage for the root manifest will
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1285
        be returned. Otherwise storage for a tree manifest is returned.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1286
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1287
        TODO formalize interface for returned object.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1288
        """
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
  1289
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1290
    def clearcaches():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1291
        """Clear caches associated with this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1292
38555
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1293
    def rev(node):
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1294
        """Obtain the revision number for a binary node.
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1295
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1296
        Raises ``error.LookupError`` if the node is not known.
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1297
        """
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1298
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1299
class ilocalrepositoryfilestorage(interfaceutil.Interface):
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1300
    """Local repository sub-interface providing access to tracked file storage.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1301
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1302
    This interface defines how a repository accesses storage for a single
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1303
    tracked file path.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1304
    """
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1305
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1306
    def file(f):
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1307
        """Obtain a filelog for a tracked path.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1308
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1309
        The returned type conforms to the ``ifilestorage`` interface.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1310
        """
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1311
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1312
class ilocalrepositorymain(interfaceutil.Interface):
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1313
    """Main interface for local repositories.
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1314
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1315
    This currently captures the reality of things - not how things should be.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1316
    """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1317
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1318
    supportedformats = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1319
        """Set of requirements that apply to stream clone.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1320
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1321
        This is actually a class attribute and is shared among all instances.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1322
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1323
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1324
    supported = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1325
        """Set of requirements that this repo is capable of opening.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1326
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1327
    requirements = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1328
        """Set of requirements this repo uses.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1329
39850
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1330
    features = interfaceutil.Attribute(
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1331
        """Set of "features" this repository supports.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1332
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1333
        A "feature" is a loosely-defined term. It can refer to a feature
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1334
        in the classical sense or can describe an implementation detail
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1335
        of the repository. For example, a ``readonly`` feature may denote
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1336
        the repository as read-only. Or a ``revlogfilestore`` feature may
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1337
        denote that the repository is using revlogs for file storage.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1338
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1339
        The intent of features is to provide a machine-queryable mechanism
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1340
        for repo consumers to test for various repository characteristics.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1341
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1342
        Features are similar to ``requirements``. The main difference is that
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1343
        requirements are stored on-disk and represent requirements to open the
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1344
        repository. Features are more run-time capabilities of the repository
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1345
        and more granular capabilities (which may be derived from requirements).
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1346
        """)
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
  1347
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1348
    filtername = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1349
        """Name of the repoview that is active on this repo.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1350
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1351
    wvfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1352
        """VFS used to access the working directory.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1353
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1354
    vfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1355
        """VFS rooted at the .hg directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1356
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1357
        Used to access repository data not in the store.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1358
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1359
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1360
    svfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1361
        """VFS rooted at the store.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1362
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1363
        Used to access repository data in the store. Typically .hg/store.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1364
        But can point elsewhere if the store is shared.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1365
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1366
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1367
    root = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1368
        """Path to the root of the working directory.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1369
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1370
    path = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1371
        """Path to the .hg directory.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1372
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1373
    origroot = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1374
        """The filesystem path that was used to construct the repo.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1375
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1376
    auditor = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1377
        """A pathauditor for the working directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1378
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1379
        This checks if a path refers to a nested repository.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1380
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1381
        Operates on the filesystem.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1382
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1383
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1384
    nofsauditor = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1385
        """A pathauditor for the working directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1386
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1387
        This is like ``auditor`` except it doesn't do filesystem checks.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1388
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1389
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1390
    baseui = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1391
        """Original ui instance passed into constructor.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1392
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1393
    ui = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1394
        """Main ui instance for this instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1395
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1396
    sharedpath = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1397
        """Path to the .hg directory of the repo this repo was shared from.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1398
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1399
    store = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1400
        """A store instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1401
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1402
    spath = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1403
        """Path to the store.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1404
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1405
    sjoin = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1406
        """Alias to self.store.join.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1407
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1408
    cachevfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1409
        """A VFS used to access the cache directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1410
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1411
        Typically .hg/cache.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1412
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1413
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1414
    filteredrevcache = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1415
        """Holds sets of revisions to be filtered.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1416
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1417
    names = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1418
        """A ``namespaces`` instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1419
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1420
    def close():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1421
        """Close the handle on this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1422
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1423
    def peer():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1424
        """Obtain an object conforming to the ``peer`` interface."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1425
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1426
    def unfiltered():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1427
        """Obtain an unfiltered/raw view of this repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1428
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1429
    def filtered(name, visibilityexceptions=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1430
        """Obtain a named view of this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1431
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1432
    obsstore = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1433
        """A store of obsolescence data.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1434
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1435
    changelog = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1436
        """A handle on the changelog revlog.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1437
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1438
    manifestlog = interfaceutil.Attribute(
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1439
        """An instance conforming to the ``imanifestlog`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1440
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1441
        Provides access to manifests for the repository.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1442
        """)
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1443
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1444
    dirstate = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1445
        """Working directory state.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1446
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1447
    narrowpats = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1448
        """Matcher patterns for this repository's narrowspec.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1449
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1450
    def narrowmatch():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1451
        """Obtain a matcher for the narrowspec."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1452
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1453
    def setnarrowpats(newincludes, newexcludes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1454
        """Define the narrowspec for this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1455
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1456
    def __getitem__(changeid):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1457
        """Try to resolve a changectx."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1458
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1459
    def __contains__(changeid):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1460
        """Whether a changeset exists."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1461
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1462
    def __nonzero__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1463
        """Always returns True."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1464
        return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1465
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1466
    __bool__ = __nonzero__
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1467
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1468
    def __len__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1469
        """Returns the number of changesets in the repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1470
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1471
    def __iter__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1472
        """Iterate over revisions in the changelog."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1473
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1474
    def revs(expr, *args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1475
        """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1476
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1477
        Emits revisions.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1478
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1479
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1480
    def set(expr, *args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1481
        """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1482
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1483
        Emits changectx instances.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1484
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1485
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1486
    def anyrevs(specs, user=False, localalias=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1487
        """Find revisions matching one of the given revsets."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1488
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1489
    def url():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1490
        """Returns a string representing the location of this repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1491
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1492
    def hook(name, throw=False, **args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1493
        """Call a hook."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1494
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1495
    def tags():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1496
        """Return a mapping of tag to node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1497
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1498
    def tagtype(tagname):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1499
        """Return the type of a given tag."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1500
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1501
    def tagslist():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1502
        """Return a list of tags ordered by revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1503
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1504
    def nodetags(node):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1505
        """Return the tags associated with a node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1506
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1507
    def nodebookmarks(node):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1508
        """Return the list of bookmarks pointing to the specified node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1509
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1510
    def branchmap():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1511
        """Return a mapping of branch to heads in that branch."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1512
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1513
    def revbranchcache():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1514
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1515
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1516
    def branchtip(branchtip, ignoremissing=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1517
        """Return the tip node for a given branch."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1518
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1519
    def lookup(key):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1520
        """Resolve the node for a revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1521
37351
fdd22bf6398f localrepo: drop "remote" argument from lookupbranch() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 37320
diff changeset
  1522
    def lookupbranch(key):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1523
        """Look up the branch name of the given revision or branch name."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1524
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1525
    def known(nodes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1526
        """Determine whether a series of nodes is known.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1527
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1528
        Returns a list of bools.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1529
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1530
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1531
    def local():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1532
        """Whether the repository is local."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1533
        return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1534
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1535
    def publishing():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1536
        """Whether the repository is a publishing repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1537
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1538
    def cancopy():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1539
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1540
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1541
    def shared():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1542
        """The type of shared repository or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1543
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1544
    def wjoin(f, *insidef):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1545
        """Calls self.vfs.reljoin(self.root, f, *insidef)"""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1546
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1547
    def setparents(p1, p2):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1548
        """Set the parent nodes of the working directory."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1549
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1550
    def filectx(path, changeid=None, fileid=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1551
        """Obtain a filectx for the given file revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1552
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1553
    def getcwd():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1554
        """Obtain the current working directory from the dirstate."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1555
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1556
    def pathto(f, cwd=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1557
        """Obtain the relative path to a file."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1558
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1559
    def adddatafilter(name, fltr):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1560
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1561
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1562
    def wread(filename):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1563
        """Read a file from wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1564
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1565
    def wwrite(filename, data, flags, backgroundclose=False, **kwargs):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1566
        """Write data to a file in the wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1567
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1568
    def wwritedata(filename, data):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1569
        """Resolve data for writing to the wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1570
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1571
    def currenttransaction():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1572
        """Obtain the current transaction instance or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1573
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1574
    def transaction(desc, report=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1575
        """Open a new transaction to write to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1576
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1577
    def undofiles():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1578
        """Returns a list of (vfs, path) for files to undo transactions."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1579
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1580
    def recover():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1581
        """Roll back an interrupted transaction."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1582
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1583
    def rollback(dryrun=False, force=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1584
        """Undo the last transaction.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1585
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1586
        DANGEROUS.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1587
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1588
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1589
    def updatecaches(tr=None, full=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1590
        """Warm repo caches."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1591
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1592
    def invalidatecaches():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1593
        """Invalidate cached data due to the repository mutating."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1594
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1595
    def invalidatevolatilesets():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1596
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1597
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1598
    def invalidatedirstate():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1599
        """Invalidate the dirstate."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1600
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1601
    def invalidate(clearfilecache=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1602
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1603
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1604
    def invalidateall():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1605
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1606
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1607
    def lock(wait=True):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1608
        """Lock the repository store and return a lock instance."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1609
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1610
    def wlock(wait=True):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1611
        """Lock the non-store parts of the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1612
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1613
    def currentwlock():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1614
        """Return the wlock if it's held or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1615
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1616
    def checkcommitpatterns(wctx, vdirs, match, status, fail):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1617
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1618
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1619
    def commit(text='', user=None, date=None, match=None, force=False,
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1620
               editor=False, extra=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1621
        """Add a new revision to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1622
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1623
    def commitctx(ctx, error=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1624
        """Commit a commitctx instance to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1625
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1626
    def destroying():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1627
        """Inform the repository that nodes are about to be destroyed."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1628
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1629
    def destroyed():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1630
        """Inform the repository that nodes have been destroyed."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1631
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1632
    def status(node1='.', node2=None, match=None, ignored=False,
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1633
               clean=False, unknown=False, listsubrepos=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1634
        """Convenience method to call repo[x].status()."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1635
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1636
    def addpostdsstatus(ps):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1637
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1638
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1639
    def postdsstatus():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1640
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1641
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1642
    def clearpostdsstatus():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1643
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1644
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1645
    def heads(start=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1646
        """Obtain list of nodes that are DAG heads."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1647
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1648
    def branchheads(branch=None, start=None, closed=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1649
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1650
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1651
    def branches(nodes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1652
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1653
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1654
    def between(pairs):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1655
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1656
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1657
    def checkpush(pushop):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1658
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1659
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1660
    prepushoutgoinghooks = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1661
        """util.hooks instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1662
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1663
    def pushkey(namespace, key, old, new):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1664
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1665
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1666
    def listkeys(namespace):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1667
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1668
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1669
    def debugwireargs(one, two, three=None, four=None, five=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1670
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1671
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1672
    def savecommitmessage(text):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1673
        pass
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1674
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1675
class completelocalrepository(ilocalrepositorymain,
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1676
                              ilocalrepositoryfilestorage):
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
  1677
    """Complete interface for a local repository."""