author | Martin von Zweigbergk <martinvonz@google.com> |
Sat, 31 Mar 2018 23:26:07 -0700 | |
changeset 37259 | f290f130d7fc |
parent 37183 | 0dfb5672f015 |
child 37316 | 836867586b83 |
permissions | -rw-r--r-- |
33821
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 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
import abc |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
|
33823
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
12 |
from .i18n import _ |
37183
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
13 |
from .thirdparty.zope import ( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
14 |
interface as zi, |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
15 |
) |
33823
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
16 |
from . import ( |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
17 |
error, |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
18 |
) |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
19 |
|
33821
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 |
class _basepeer(object): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
"""Represents a "connection" to a repository. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
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
|
27 |
outside of this module. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
__metaclass__ = abc.ABCMeta |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 |
@abc.abstractproperty |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
def ui(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
"""ui.ui instance.""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 |
@abc.abstractmethod |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
def url(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 |
"""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
|
38 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
data leakage. |
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 |
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
|
45 |
value. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 |
""" |
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 |
@abc.abstractmethod |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
def local(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 |
"""Returns a local repository instance. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
56 |
@abc.abstractmethod |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
57 |
def peer(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 |
"""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
|
59 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
60 |
Most implementations will ``return self``. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
61 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
62 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 |
@abc.abstractmethod |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
64 |
def canpush(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
65 |
"""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
|
66 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
67 |
@abc.abstractmethod |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
68 |
def close(self): |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
69 |
"""Close the connection to this peer. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
70 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 |
|
33822
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
75 |
class _basewirecommands(object): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
76 |
"""Client-side interface for communicating over the wire protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
77 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
78 |
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:
33821
diff
changeset
|
79 |
methods commonly call wire protocol commands of the same name. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
80 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
81 |
__metaclass__ = abc.ABCMeta |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
82 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
83 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
84 |
def branchmap(self): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
85 |
"""Obtain heads in named branches. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
86 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
87 |
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:
33821
diff
changeset
|
88 |
heads on that branch. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
89 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
90 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
91 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
92 |
def capabilities(self): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
93 |
"""Obtain capabilities of the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
94 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
95 |
Returns a set of string capabilities. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
96 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
97 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
98 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
99 |
def debugwireargs(self, one, two, three=None, four=None, five=None): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
100 |
"""Used to facilitate debugging of arguments passed over the wire.""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
101 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
102 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
103 |
def getbundle(self, source, **kwargs): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
104 |
"""Obtain remote repository data as a bundle. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
105 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
106 |
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:
33821
diff
changeset
|
107 |
the peer to the local repository |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
108 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
109 |
Returns a generator of bundle data. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
110 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
111 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
112 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
113 |
def heads(self): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
114 |
"""Determine all known head revisions in the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
115 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
116 |
Returns an iterable of binary nodes. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
117 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
118 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
119 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
120 |
def known(self, nodes): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
121 |
"""Determine whether multiple nodes are known. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
122 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
123 |
Accepts an iterable of nodes whose presence to check for. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
124 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
125 |
Returns an iterable of booleans indicating of the corresponding node |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
126 |
at that index is known to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
127 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
128 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
129 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
130 |
def listkeys(self, namespace): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
131 |
"""Obtain all keys in a pushkey namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
132 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
133 |
Returns an iterable of key names. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
134 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
135 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
136 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
137 |
def lookup(self, key): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
138 |
"""Resolve a value to a known revision. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
139 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
140 |
Returns a binary node of the resolved revision on success. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
141 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
142 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
143 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
144 |
def pushkey(self, namespace, key, old, new): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
145 |
"""Set a value using the ``pushkey`` protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
146 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
147 |
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:
33821
diff
changeset
|
148 |
the old and new values for that key. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
149 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
150 |
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:
33821
diff
changeset
|
151 |
namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
152 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
153 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
154 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
155 |
def stream_out(self): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
156 |
"""Obtain streaming clone data. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
157 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
158 |
Successful result should be a generator of data chunks. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
159 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
160 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
161 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
162 |
def unbundle(self, bundle, heads, url): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
163 |
"""Transfer repository data to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
164 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
165 |
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:
33821
diff
changeset
|
166 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
167 |
Returns the integer number of heads added to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
168 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
169 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
170 |
class _baselegacywirecommands(object): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
171 |
"""Interface for implementing support for legacy wire protocol commands. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
172 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
173 |
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:
33821
diff
changeset
|
174 |
used by modern clients. To facilitate identifying which commands are |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
175 |
legacy, the interfaces are split. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
176 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
177 |
__metaclass__ = abc.ABCMeta |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
178 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
179 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
180 |
def between(self, pairs): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
181 |
"""Obtain nodes between pairs of nodes. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
182 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
183 |
``pairs`` is an iterable of node pairs. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
184 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
185 |
Returns an iterable of iterables of nodes corresponding to each |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
186 |
requested pair. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
187 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
188 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
189 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
190 |
def branches(self, nodes): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
191 |
"""Obtain ancestor changesets of specific nodes back to a branch point. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
192 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
193 |
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:
33821
diff
changeset
|
194 |
a DAG root or is a merge. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
195 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
196 |
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:
33821
diff
changeset
|
197 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
198 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
199 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
200 |
def changegroup(self, nodes, kind): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
201 |
"""Obtain a changegroup with data for descendants of specified nodes.""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
202 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
203 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
204 |
def changegroupsubset(self, bases, heads, kind): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
205 |
pass |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
206 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
207 |
class peer(_basepeer, _basewirecommands): |
33821
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 |
"""Unified interface and base class for peer repositories. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
209 |
|
33822
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
210 |
All peer instances must inherit from this class and conform to its |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
211 |
interface. |
33821
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
212 |
""" |
33822
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
213 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
214 |
@abc.abstractmethod |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
215 |
def iterbatch(self): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
216 |
"""Obtain an object to be used for multiple method calls. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
217 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
218 |
Various operations call several methods on peer instances. If each |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
219 |
method call were performed immediately and serially, this would |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
220 |
require round trips to remote peers and/or would slow down execution. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
221 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
222 |
Some peers have the ability to "batch" method calls to avoid costly |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
223 |
round trips or to facilitate concurrent execution. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
224 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
225 |
This method returns an object that can be used to indicate intent to |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
226 |
perform batched method calls. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
227 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
228 |
The returned object is a proxy of this peer. It intercepts calls to |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
229 |
batchable methods and queues them instead of performing them |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
230 |
immediately. This proxy object has a ``submit`` method that will |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
231 |
perform all queued batchable method calls. A ``results()`` method |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
232 |
exposes the results of queued/batched method calls. It is a generator |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
233 |
of results in the order they were called. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
234 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
235 |
Not all peers or wire protocol implementations may actually batch method |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
236 |
calls. However, they must all support this API. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
237 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
238 |
|
33823
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
239 |
def capable(self, name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
240 |
"""Determine support for a named capability. |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
241 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
242 |
Returns ``False`` if capability not supported. |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
243 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
244 |
Returns ``True`` if boolean capability is supported. Returns a string |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
245 |
if capability support is non-boolean. |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
246 |
""" |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
247 |
caps = self.capabilities() |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
248 |
if name in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
249 |
return True |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
250 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
251 |
name = '%s=' % name |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
252 |
for cap in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
253 |
if cap.startswith(name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
254 |
return cap[len(name):] |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
255 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
256 |
return False |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
257 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
258 |
def requirecap(self, name, purpose): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
259 |
"""Require a capability to be present. |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
260 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
261 |
Raises a ``CapabilityError`` if the capability isn't present. |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
262 |
""" |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
263 |
if self.capable(name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
264 |
return |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
265 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
266 |
raise error.CapabilityError( |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
267 |
_('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:
33822
diff
changeset
|
268 |
'capability') % (purpose, name)) |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33822
diff
changeset
|
269 |
|
33822
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
270 |
class legacypeer(peer, _baselegacywirecommands): |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33821
diff
changeset
|
271 |
"""peer but with support for legacy wire protocol commands.""" |
37183
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
272 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
273 |
class completelocalrepository(zi.Interface): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
274 |
"""Monolithic interface for local repositories. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
275 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
276 |
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:
33823
diff
changeset
|
277 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
278 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
279 |
supportedformats = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
280 |
"""Set of requirements that apply to stream clone. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
281 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
282 |
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:
33823
diff
changeset
|
283 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
284 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
285 |
openerreqs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
286 |
"""Set of requirements that are passed to the opener. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
287 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
288 |
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:
33823
diff
changeset
|
289 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
290 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
291 |
supported = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
292 |
"""Set of requirements that this repo is capable of opening.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
293 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
294 |
requirements = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
295 |
"""Set of requirements this repo uses.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
296 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
297 |
filtername = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
298 |
"""Name of the repoview that is active on this repo.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
299 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
300 |
wvfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
301 |
"""VFS used to access the working directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
302 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
303 |
vfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
304 |
"""VFS rooted at the .hg directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
305 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
306 |
Used to access repository data not in the store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
307 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
308 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
309 |
svfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
310 |
"""VFS rooted at the store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
311 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
312 |
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:
33823
diff
changeset
|
313 |
But can point elsewhere if the store is shared. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
314 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
315 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
316 |
root = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
317 |
"""Path to the root of the working directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
318 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
319 |
path = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
320 |
"""Path to the .hg directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
321 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
322 |
origroot = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
323 |
"""The filesystem path that was used to construct the repo.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
324 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
325 |
auditor = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
326 |
"""A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
327 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
328 |
This checks if a path refers to a nested repository. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
329 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
330 |
Operates on the filesystem. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
331 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
332 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
333 |
nofsauditor = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
334 |
"""A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
335 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
336 |
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:
33823
diff
changeset
|
337 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
338 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
339 |
baseui = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
340 |
"""Original ui instance passed into constructor.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
341 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
342 |
ui = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
343 |
"""Main ui instance for this instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
344 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
345 |
sharedpath = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
346 |
"""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:
33823
diff
changeset
|
347 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
348 |
store = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
349 |
"""A store instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
350 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
351 |
spath = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
352 |
"""Path to the store.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
353 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
354 |
sjoin = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
355 |
"""Alias to self.store.join.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
356 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
357 |
cachevfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
358 |
"""A VFS used to access the cache directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
359 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
360 |
Typically .hg/cache. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
361 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
362 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
363 |
filteredrevcache = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
364 |
"""Holds sets of revisions to be filtered.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
365 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
366 |
names = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
367 |
"""A ``namespaces`` instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
368 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
369 |
def close(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
370 |
"""Close the handle on this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
371 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
372 |
def peer(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
373 |
"""Obtain an object conforming to the ``peer`` interface.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
374 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
375 |
def unfiltered(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
376 |
"""Obtain an unfiltered/raw view of this repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
377 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
378 |
def filtered(name, visibilityexceptions=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
379 |
"""Obtain a named view of this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
380 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
381 |
obsstore = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
382 |
"""A store of obsolescence data.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
383 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
384 |
changelog = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
385 |
"""A handle on the changelog revlog.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
386 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
387 |
manifestlog = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
388 |
"""A handle on the root manifest revlog.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
389 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
390 |
dirstate = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
391 |
"""Working directory state.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
392 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
393 |
narrowpats = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
394 |
"""Matcher patterns for this repository's narrowspec.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
395 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
396 |
def narrowmatch(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
397 |
"""Obtain a matcher for the narrowspec.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
398 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
399 |
def setnarrowpats(newincludes, newexcludes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
400 |
"""Define the narrowspec for this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
401 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
402 |
def __getitem__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
403 |
"""Try to resolve a changectx.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
404 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
405 |
def __contains__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
406 |
"""Whether a changeset exists.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
407 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
408 |
def __nonzero__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
409 |
"""Always returns True.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
410 |
return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
411 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
412 |
__bool__ = __nonzero__ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
413 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
414 |
def __len__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
415 |
"""Returns the number of changesets in the repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
416 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
417 |
def __iter__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
418 |
"""Iterate over revisions in the changelog.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
419 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
420 |
def revs(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
421 |
"""Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
422 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
423 |
Emits revisions. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
424 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
425 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
426 |
def set(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
427 |
"""Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
428 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
429 |
Emits changectx instances. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
430 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
431 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
432 |
def anyrevs(specs, user=False, localalias=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
433 |
"""Find revisions matching one of the given revsets.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
434 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
435 |
def url(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
436 |
"""Returns a string representing the location of this repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
437 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
438 |
def hook(name, throw=False, **args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
439 |
"""Call a hook.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
440 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
441 |
def tags(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
442 |
"""Return a mapping of tag to node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
443 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
444 |
def tagtype(tagname): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
445 |
"""Return the type of a given tag.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
446 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
447 |
def tagslist(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
448 |
"""Return a list of tags ordered by revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
449 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
450 |
def nodetags(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
451 |
"""Return the tags associated with a node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
452 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
453 |
def nodebookmarks(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
454 |
"""Return the list of bookmarks pointing to the specified node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
455 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
456 |
def branchmap(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
457 |
"""Return a mapping of branch to heads in that branch.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
458 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
459 |
def revbranchcache(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
460 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
461 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
462 |
def branchtip(branchtip, ignoremissing=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
463 |
"""Return the tip node for a given branch.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
464 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
465 |
def lookup(key): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
466 |
"""Resolve the node for a revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
467 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
468 |
def lookupbranch(key, remote=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
469 |
"""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:
33823
diff
changeset
|
470 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
471 |
def known(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
472 |
"""Determine whether a series of nodes is known. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
473 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
474 |
Returns a list of bools. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
475 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
476 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
477 |
def local(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
478 |
"""Whether the repository is local.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
479 |
return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
480 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
481 |
def publishing(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
482 |
"""Whether the repository is a publishing repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
483 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
484 |
def cancopy(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
485 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
486 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
487 |
def shared(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
488 |
"""The type of shared repository or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
489 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
490 |
def wjoin(f, *insidef): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
491 |
"""Calls self.vfs.reljoin(self.root, f, *insidef)""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
492 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
493 |
def file(f): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
494 |
"""Obtain a filelog for a tracked path.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
495 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
496 |
def changectx(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
497 |
"""Obtains a changectx for a revision. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
498 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
499 |
Identical to __getitem__. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
500 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
501 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
502 |
def setparents(p1, p2): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
503 |
"""Set the parent nodes of the working directory.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
504 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
505 |
def filectx(path, changeid=None, fileid=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
506 |
"""Obtain a filectx for the given file revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
507 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
508 |
def getcwd(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
509 |
"""Obtain the current working directory from the dirstate.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
510 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
511 |
def pathto(f, cwd=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
512 |
"""Obtain the relative path to a file.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
513 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
514 |
def adddatafilter(name, fltr): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
515 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
516 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
517 |
def wread(filename): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
518 |
"""Read a file from wvfs, using data filters.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
519 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
520 |
def wwrite(filename, data, flags, backgroundclose=False, **kwargs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
521 |
"""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:
33823
diff
changeset
|
522 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
523 |
def wwritedata(filename, data): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
524 |
"""Resolve data for writing to the wvfs, using data filters.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
525 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
526 |
def currenttransaction(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
527 |
"""Obtain the current transaction instance or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
528 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
529 |
def transaction(desc, report=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
530 |
"""Open a new transaction to write to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
531 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
532 |
def undofiles(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
533 |
"""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:
33823
diff
changeset
|
534 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
535 |
def recover(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
536 |
"""Roll back an interrupted transaction.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
537 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
538 |
def rollback(dryrun=False, force=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
539 |
"""Undo the last transaction. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
540 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
541 |
DANGEROUS. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
542 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
543 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
544 |
def updatecaches(tr=None, full=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
545 |
"""Warm repo caches.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
546 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
547 |
def invalidatecaches(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
548 |
"""Invalidate cached data due to the repository mutating.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
549 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
550 |
def invalidatevolatilesets(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
551 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
552 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
553 |
def invalidatedirstate(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
554 |
"""Invalidate the dirstate.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
555 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
556 |
def invalidate(clearfilecache=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
557 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
558 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
559 |
def invalidateall(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
560 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
561 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
562 |
def lock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
563 |
"""Lock the repository store and return a lock instance.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
564 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
565 |
def wlock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
566 |
"""Lock the non-store parts of the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
567 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
568 |
def currentwlock(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
569 |
"""Return the wlock if it's held or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
570 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
571 |
def checkcommitpatterns(wctx, vdirs, match, status, fail): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
572 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
573 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
574 |
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:
33823
diff
changeset
|
575 |
editor=False, extra=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
576 |
"""Add a new revision to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
577 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
578 |
def commitctx(ctx, error=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
579 |
"""Commit a commitctx instance to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
580 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
581 |
def destroying(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
582 |
"""Inform the repository that nodes are about to be destroyed.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
583 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
584 |
def destroyed(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
585 |
"""Inform the repository that nodes have been destroyed.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
586 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
587 |
def status(node1='.', node2=None, match=None, ignored=False, |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
588 |
clean=False, unknown=False, listsubrepos=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
589 |
"""Convenience method to call repo[x].status().""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
590 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
591 |
def addpostdsstatus(ps): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
592 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
593 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
594 |
def postdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
595 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
596 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
597 |
def clearpostdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
598 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
599 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
600 |
def heads(start=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
601 |
"""Obtain list of nodes that are DAG heads.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
602 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
603 |
def branchheads(branch=None, start=None, closed=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
604 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
605 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
606 |
def branches(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
607 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
608 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
609 |
def between(pairs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
610 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
611 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
612 |
def checkpush(pushop): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
613 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
614 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
615 |
prepushoutgoinghooks = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
616 |
"""util.hooks instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
617 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
618 |
def pushkey(namespace, key, old, new): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
619 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
620 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
621 |
def listkeys(namespace): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
622 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
623 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
624 |
def debugwireargs(one, two, three=None, four=None, five=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
625 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
626 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
627 |
def savecommitmessage(text): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33823
diff
changeset
|
628 |
pass |