mercurial/repository.py
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 09 Aug 2018 15:40:14 -0700
changeset 39230 b518d495a560
parent 38835 a232e6744ba3
child 39231 b41d023a412a
permissions -rw-r--r--
repository: formalize interfaces for revision deltas and requests Now that we've sufficiently abstracted how revision deltas are produced in changegroup code, we can now start the process of formalizing that as part of the interfaces defined in the repository module. This commit essentially converts the revisiondelta and revisiondeltarequest classes into well-defined interfaces. This is not strictly necessary. But I want all types formalized by the storage interface to have interfaces. This makes it much easier to test for interface conformance and for implementing new storage backends. Because the interface is documented, comments and docstrings from changegroup.py have been dropped. Differential Revision: https://phab.mercurial-scm.org/D4225
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
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    22
class ipeerconnection(interfaceutil.Interface):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
    """Represents a "connection" to a repository.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
    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
    26
    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
    27
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
    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
    29
    outside of this module.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
    """
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    31
    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
    32
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    33
    def url():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
        """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
    35
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
        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
    37
        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
    38
        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
    39
        data leakage.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
        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
    42
        value.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    45
    def local():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
        """Returns a local repository instance.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
        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
    49
        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
    50
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    51
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    52
    def peer():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
        """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
    54
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
        Most implementations will ``return self``.
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
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    58
    def canpush():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
        """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
    60
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    61
    def close():
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
        """Close the connection to this peer.
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
        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
    65
        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
    66
        """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    68
class ipeercapabilities(interfaceutil.Interface):
37610
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    69
    """Peer sub-interface related to capabilities."""
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    70
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    71
    def capable(name):
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    72
        """Determine support for a named capability.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    73
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    74
        Returns ``False`` if capability not supported.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    75
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    76
        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
    77
        if capability support is non-boolean.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    78
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    79
        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
    80
        """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    81
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    82
    def requirecap(name, purpose):
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    83
        """Require a capability to be present.
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
        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
    86
        """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
    87
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
    88
class ipeercommands(interfaceutil.Interface):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    89
    """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
    90
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    91
    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
    92
    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
    93
    """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    94
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
    95
    def branchmap():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    96
        """Obtain heads in named branches.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    97
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
    98
        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
    99
        heads on that branch.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   100
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   101
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   102
    def capabilities():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   103
        """Obtain capabilities of the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   104
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   105
        Returns a set of string capabilities.
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
37649
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   108
    def clonebundles():
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   109
        """Obtains the clone bundles manifest for the repo.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   110
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   111
        Returns the manifest as unparsed bytes.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   112
        """
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
   113
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   114
    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
   115
        """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
   116
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   117
    def getbundle(source, **kwargs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   118
        """Obtain remote repository data as a bundle.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   119
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   120
        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
   121
        the peer to the local repository
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   122
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   123
        Returns a generator of bundle data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   124
        """
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 heads():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   127
        """Determine all known head revisions in the peer.
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
        Returns an iterable of binary nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   130
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   131
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   132
    def known(nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   133
        """Determine whether multiple nodes are known.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   134
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   135
        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
   136
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   137
        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
   138
        at that index is known to the peer.
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 listkeys(namespace):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   142
        """Obtain all keys in a pushkey namespace.
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
        Returns an iterable of key names.
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
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   147
    def lookup(key):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   148
        """Resolve a value to a known revision.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   149
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   150
        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
   151
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   152
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   153
    def pushkey(namespace, key, old, new):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   154
        """Set a value using the ``pushkey`` protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   155
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   156
        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
   157
        the old and new values for that key.
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 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
   160
        namespace.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   161
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   162
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   163
    def stream_out():
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   164
        """Obtain streaming clone data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   165
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   166
        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
   167
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   168
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   169
    def unbundle(bundle, heads, url):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   170
        """Transfer repository data to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   171
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   172
        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
   173
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   174
        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
   175
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   176
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   177
class ipeerlegacycommands(interfaceutil.Interface):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   178
    """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
   179
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   180
    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
   181
    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
   182
    legacy, the interfaces are split.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   183
    """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   184
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   185
    def between(pairs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   186
        """Obtain nodes between pairs of nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   187
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   188
        ``pairs`` is an iterable of node pairs.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   189
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   190
        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
   191
        requested pair.
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 branches(nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   195
        """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
   196
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   197
        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
   198
        a DAG root or is a merge.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   199
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   200
        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
   201
        """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   202
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37633
diff changeset
   203
    def changegroup(nodes, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   204
        """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
   205
37635
cc8c06835097 wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37633
diff changeset
   206
    def changegroupsubset(bases, heads, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   207
        pass
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   208
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   209
class ipeercommandexecutor(interfaceutil.Interface):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   210
    """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
   211
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   212
    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
   213
    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
   214
    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
   215
    outstanding requests are waited on.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   216
    """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   217
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   218
    def callcommand(name, args):
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   219
        """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
   220
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   221
        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
   222
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   223
        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
   224
        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
   225
        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
   226
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   227
        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
   228
        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
   229
        used and the command itself.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   230
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   231
        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
   232
        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
   233
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   234
        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
   235
        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
   236
        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
   237
        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
   238
        """
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
    def sendcommands():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   241
        """Trigger submission of queued command requests.
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
        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
   244
        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
   245
        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
   246
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   247
        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
   248
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   249
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   250
    def close():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   251
        """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
   252
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   253
        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
   254
        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
   255
        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
   256
        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
   257
        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
   258
        to finish.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   259
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   260
        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
   261
        context manager.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   262
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   263
        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
   264
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   265
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   266
class ipeerrequests(interfaceutil.Interface):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   267
    """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
   268
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   269
    def commandexecutor():
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   270
        """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
   271
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   272
        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
   273
        to the peer.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   274
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   275
        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
   276
        requests.
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
        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
   279
        (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
   280
        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
   281
        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
   282
        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
   283
        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
   284
        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
   285
        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
   286
        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
   287
        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
   288
        being issued.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   289
        """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
   290
37650
62ebfda864de repository: remove ipeercommands from ipeerbase
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37649
diff changeset
   291
class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   292
    """Unified interface for peer repositories.
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   293
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   294
    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
   295
    """
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
   296
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   297
@interfaceutil.implementer(ipeerbase)
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   298
class peer(object):
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   299
    """Base class for peer repositories."""
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   300
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
   301
    def capable(self, name):
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   302
        caps = self.capabilities()
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   303
        if name in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   304
            return True
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   305
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   306
        name = '%s=' % name
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   307
        for cap in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   308
            if cap.startswith(name):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   309
                return cap[len(name):]
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   310
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   311
        return False
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   312
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   313
    def requirecap(self, name, purpose):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   314
        if self.capable(name):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   315
            return
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   316
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   317
        raise error.CapabilityError(
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   318
            _('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
   319
              'capability') % (purpose, name))
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
   320
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   321
class irevisiondelta(interfaceutil.Interface):
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   322
    """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
   323
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   324
    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
   325
    with another repository.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   326
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   327
    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
   328
    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
   329
    are mutually exclusive.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   330
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   331
    Typically used for changegroup generation.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   332
    """
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   333
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   334
    node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   335
        """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
   336
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   337
    p1node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   338
        """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
   339
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   340
    p2node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   341
        """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
   342
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   343
    linknode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   344
        """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
   345
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   346
    flags = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   347
        """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
   348
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   349
    basenode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   350
        """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
   351
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   352
        ``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
   353
        a delta.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   354
        """)
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
    baserevisionsize = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   357
        """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
   358
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   359
        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
   360
        """)
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
    revision = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   363
        """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
   364
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   365
    delta = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   366
        """Delta between ``basenode`` and ``node``.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   367
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   368
        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
   369
        """)
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   370
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   371
class irevisiondeltarequest(interfaceutil.Interface):
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   372
    """Represents a request to generate an ``irevisiondelta``."""
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   373
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   374
    node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   375
        """20 byte node of revision being requested.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   376
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   377
    p1node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   378
        """20 byte node of 1st parent of revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   379
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   380
    p2node = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   381
        """20 byte node of 2nd parent of revision.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   382
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   383
    linknode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   384
        """20 byte node to store in ``linknode`` attribute.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   385
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   386
    basenode = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   387
        """Base revision that delta should be generated against.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   388
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   389
        If ``nullid``, the derived ``irevisiondelta`` should have its
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   390
        ``revision`` field populated and no delta should be generated.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   391
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   392
        If ``None``, the delta may be generated against any revision that
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   393
        is an ancestor of this revision. Or a full revision may be used.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   394
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   395
        If any other value, the delta should be produced against that
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   396
        revision.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   397
        """)
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
    ellipsis = interfaceutil.Attribute(
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   400
        """Boolean on whether the ellipsis flag should be set.""")
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
   401
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   402
class ifilerevisionssequence(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   403
    """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
   404
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   405
    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
   406
    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
   407
    index metadata.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   408
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   409
    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
   410
    in the index.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   411
    """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   412
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   413
    def __len__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   414
        """The total number of revisions."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   415
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   416
    def __getitem__(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   417
        """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
   418
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   419
        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
   420
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   421
        offset+flags
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   422
           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
   423
           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
   424
           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
   425
        compressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   426
            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
   427
            needed by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   428
        uncompressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   429
            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
   430
        base revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   431
            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
   432
            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
   433
        link revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   434
            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
   435
        p1 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   436
            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
   437
        p2 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   438
            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
   439
        node
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   440
            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
   441
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   442
        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
   443
        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
   444
        recent revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   445
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   446
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   447
    def __contains__(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   448
        """Whether a revision number exists."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   449
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   450
    def insert(self, i, entry):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   451
        """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
   452
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   453
class ifileindex(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   454
    """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
   455
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   456
    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
   457
    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
   458
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   459
    The index logically consists of:
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   460
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   461
    * 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
   462
    * 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
   463
    * Metadata to facilitate storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   464
    """
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   465
    index = interfaceutil.Attribute(
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   466
        """An ``ifilerevisionssequence`` instance.""")
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   467
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   468
    def __len__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   469
        """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
   470
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   471
    def __iter__():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   472
        """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
   473
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   474
    def revs(start=0, stop=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   475
        """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
   476
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   477
    def parents(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   478
        """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
   479
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   480
        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
   481
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   482
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   483
    def parentrevs(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   484
        """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
   485
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   486
    def rev(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   487
        """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
   488
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   489
        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
   490
        """
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
    def node(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   493
        """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
   494
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   495
        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
   496
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   497
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   498
    def lookup(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   499
        """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
   500
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   501
        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
   502
        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
   503
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   504
        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
   505
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   506
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   507
    def linkrev(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   508
        """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
   509
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   510
    def flags(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   511
        """Obtain flags used to affect storage of a revision."""
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
    def iscensored(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   514
        """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
   515
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   516
    def commonancestorsheads(node1, node2):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   517
        """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
   518
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   519
        See ``ancestor.commonancestorsheads()``.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   520
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   521
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   522
    def descendants(revs):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   523
        """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
   524
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   525
        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
   526
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   527
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   528
    def headrevs():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   529
        """Obtain a list of revision numbers that are DAG heads.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   530
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   531
        The list is sorted oldest to newest.
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
        TODO determine if sorting is required.
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
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   536
    def heads(start=None, stop=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   537
        """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
   538
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   539
        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
   540
        ``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
   541
        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
   542
        ``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
   543
        encountered.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   544
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   545
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   546
    def children(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   547
        """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
   548
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   549
        Returns a list of nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   550
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   551
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   552
    def deltaparent(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   553
        """"Return the revision that is a suitable parent to delta against."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   554
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   555
    def candelta(baserev, rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   556
        """"Whether a delta can be generated between two revisions."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   557
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   558
class ifiledata(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   559
    """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
   560
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   561
    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
   562
    data for a tracked file.
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
    def rawsize(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   565
        """The size of the fulltext data for a revision as stored."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   566
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   567
    def size(rev):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   568
        """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
   569
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   570
        Any metadata is excluded from size measurements. Use ``rawsize()`` if
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   571
        metadata size is important.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   572
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   573
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   574
    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
   575
        """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
   576
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   577
        Raises ``error.RevlogError`` is hash validation fails.
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
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   580
    def revision(node, raw=False):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   581
        """"Obtain fulltext data for a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   582
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   583
        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
   584
        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
   585
        are not applied.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   586
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   587
        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
   588
        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
   589
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   590
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   591
    def read(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   592
        """Resolve file fulltext data.
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
        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
   595
        headers is stripped.
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
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   598
    def renamed(node):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   599
        """Obtain copy metadata for a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   600
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   601
        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
   602
        (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
   603
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   604
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   605
    def cmp(node, fulltext):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   606
        """Compare fulltext to another revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   607
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   608
        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
   609
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   610
        This takes copy metadata into account.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   611
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   612
        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
   613
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   614
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   615
    def revdiff(rev1, rev2):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   616
        """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
   617
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   618
        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
   619
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   620
        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
   621
        revision data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   622
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   623
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   624
class ifilemutation(interfaceutil.Interface):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   625
    """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
   626
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   627
    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
   628
        """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
   629
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   630
        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
   631
        and parent nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   632
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   633
        Returns the node that was added.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   634
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   635
        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
   636
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   637
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   638
    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
   639
                    flags=0, cachedelta=None):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   640
        """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
   641
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   642
        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
   643
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   644
        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
   645
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   646
        ``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
   647
        the flags to use with storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   648
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   649
        ``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
   650
        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
   651
        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
   652
        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
   653
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   654
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   655
    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
   656
        """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
   657
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   658
        ``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
   659
        (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
   660
        to add.
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
        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
   663
        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
   664
        ``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
   665
        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
   666
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   667
        ``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
   668
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   669
        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
   670
        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
   671
        """
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
    def getstrippoint(minlink):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   674
        """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
   675
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   676
        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
   677
        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
   678
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   679
        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
   680
        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
   681
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   682
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   683
    def strip(minlink, transaction):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   684
        """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
   685
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   686
        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
   687
        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
   688
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   689
        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
   690
        higher-level deletion API.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   691
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   692
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   693
class ifilestorage(ifileindex, ifiledata, ifilemutation):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   694
    """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
   695
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   696
    version = interfaceutil.Attribute(
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   697
        """Version number of storage.
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
        TODO this feels revlog centric and could likely be removed.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   700
        """)
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   701
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   702
    storedeltachains = interfaceutil.Attribute(
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   703
        """Whether the store stores deltas.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   704
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   705
        TODO deltachains are revlog centric. This can probably removed
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   706
        once there are better abstractions for obtaining/writing
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   707
        data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   708
        """)
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   709
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
   710
    _generaldelta = interfaceutil.Attribute(
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   711
        """Whether deltas can be against any parent revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   712
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   713
        TODO this is used by changegroup code and it could probably be
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   714
        folded into another API.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   715
        """)
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   716
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   717
    def files():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   718
        """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
   719
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   720
        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
   721
        be a better API for that.
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
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   724
    def checksize():
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   725
        """Obtain the expected sizes of backing files.
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
        TODO this is used by verify and it should not be part of the interface.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   728
        """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
   729
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   730
class idirs(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   731
    """Interface representing a collection of directories from paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   732
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   733
    This interface is essentially a derived data structure representing
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   734
    directories from a collection of paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   735
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   736
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   737
    def addpath(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   738
        """Add a path to the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   739
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   740
        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
   741
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   742
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   743
    def delpath(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   744
        """Remove a path from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   745
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   746
        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
   747
        directory is removed from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   748
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   749
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   750
    def __iter__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   751
        """Iterate over the directories in this collection of paths."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   752
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   753
    def __contains__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   754
        """Whether a specific directory is in this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   755
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   756
class imanifestdict(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   757
    """Interface representing a manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   758
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   759
    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
   760
    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
   761
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   762
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   763
    def __getitem__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   764
        """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
   765
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   766
        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
   767
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   768
        Equivalent to ``self.find(path)[0]``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   769
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   770
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   771
    def find(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   772
        """Returns the entry for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   773
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   774
        Returns a 2-tuple of (node, flags).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   775
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   776
        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
   777
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   778
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   779
    def __len__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   780
        """Return the number of entries in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   781
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   782
    def __nonzero__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   783
        """Returns True if the manifest has entries, False otherwise."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   784
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   785
    __bool__ = __nonzero__
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   786
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   787
    def __setitem__(path, node):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   788
        """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
   789
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   790
        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
   791
        the new entry.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   792
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   793
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   794
    def __contains__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   795
        """Whether a path exists in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   796
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   797
    def __delitem__(path):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   798
        """Remove a path from the manifest.
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
        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
   801
        """
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
    def __iter__():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   804
        """Iterate over paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   805
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   806
    def iterkeys():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   807
        """Iterate over paths in the manifest."""
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
    def keys():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   810
        """Obtain a list of paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   811
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   812
    def filesnotin(other, match=None):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   813
        """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
   814
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   815
        ``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
   816
        manifests.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   817
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   818
        Returns a set 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
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   821
    def dirs():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   822
        """Returns an object implementing the ``idirs`` interface."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   823
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   824
    def hasdir(dir):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   825
        """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
   826
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   827
    def matches(match):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   828
        """Generate a new manifest filtered through a matcher.
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
        Returns an object conforming to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   831
        """
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
    def walk(match):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   834
        """Generator of paths in manifest satisfying a matcher.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   835
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   836
        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
   837
        manifest object is not created.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   838
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   839
        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
   840
        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
   841
        """
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
    def diff(other, match=None, clean=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   844
        """Find differences between this manifest and another.
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
        This manifest is compared to ``other``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   847
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   848
        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
   849
        matcher and only entries satisfying the matcher are compared.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   850
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   851
        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
   852
        object.
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
        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
   855
        the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   856
        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
   857
        are the same for the other manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   858
        """
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
    def setflag(path, flag):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   861
        """Set the flag value for a given path.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   862
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   863
        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
   864
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   865
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   866
    def get(path, default=None):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   867
        """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
   868
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   869
    def flags(path, default=''):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   870
        """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
   871
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   872
    def copy():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   873
        """Return a copy of this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   874
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   875
    def items():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   876
        """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
   877
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   878
    def iteritems():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   879
        """Identical to items()."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   880
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   881
    def iterentries():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   882
        """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
   883
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   884
        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
   885
        flags.
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 text():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   889
        """Obtain the raw data representation for this manifest.
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
        Result is used to create a manifest revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   892
        """
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 fastdelta(base, changes):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   895
        """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
   896
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   897
        ``base`` in the raw data representation for another manifest.
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
        ``changes`` is an iterable of ``(path, to_delete)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   900
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   901
        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
   902
        delta between ``base`` and this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   903
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   904
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   905
class imanifestrevisionbase(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   906
    """Base interface representing a single revision of a manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   907
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   908
    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
   909
    as part of a larger interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   910
    """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   911
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   912
    def new():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   913
        """Obtain a new manifest instance.
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
        Returns an object conforming to the ``imanifestrevisionwritable``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   916
        interface. The instance will be associated with the same
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   917
        ``imanifestlog`` collection as this instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   918
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   919
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   920
    def copy():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   921
        """Obtain a copy of this manifest instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   922
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   923
        Returns an object conforming to the ``imanifestrevisionwritable``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   924
        interface. The instance will be associated with the same
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   925
        ``imanifestlog`` collection as this instance.
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
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   928
    def read():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   929
        """Obtain the parsed manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   930
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   931
        The returned object conforms to the ``imanifestdict`` interface.
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
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   934
class imanifestrevisionstored(imanifestrevisionbase):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   935
    """Interface representing a manifest revision committed to storage."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   936
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   937
    def node():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   938
        """The binary node for this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   939
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   940
    parents = interfaceutil.Attribute(
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   941
        """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
   942
    )
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   943
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   944
    def readdelta(shallow=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   945
        """Obtain the manifest data structure representing changes from parent.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   946
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   947
        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
   948
        those differences is constructed.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   949
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   950
        The returned object conforms to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   951
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   952
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   953
    def readfast(shallow=False):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   954
        """Calls either ``read()`` or ``readdelta()``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   955
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   956
        The faster of the two options is called.
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
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   959
    def find(key):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   960
        """Calls self.read().find(key)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   961
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   962
        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
   963
        """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   964
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   965
class imanifestrevisionwritable(imanifestrevisionbase):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   966
    """Interface representing a manifest revision that can be committed."""
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
    def write(transaction, linkrev, p1node, p2node, added, removed):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   969
        """Add this revision to storage.
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
        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
   972
        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
   973
        removed paths.
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
        Returns the binary node of the created revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   976
        """
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
class imanifestlog(interfaceutil.Interface):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   979
    """Interface representing a collection of manifest snapshots."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   980
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   981
    def __getitem__(node):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   982
        """Obtain a manifest instance for a given binary node.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   983
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   984
        Equivalent to calling ``self.get('', node)``.
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
        The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   987
        interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   988
        """
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
    def get(dir, node, verify=True):
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   991
        """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
   992
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   993
        ``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
   994
        the only manifest if flat manifests are being used).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   995
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   996
        If ``dir`` is the empty string, the root manifest is returned. Otherwise
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   997
        the manifest for the specified directory will be returned (requires
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
   998
        tree manifests).
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
        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
  1001
        known.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1002
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1003
        The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1004
        interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1005
        """
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
    def clearcaches():
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1008
        """Clear caches associated with this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1009
38555
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1010
    def rev(node):
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1011
        """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
  1012
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1013
        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
  1014
        """
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
  1015
38556
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1016
    def addgroup(deltas, linkmapper, transaction):
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1017
        """Process a series of deltas for storage.
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1018
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1019
        ``deltas`` is an iterable of 7-tuples of
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1020
        (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1021
        to add.
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1022
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1023
        The ``delta`` field contains ``mpatch`` data to apply to a base
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1024
        revision, identified by ``deltabase``. The base node can be
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1025
        ``nullid``, in which case the header from the delta can be ignored
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1026
        and the delta used as the fulltext.
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1027
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1028
        Returns a list of nodes that were processed. A node will be in the list
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1029
        even if it existed in the store previously.
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1030
        """
0db41eb0a3ac manifest: define and implement addgroup() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38555
diff changeset
  1031
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1032
class completelocalrepository(interfaceutil.Interface):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1033
    """Monolithic interface for local repositories.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1034
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1035
    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
  1036
    """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1037
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1038
    supportedformats = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1039
        """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
  1040
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1041
        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
  1042
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1043
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1044
    openerreqs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1045
        """Set of requirements that are passed to the opener.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1046
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1047
        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
  1048
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1049
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1050
    supported = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1051
        """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
  1052
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1053
    requirements = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1054
        """Set of requirements this repo uses.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1055
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1056
    filtername = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1057
        """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
  1058
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1059
    wvfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1060
        """VFS used to access the working directory.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1061
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1062
    vfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1063
        """VFS rooted at the .hg directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1064
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1065
        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
  1066
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1067
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1068
    svfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1069
        """VFS rooted at the store.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1070
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1071
        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
  1072
        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
  1073
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1074
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1075
    root = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1076
        """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
  1077
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1078
    path = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1079
        """Path to the .hg directory.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1080
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1081
    origroot = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1082
        """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
  1083
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1084
    auditor = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1085
        """A pathauditor for the working directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1086
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1087
        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
  1088
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1089
        Operates on the filesystem.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1090
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1091
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1092
    nofsauditor = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1093
        """A pathauditor for the working directory.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1094
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1095
        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
  1096
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1097
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1098
    baseui = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1099
        """Original ui instance passed into constructor.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1100
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1101
    ui = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1102
        """Main ui instance for this instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1103
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1104
    sharedpath = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1105
        """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
  1106
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1107
    store = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1108
        """A store instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1109
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1110
    spath = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1111
        """Path to the store.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1112
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1113
    sjoin = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1114
        """Alias to self.store.join.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1115
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1116
    cachevfs = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1117
        """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
  1118
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1119
        Typically .hg/cache.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1120
        """)
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1121
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1122
    filteredrevcache = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1123
        """Holds sets of revisions to be filtered.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1124
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1125
    names = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1126
        """A ``namespaces`` instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1127
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1128
    def close():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1129
        """Close the handle on this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1130
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1131
    def peer():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1132
        """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
  1133
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1134
    def unfiltered():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1135
        """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
  1136
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1137
    def filtered(name, visibilityexceptions=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1138
        """Obtain a named view of this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1139
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1140
    obsstore = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1141
        """A store of obsolescence data.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1142
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1143
    changelog = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1144
        """A handle on the changelog revlog.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1145
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1146
    manifestlog = interfaceutil.Attribute(
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1147
        """An instance conforming to the ``imanifestlog`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1148
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1149
        Provides access to manifests for the repository.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
  1150
        """)
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1151
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1152
    dirstate = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1153
        """Working directory state.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1154
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1155
    narrowpats = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1156
        """Matcher patterns for this repository's narrowspec.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1157
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1158
    def narrowmatch():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1159
        """Obtain a matcher for the narrowspec."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1160
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1161
    def setnarrowpats(newincludes, newexcludes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1162
        """Define the narrowspec for this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1163
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1164
    def __getitem__(changeid):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1165
        """Try to resolve a changectx."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1166
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1167
    def __contains__(changeid):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1168
        """Whether a changeset exists."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1169
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1170
    def __nonzero__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1171
        """Always returns True."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1172
        return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1173
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1174
    __bool__ = __nonzero__
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1175
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1176
    def __len__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1177
        """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
  1178
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1179
    def __iter__():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1180
        """Iterate over revisions in the changelog."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1182
    def revs(expr, *args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1183
        """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1184
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1185
        Emits revisions.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1186
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1187
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1188
    def set(expr, *args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1189
        """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1190
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1191
        Emits changectx instances.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1192
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1193
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1194
    def anyrevs(specs, user=False, localalias=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1195
        """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
  1196
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1197
    def url():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1198
        """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
  1199
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1200
    def hook(name, throw=False, **args):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1201
        """Call a hook."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1202
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1203
    def tags():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1204
        """Return a mapping of tag to node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1205
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1206
    def tagtype(tagname):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1207
        """Return the type of a given tag."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1208
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1209
    def tagslist():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1210
        """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
  1211
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1212
    def nodetags(node):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1213
        """Return the tags associated with a node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1214
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1215
    def nodebookmarks(node):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1216
        """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
  1217
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1218
    def branchmap():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1219
        """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
  1220
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1221
    def revbranchcache():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1222
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1223
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1224
    def branchtip(branchtip, ignoremissing=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1225
        """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
  1226
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1227
    def lookup(key):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1228
        """Resolve the node for a revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1229
37351
fdd22bf6398f localrepo: drop "remote" argument from lookupbranch() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 37320
diff changeset
  1230
    def lookupbranch(key):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1231
        """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
  1232
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1233
    def known(nodes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1234
        """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
  1235
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1236
        Returns a list of bools.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1237
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1238
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1239
    def local():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1240
        """Whether the repository is local."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1241
        return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1242
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1243
    def publishing():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1244
        """Whether the repository is a publishing repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1245
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1246
    def cancopy():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1247
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1248
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1249
    def shared():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1250
        """The type of shared repository or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1251
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1252
    def wjoin(f, *insidef):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1253
        """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
  1254
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1255
    def file(f):
38509
5cfb01d5ff26 repository: document that file() return value conforms to interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37810
diff changeset
  1256
        """Obtain a filelog for a tracked path.
5cfb01d5ff26 repository: document that file() return value conforms to interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37810
diff changeset
  1257
5cfb01d5ff26 repository: document that file() return value conforms to interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37810
diff changeset
  1258
        The returned type conforms to the ``ifilestorage`` interface.
5cfb01d5ff26 repository: document that file() return value conforms to interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37810
diff changeset
  1259
        """
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1260
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1261
    def setparents(p1, p2):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1262
        """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
  1263
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1264
    def filectx(path, changeid=None, fileid=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1265
        """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
  1266
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1267
    def getcwd():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1268
        """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
  1269
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1270
    def pathto(f, cwd=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1271
        """Obtain the relative path to a file."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1272
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1273
    def adddatafilter(name, fltr):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1274
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1275
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1276
    def wread(filename):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1277
        """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
  1278
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1279
    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
  1280
        """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
  1281
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1282
    def wwritedata(filename, data):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1283
        """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
  1284
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1285
    def currenttransaction():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1286
        """Obtain the current transaction instance or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1287
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1288
    def transaction(desc, report=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1289
        """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
  1290
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1291
    def undofiles():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1292
        """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
  1293
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1294
    def recover():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1295
        """Roll back an interrupted transaction."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1296
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1297
    def rollback(dryrun=False, force=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1298
        """Undo the last transaction.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1299
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1300
        DANGEROUS.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1301
        """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1302
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1303
    def updatecaches(tr=None, full=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1304
        """Warm repo caches."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1305
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1306
    def invalidatecaches():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1307
        """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
  1308
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1309
    def invalidatevolatilesets():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1310
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1311
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1312
    def invalidatedirstate():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1313
        """Invalidate the dirstate."""
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
    def invalidate(clearfilecache=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1316
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1317
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1318
    def invalidateall():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1319
        pass
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
    def lock(wait=True):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1322
        """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
  1323
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1324
    def wlock(wait=True):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1325
        """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
  1326
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1327
    def currentwlock():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1328
        """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
  1329
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1330
    def checkcommitpatterns(wctx, vdirs, match, status, fail):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1331
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1332
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1333
    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
  1334
               editor=False, extra=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1335
        """Add a new revision to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1336
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1337
    def commitctx(ctx, error=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1338
        """Commit a commitctx instance to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1339
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1340
    def destroying():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1341
        """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
  1342
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1343
    def destroyed():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1344
        """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
  1345
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1346
    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
  1347
               clean=False, unknown=False, listsubrepos=False):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1348
        """Convenience method to call repo[x].status()."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1349
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1350
    def addpostdsstatus(ps):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1351
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1352
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1353
    def postdsstatus():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1354
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1355
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1356
    def clearpostdsstatus():
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1357
        pass
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
    def heads(start=None):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1360
        """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
  1361
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1362
    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
  1363
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1364
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1365
    def branches(nodes):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1366
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1367
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1368
    def between(pairs):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1369
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1370
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1371
    def checkpush(pushop):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1372
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1373
37810
856f381ad74b interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37650
diff changeset
  1374
    prepushoutgoinghooks = interfaceutil.Attribute(
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1375
        """util.hooks instance.""")
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1376
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1377
    def pushkey(namespace, key, old, new):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1378
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1379
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1380
    def listkeys(namespace):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1381
        pass
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
    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
  1384
        pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1385
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1386
    def savecommitmessage(text):
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
  1387
        pass