author | Gregory Szorc <gregory.szorc@gmail.com> |
Fri, 13 Apr 2018 11:12:19 -0700 | |
changeset 37635 | cc8c06835097 |
parent 37633 | 33a6eee08db2 |
child 37649 | a168799687e5 |
permissions | -rw-r--r-- |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 |
# repository.py - Interfaces and base classes for repositories and peers. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
# |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com> |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
# |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
from __future__ import absolute_import |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
|
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
10 |
from .i18n import _ |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
11 |
from .thirdparty.zope import ( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
12 |
interface as zi, |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
13 |
) |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
14 |
from . import ( |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
15 |
error, |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
16 |
) |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
17 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
18 |
class ipeerconnection(zi.Interface): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 |
"""Represents a "connection" to a repository. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
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
|
22 |
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
|
23 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 |
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
|
25 |
outside of this module. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
""" |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
27 |
ui = zi.Attribute("""ui.ui instance""") |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
29 |
def url(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 |
"""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
|
31 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
data leakage. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 |
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
|
38 |
value. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
41 |
def local(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 |
"""Returns a local repository instance. |
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 |
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
|
45 |
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
|
46 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
48 |
def peer(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
"""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
|
50 |
|
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
Most implementations will ``return self``. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
52 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
53 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
54 |
def canpush(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
55 |
"""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
|
56 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
57 |
def close(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
58 |
"""Close the connection to this peer. |
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 |
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
|
61 |
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
|
62 |
""" |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
63 |
|
37610
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
64 |
class ipeercapabilities(zi.Interface): |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
65 |
"""Peer sub-interface related to capabilities.""" |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
66 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
67 |
def capable(name): |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
68 |
"""Determine support for a named capability. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
69 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
70 |
Returns ``False`` if capability not supported. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
71 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
72 |
Returns ``True`` if boolean capability is supported. Returns a string |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
73 |
if capability support is non-boolean. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
74 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
75 |
Capability strings may or may not map to wire protocol capabilities. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
76 |
""" |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
77 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
78 |
def requirecap(name, purpose): |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
79 |
"""Require a capability to be present. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
80 |
|
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
81 |
Raises a ``CapabilityError`` if the capability isn't present. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
82 |
""" |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
83 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
84 |
class ipeercommands(zi.Interface): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
85 |
"""Client-side interface for communicating over the wire protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
86 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
87 |
This interface is used as a gateway to the Mercurial wire protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
88 |
methods commonly call wire protocol commands of the same name. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
89 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
90 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
91 |
def branchmap(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
92 |
"""Obtain heads in named branches. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
93 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
94 |
Returns a dict mapping branch name to an iterable of nodes that are |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
95 |
heads on that branch. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
96 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
97 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
98 |
def capabilities(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
99 |
"""Obtain capabilities of the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
100 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
101 |
Returns a set of string capabilities. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
102 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
103 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
104 |
def debugwireargs(one, two, three=None, four=None, five=None): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
105 |
"""Used to facilitate debugging of arguments passed over the wire.""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
106 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
107 |
def getbundle(source, **kwargs): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
108 |
"""Obtain remote repository data as a bundle. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
109 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
110 |
This command is how the bulk of repository data is transferred from |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
111 |
the peer to the local repository |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
112 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
113 |
Returns a generator of bundle data. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
114 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
115 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
116 |
def heads(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
117 |
"""Determine all known head revisions in the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
118 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
119 |
Returns an iterable of binary nodes. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
120 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
121 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
122 |
def known(nodes): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
123 |
"""Determine whether multiple nodes are known. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
124 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
125 |
Accepts an iterable of nodes whose presence to check for. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
126 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
127 |
Returns an iterable of booleans indicating of the corresponding node |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
128 |
at that index is known to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
129 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
130 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
131 |
def listkeys(namespace): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
132 |
"""Obtain all keys in a pushkey namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
133 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
134 |
Returns an iterable of key names. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
135 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
136 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
137 |
def lookup(key): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
138 |
"""Resolve a value to a known revision. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
139 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
140 |
Returns a binary node of the resolved revision on success. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
141 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
142 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
143 |
def pushkey(namespace, key, old, new): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
144 |
"""Set a value using the ``pushkey`` protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
145 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
146 |
Arguments correspond to the pushkey namespace and key to operate on and |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
147 |
the old and new values for that key. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
148 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
149 |
Returns a string with the peer result. The value inside varies by the |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
150 |
namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
151 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
152 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
153 |
def stream_out(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
154 |
"""Obtain streaming clone data. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
155 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
156 |
Successful result should be a generator of data chunks. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
157 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
158 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
159 |
def unbundle(bundle, heads, url): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
160 |
"""Transfer repository data to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
161 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
162 |
This is how the bulk of data during a push is transferred. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
163 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
164 |
Returns the integer number of heads added to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
165 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
166 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
167 |
class ipeerlegacycommands(zi.Interface): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
168 |
"""Interface for implementing support for legacy wire protocol commands. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
169 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
170 |
Wire protocol commands transition to legacy status when they are no longer |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
171 |
used by modern clients. To facilitate identifying which commands are |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
172 |
legacy, the interfaces are split. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
173 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
174 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
175 |
def between(pairs): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
176 |
"""Obtain nodes between pairs of nodes. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
177 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
178 |
``pairs`` is an iterable of node pairs. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
179 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
180 |
Returns an iterable of iterables of nodes corresponding to each |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
181 |
requested pair. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
182 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
183 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
184 |
def branches(nodes): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
185 |
"""Obtain ancestor changesets of specific nodes back to a branch point. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
186 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
187 |
For each requested node, the peer finds the first ancestor node that is |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
188 |
a DAG root or is a merge. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
189 |
|
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
190 |
Returns an iterable of iterables with the resolved values for each node. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
191 |
""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
192 |
|
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
193 |
def changegroup(nodes, source): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
194 |
"""Obtain a changegroup with data for descendants of specified nodes.""" |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
195 |
|
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
196 |
def changegroupsubset(bases, heads, source): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
197 |
pass |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
198 |
|
37629
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
199 |
class ipeercommandexecutor(zi.Interface): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
200 |
"""Represents a mechanism to execute remote commands. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
201 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
202 |
This is the primary interface for requesting that wire protocol commands |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
203 |
be executed. Instances of this interface are active in a context manager |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
204 |
and have a well-defined lifetime. When the context manager exits, all |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
205 |
outstanding requests are waited on. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
206 |
""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
207 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
208 |
def callcommand(name, args): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
209 |
"""Request that a named command be executed. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
210 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
211 |
Receives the command name and a dictionary of command arguments. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
212 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
213 |
Returns a ``concurrent.futures.Future`` that will resolve to the |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
214 |
result of that command request. That exact value is left up to |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
215 |
the implementation and possibly varies by command. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
216 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
217 |
Not all commands can coexist with other commands in an executor |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
218 |
instance: it depends on the underlying wire protocol transport being |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
219 |
used and the command itself. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
220 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
221 |
Implementations MAY call ``sendcommands()`` automatically if the |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
222 |
requested command can not coexist with other commands in this executor. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
223 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
224 |
Implementations MAY call ``sendcommands()`` automatically when the |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
225 |
future's ``result()`` is called. So, consumers using multiple |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
226 |
commands with an executor MUST ensure that ``result()`` is not called |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
227 |
until all command requests have been issued. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
228 |
""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
229 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
230 |
def sendcommands(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
231 |
"""Trigger submission of queued command requests. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
232 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
233 |
Not all transports submit commands as soon as they are requested to |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
234 |
run. When called, this method forces queued command requests to be |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
235 |
issued. It will no-op if all commands have already been sent. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
236 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
237 |
When called, no more new commands may be issued with this executor. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
238 |
""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
239 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
240 |
def close(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
241 |
"""Signal that this command request is finished. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
242 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
243 |
When called, no more new commands may be issued. All outstanding |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
244 |
commands that have previously been issued are waited on before |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
245 |
returning. This not only includes waiting for the futures to resolve, |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
246 |
but also waiting for all response data to arrive. In other words, |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
247 |
calling this waits for all on-wire state for issued command requests |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
248 |
to finish. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
249 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
250 |
When used as a context manager, this method is called when exiting the |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
251 |
context manager. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
252 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
253 |
This method may call ``sendcommands()`` if there are buffered commands. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
254 |
""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
255 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
256 |
class ipeerrequests(zi.Interface): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
257 |
"""Interface for executing commands on a peer.""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
258 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
259 |
def commandexecutor(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
260 |
"""A context manager that resolves to an ipeercommandexecutor. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
261 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
262 |
The object this resolves to can be used to issue command requests |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
263 |
to the peer. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
264 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
265 |
Callers should call its ``callcommand`` method to issue command |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
266 |
requests. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
267 |
|
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
268 |
A new executor should be obtained for each distinct set of commands |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
269 |
(possibly just a single command) that the consumer wants to execute |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
270 |
as part of a single operation or round trip. This is because some |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
271 |
peers are half-duplex and/or don't support persistent connections. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
272 |
e.g. in the case of HTTP peers, commands sent to an executor represent |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
273 |
a single HTTP request. While some peers may support multiple command |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
274 |
sends over the wire per executor, consumers need to code to the least |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
275 |
capable peer. So it should be assumed that command executors buffer |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
276 |
called commands until they are told to send them and that each |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
277 |
command executor could result in a new connection or wire-level request |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
278 |
being issued. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
279 |
""" |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
280 |
|
37630
e1b32dc4646c
wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37629
diff
changeset
|
281 |
class ipeerbase(ipeerconnection, ipeercapabilities, ipeercommands, |
e1b32dc4646c
wireproto: implement command executor interface for version 1 peers
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37629
diff
changeset
|
282 |
ipeerrequests): |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
283 |
"""Unified interface for peer repositories. |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
284 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
285 |
All peer instances must conform to this interface. |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
286 |
""" |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
287 |
|
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
288 |
@zi.implementer(ipeerbase) |
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
289 |
class peer(object): |
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
290 |
"""Base class for peer repositories.""" |
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
291 |
|
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
292 |
def capable(self, name): |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
293 |
caps = self.capabilities() |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
294 |
if name in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
295 |
return True |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
296 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
297 |
name = '%s=' % name |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
298 |
for cap in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
299 |
if cap.startswith(name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
300 |
return cap[len(name):] |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
301 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
302 |
return False |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
303 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
304 |
def requirecap(self, name, purpose): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
305 |
if self.capable(name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
306 |
return |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
307 |
|
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
308 |
raise error.CapabilityError( |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
309 |
_('cannot %s; remote repository does not support the %r ' |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
310 |
'capability') % (purpose, name)) |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
311 |
|
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
312 |
class ifilerevisionssequence(zi.Interface): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
313 |
"""Contains index data for all revisions of a file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
314 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
315 |
Types implementing this behave like lists of tuples. The index |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
316 |
in the list corresponds to the revision number. The values contain |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
317 |
index metadata. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
318 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
319 |
The *null* revision (revision number -1) is always the last item |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
320 |
in the index. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
321 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
322 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
323 |
def __len__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
324 |
"""The total number of revisions.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
325 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
326 |
def __getitem__(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
327 |
"""Returns the object having a specific revision number. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
328 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
329 |
Returns an 8-tuple with the following fields: |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
330 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
331 |
offset+flags |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
332 |
Contains the offset and flags for the revision. 64-bit unsigned |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
333 |
integer where first 6 bytes are the offset and the next 2 bytes |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
334 |
are flags. The offset can be 0 if it is not used by the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
335 |
compressed size |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
336 |
Size of the revision data in the store. It can be 0 if it isn't |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
337 |
needed by the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
338 |
uncompressed size |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
339 |
Fulltext size. It can be 0 if it isn't needed by the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
340 |
base revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
341 |
Revision number of revision the delta for storage is encoded |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
342 |
against. -1 indicates not encoded against a base revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
343 |
link revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
344 |
Revision number of changelog revision this entry is related to. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
345 |
p1 revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
346 |
Revision number of 1st parent. -1 if no 1st parent. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
347 |
p2 revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
348 |
Revision number of 2nd parent. -1 if no 1st parent. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
349 |
node |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
350 |
Binary node value for this revision number. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
351 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
352 |
Negative values should index off the end of the sequence. ``-1`` |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
353 |
should return the null revision. ``-2`` should return the most |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
354 |
recent revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
355 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
356 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
357 |
def __contains__(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
358 |
"""Whether a revision number exists.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
359 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
360 |
def insert(self, i, entry): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
361 |
"""Add an item to the index at specific revision.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
362 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
363 |
class ifileindex(zi.Interface): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
364 |
"""Storage interface for index data of a single file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
365 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
366 |
File storage data is divided into index metadata and data storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
367 |
This interface defines the index portion of the interface. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
368 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
369 |
The index logically consists of: |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
370 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
371 |
* A mapping between revision numbers and nodes. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
372 |
* DAG data (storing and querying the relationship between nodes). |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
373 |
* Metadata to facilitate storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
374 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
375 |
index = zi.Attribute( |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
376 |
"""An ``ifilerevisionssequence`` instance.""") |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
377 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
378 |
def __len__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
379 |
"""Obtain the number of revisions stored for this file.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
380 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
381 |
def __iter__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
382 |
"""Iterate over revision numbers for this file.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
383 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
384 |
def revs(start=0, stop=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
385 |
"""Iterate over revision numbers for this file, with control.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
386 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
387 |
def parents(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
388 |
"""Returns a 2-tuple of parent nodes for a revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
389 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
390 |
Values will be ``nullid`` if the parent is empty. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
391 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
392 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
393 |
def parentrevs(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
394 |
"""Like parents() but operates on revision numbers.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
395 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
396 |
def rev(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
397 |
"""Obtain the revision number given a node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
398 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
399 |
Raises ``error.LookupError`` if the node is not known. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
400 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
401 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
402 |
def node(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
403 |
"""Obtain the node value given a revision number. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
404 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
405 |
Raises ``IndexError`` if the node is not known. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
406 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
407 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
408 |
def lookup(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
409 |
"""Attempt to resolve a value to a node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
410 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
411 |
Value can be a binary node, hex node, revision number, or a string |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
412 |
that can be converted to an integer. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
413 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
414 |
Raises ``error.LookupError`` if a node could not be resolved. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
415 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
416 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
417 |
def linkrev(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
418 |
"""Obtain the changeset revision number a revision is linked to.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
419 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
420 |
def flags(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
421 |
"""Obtain flags used to affect storage of a revision.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
422 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
423 |
def iscensored(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
424 |
"""Return whether a revision's content has been censored.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
425 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
426 |
def commonancestorsheads(node1, node2): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
427 |
"""Obtain an iterable of nodes containing heads of common ancestors. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
428 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
429 |
See ``ancestor.commonancestorsheads()``. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
430 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
431 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
432 |
def descendants(revs): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
433 |
"""Obtain descendant revision numbers for a set of revision numbers. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
434 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
435 |
If ``nullrev`` is in the set, this is equivalent to ``revs()``. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
436 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
437 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
438 |
def headrevs(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
439 |
"""Obtain a list of revision numbers that are DAG heads. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
440 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
441 |
The list is sorted oldest to newest. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
442 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
443 |
TODO determine if sorting is required. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
444 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
445 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
446 |
def heads(start=None, stop=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
447 |
"""Obtain a list of nodes that are DAG heads, with control. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
448 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
449 |
The set of revisions examined can be limited by specifying |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
450 |
``start`` and ``stop``. ``start`` is a node. ``stop`` is an |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
451 |
iterable of nodes. DAG traversal starts at earlier revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
452 |
``start`` and iterates forward until any node in ``stop`` is |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
453 |
encountered. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
454 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
455 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
456 |
def children(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
457 |
"""Obtain nodes that are children of a node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
458 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
459 |
Returns a list of nodes. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
460 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
461 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
462 |
def deltaparent(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
463 |
""""Return the revision that is a suitable parent to delta against.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
464 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
465 |
def candelta(baserev, rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
466 |
""""Whether a delta can be generated between two revisions.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
467 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
468 |
class ifiledata(zi.Interface): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
469 |
"""Storage interface for data storage of a specific file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
470 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
471 |
This complements ``ifileindex`` and provides an interface for accessing |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
472 |
data for a tracked file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
473 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
474 |
def rawsize(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
475 |
"""The size of the fulltext data for a revision as stored.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
476 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
477 |
def size(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
478 |
"""Obtain the fulltext size of file data. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
479 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
480 |
Any metadata is excluded from size measurements. Use ``rawsize()`` if |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
481 |
metadata size is important. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
482 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
483 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
484 |
def checkhash(fulltext, node, p1=None, p2=None, rev=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
485 |
"""Validate the stored hash of a given fulltext and node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
486 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
487 |
Raises ``error.RevlogError`` is hash validation fails. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
488 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
489 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
490 |
def revision(node, raw=False): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
491 |
""""Obtain fulltext data for a node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
492 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
493 |
By default, any storage transformations are applied before the data |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
494 |
is returned. If ``raw`` is True, non-raw storage transformations |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
495 |
are not applied. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
496 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
497 |
The fulltext data may contain a header containing metadata. Most |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
498 |
consumers should use ``read()`` to obtain the actual file data. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
499 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
500 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
501 |
def read(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
502 |
"""Resolve file fulltext data. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
503 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
504 |
This is similar to ``revision()`` except any metadata in the data |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
505 |
headers is stripped. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
506 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
507 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
508 |
def renamed(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
509 |
"""Obtain copy metadata for a node. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
510 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
511 |
Returns ``False`` if no copy metadata is stored or a 2-tuple of |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
512 |
(path, node) from which this revision was copied. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
513 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
514 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
515 |
def cmp(node, fulltext): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
516 |
"""Compare fulltext to another revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
517 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
518 |
Returns True if the fulltext is different from what is stored. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
519 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
520 |
This takes copy metadata into account. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
521 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
522 |
TODO better document the copy metadata and censoring logic. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
523 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
524 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
525 |
def revdiff(rev1, rev2): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
526 |
"""Obtain a delta between two revision numbers. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
527 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
528 |
Operates on raw data in the store (``revision(node, raw=True)``). |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
529 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
530 |
The returned data is the result of ``bdiff.bdiff`` on the raw |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
531 |
revision data. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
532 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
533 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
534 |
class ifilemutation(zi.Interface): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
535 |
"""Storage interface for mutation events of a tracked file.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
536 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
537 |
def add(filedata, meta, transaction, linkrev, p1, p2): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
538 |
"""Add a new revision to the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
539 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
540 |
Takes file data, dictionary of metadata, a transaction, linkrev, |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
541 |
and parent nodes. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
542 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
543 |
Returns the node that was added. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
544 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
545 |
May no-op if a revision matching the supplied data is already stored. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
546 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
547 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
548 |
def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None, |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
549 |
flags=0, cachedelta=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
550 |
"""Add a new revision to the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
551 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
552 |
This is similar to ``add()`` except it operates at a lower level. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
553 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
554 |
The data passed in already contains a metadata header, if any. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
555 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
556 |
``node`` and ``flags`` can be used to define the expected node and |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
557 |
the flags to use with storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
558 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
559 |
``add()`` is usually called when adding files from e.g. the working |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
560 |
directory. ``addrevision()`` is often called by ``add()`` and for |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
561 |
scenarios where revision data has already been computed, such as when |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
562 |
applying raw data from a peer repo. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
563 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
564 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
565 |
def addgroup(deltas, linkmapper, transaction, addrevisioncb=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
566 |
"""Process a series of deltas for storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
567 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
568 |
``deltas`` is an iterable of 7-tuples of |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
569 |
(node, p1, p2, linknode, deltabase, delta, flags) defining revisions |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
570 |
to add. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
571 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
572 |
The ``delta`` field contains ``mpatch`` data to apply to a base |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
573 |
revision, identified by ``deltabase``. The base node can be |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
574 |
``nullid``, in which case the header from the delta can be ignored |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
575 |
and the delta used as the fulltext. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
576 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
577 |
``addrevisioncb`` should be called for each node as it is committed. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
578 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
579 |
Returns a list of nodes that were processed. A node will be in the list |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
580 |
even if it existed in the store previously. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
581 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
582 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
583 |
def getstrippoint(minlink): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
584 |
"""Find the minimum revision that must be stripped to strip a linkrev. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
585 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
586 |
Returns a 2-tuple containing the minimum revision number and a set |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
587 |
of all revisions numbers that would be broken by this strip. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
588 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
589 |
TODO this is highly revlog centric and should be abstracted into |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
590 |
a higher-level deletion API. ``repair.strip()`` relies on this. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
591 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
592 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
593 |
def strip(minlink, transaction): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
594 |
"""Remove storage of items starting at a linkrev. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
595 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
596 |
This uses ``getstrippoint()`` to determine the first node to remove. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
597 |
Then it effectively truncates storage for all revisions after that. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
598 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
599 |
TODO this is highly revlog centric and should be abstracted into a |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
600 |
higher-level deletion API. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
601 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
602 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
603 |
class ifilestorage(ifileindex, ifiledata, ifilemutation): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
604 |
"""Complete storage interface for a single tracked file.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
605 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
606 |
version = zi.Attribute( |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
607 |
"""Version number of storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
608 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
609 |
TODO this feels revlog centric and could likely be removed. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
610 |
""") |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
611 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
612 |
storedeltachains = zi.Attribute( |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
613 |
"""Whether the store stores deltas. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
614 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
615 |
TODO deltachains are revlog centric. This can probably removed |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
616 |
once there are better abstractions for obtaining/writing |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
617 |
data. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
618 |
""") |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
619 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
620 |
_generaldelta = zi.Attribute( |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
621 |
"""Whether deltas can be against any parent revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
622 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
623 |
TODO this is used by changegroup code and it could probably be |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
624 |
folded into another API. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
625 |
""") |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
626 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
627 |
def files(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
628 |
"""Obtain paths that are backing storage for this file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
629 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
630 |
TODO this is used heavily by verify code and there should probably |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
631 |
be a better API for that. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
632 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
633 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
634 |
def checksize(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
635 |
"""Obtain the expected sizes of backing files. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
636 |
|
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
637 |
TODO this is used by verify and it should not be part of the interface. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
638 |
""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
639 |
|
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
640 |
class completelocalrepository(zi.Interface): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
641 |
"""Monolithic interface for local repositories. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
642 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
643 |
This currently captures the reality of things - not how things should be. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
644 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
645 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
646 |
supportedformats = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
647 |
"""Set of requirements that apply to stream clone. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
648 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
649 |
This is actually a class attribute and is shared among all instances. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
650 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
651 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
652 |
openerreqs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
653 |
"""Set of requirements that are passed to the opener. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
654 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
655 |
This is actually a class attribute and is shared among all instances. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
656 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
657 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
658 |
supported = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
659 |
"""Set of requirements that this repo is capable of opening.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
660 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
661 |
requirements = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
662 |
"""Set of requirements this repo uses.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
663 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
664 |
filtername = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
665 |
"""Name of the repoview that is active on this repo.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
666 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
667 |
wvfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
668 |
"""VFS used to access the working directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
669 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
670 |
vfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
671 |
"""VFS rooted at the .hg directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
672 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
673 |
Used to access repository data not in the store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
674 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
675 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
676 |
svfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
677 |
"""VFS rooted at the store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
678 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
679 |
Used to access repository data in the store. Typically .hg/store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
680 |
But can point elsewhere if the store is shared. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
681 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
682 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
683 |
root = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
684 |
"""Path to the root of the working directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
685 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
686 |
path = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
687 |
"""Path to the .hg directory.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
688 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
689 |
origroot = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
690 |
"""The filesystem path that was used to construct the repo.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
691 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
692 |
auditor = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
693 |
"""A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
694 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
695 |
This checks if a path refers to a nested repository. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
696 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
697 |
Operates on the filesystem. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
698 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
699 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
700 |
nofsauditor = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
701 |
"""A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
702 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
703 |
This is like ``auditor`` except it doesn't do filesystem checks. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
704 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
705 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
706 |
baseui = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
707 |
"""Original ui instance passed into constructor.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
708 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
709 |
ui = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
710 |
"""Main ui instance for this instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
711 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
712 |
sharedpath = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
713 |
"""Path to the .hg directory of the repo this repo was shared from.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
714 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
715 |
store = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
716 |
"""A store instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
717 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
718 |
spath = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
719 |
"""Path to the store.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
720 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
721 |
sjoin = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
722 |
"""Alias to self.store.join.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
723 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
724 |
cachevfs = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
725 |
"""A VFS used to access the cache directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
726 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
727 |
Typically .hg/cache. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
728 |
""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
729 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
730 |
filteredrevcache = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
731 |
"""Holds sets of revisions to be filtered.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
732 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
733 |
names = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
734 |
"""A ``namespaces`` instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
735 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
736 |
def close(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
737 |
"""Close the handle on this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
738 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
739 |
def peer(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
740 |
"""Obtain an object conforming to the ``peer`` interface.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
741 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
742 |
def unfiltered(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
743 |
"""Obtain an unfiltered/raw view of this repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
744 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
745 |
def filtered(name, visibilityexceptions=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
746 |
"""Obtain a named view of this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
747 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
748 |
obsstore = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
749 |
"""A store of obsolescence data.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
750 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
751 |
changelog = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
752 |
"""A handle on the changelog revlog.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
753 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
754 |
manifestlog = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
755 |
"""A handle on the root manifest revlog.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
756 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
757 |
dirstate = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
758 |
"""Working directory state.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
759 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
760 |
narrowpats = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
761 |
"""Matcher patterns for this repository's narrowspec.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
762 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
763 |
def narrowmatch(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
764 |
"""Obtain a matcher for the narrowspec.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
765 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
766 |
def setnarrowpats(newincludes, newexcludes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
767 |
"""Define the narrowspec for this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
768 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
769 |
def __getitem__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
770 |
"""Try to resolve a changectx.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
771 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
772 |
def __contains__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
773 |
"""Whether a changeset exists.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
774 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
775 |
def __nonzero__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
776 |
"""Always returns True.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
777 |
return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
778 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
779 |
__bool__ = __nonzero__ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
780 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
781 |
def __len__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
782 |
"""Returns the number of changesets in the repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
783 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
784 |
def __iter__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
785 |
"""Iterate over revisions in the changelog.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
786 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
787 |
def revs(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
788 |
"""Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
789 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
790 |
Emits revisions. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
791 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
792 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
793 |
def set(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
794 |
"""Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
795 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
796 |
Emits changectx instances. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
797 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
798 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
799 |
def anyrevs(specs, user=False, localalias=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
800 |
"""Find revisions matching one of the given revsets.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
801 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
802 |
def url(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
803 |
"""Returns a string representing the location of this repo.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
804 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
805 |
def hook(name, throw=False, **args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
806 |
"""Call a hook.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
807 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
808 |
def tags(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
809 |
"""Return a mapping of tag to node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
810 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
811 |
def tagtype(tagname): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
812 |
"""Return the type of a given tag.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
813 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
814 |
def tagslist(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
815 |
"""Return a list of tags ordered by revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
816 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
817 |
def nodetags(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
818 |
"""Return the tags associated with a node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
819 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
820 |
def nodebookmarks(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
821 |
"""Return the list of bookmarks pointing to the specified node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
822 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
823 |
def branchmap(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
824 |
"""Return a mapping of branch to heads in that branch.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
825 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
826 |
def revbranchcache(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
827 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
828 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
829 |
def branchtip(branchtip, ignoremissing=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
830 |
"""Return the tip node for a given branch.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
831 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
832 |
def lookup(key): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
833 |
"""Resolve the node for a revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
834 |
|
37351
fdd22bf6398f
localrepo: drop "remote" argument from lookupbranch() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37320
diff
changeset
|
835 |
def lookupbranch(key): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
836 |
"""Look up the branch name of the given revision or branch name.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
837 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
838 |
def known(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
839 |
"""Determine whether a series of nodes is known. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
840 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
841 |
Returns a list of bools. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
842 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
843 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
844 |
def local(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
845 |
"""Whether the repository is local.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
846 |
return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
847 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
848 |
def publishing(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
849 |
"""Whether the repository is a publishing repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
850 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
851 |
def cancopy(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
852 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
853 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
854 |
def shared(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
855 |
"""The type of shared repository or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
856 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
857 |
def wjoin(f, *insidef): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
858 |
"""Calls self.vfs.reljoin(self.root, f, *insidef)""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
859 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
860 |
def file(f): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
861 |
"""Obtain a filelog for a tracked path.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
862 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
863 |
def setparents(p1, p2): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
864 |
"""Set the parent nodes of the working directory.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
865 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
866 |
def filectx(path, changeid=None, fileid=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
867 |
"""Obtain a filectx for the given file revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
868 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
869 |
def getcwd(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
870 |
"""Obtain the current working directory from the dirstate.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
871 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
872 |
def pathto(f, cwd=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
873 |
"""Obtain the relative path to a file.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
874 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
875 |
def adddatafilter(name, fltr): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
876 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
877 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
878 |
def wread(filename): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
879 |
"""Read a file from wvfs, using data filters.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
880 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
881 |
def wwrite(filename, data, flags, backgroundclose=False, **kwargs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
882 |
"""Write data to a file in the wvfs, using data filters.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
883 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
884 |
def wwritedata(filename, data): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
885 |
"""Resolve data for writing to the wvfs, using data filters.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
886 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
887 |
def currenttransaction(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
888 |
"""Obtain the current transaction instance or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
889 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
890 |
def transaction(desc, report=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
891 |
"""Open a new transaction to write to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
892 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
893 |
def undofiles(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
894 |
"""Returns a list of (vfs, path) for files to undo transactions.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
895 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
896 |
def recover(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
897 |
"""Roll back an interrupted transaction.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
898 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
899 |
def rollback(dryrun=False, force=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
900 |
"""Undo the last transaction. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
901 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
902 |
DANGEROUS. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
903 |
""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
904 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
905 |
def updatecaches(tr=None, full=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
906 |
"""Warm repo caches.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
907 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
908 |
def invalidatecaches(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
909 |
"""Invalidate cached data due to the repository mutating.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
910 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
911 |
def invalidatevolatilesets(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
912 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
913 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
914 |
def invalidatedirstate(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
915 |
"""Invalidate the dirstate.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
916 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
917 |
def invalidate(clearfilecache=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
918 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
919 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
920 |
def invalidateall(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
921 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
922 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
923 |
def lock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
924 |
"""Lock the repository store and return a lock instance.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
925 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
926 |
def wlock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
927 |
"""Lock the non-store parts of the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
928 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
929 |
def currentwlock(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
930 |
"""Return the wlock if it's held or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
931 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
932 |
def checkcommitpatterns(wctx, vdirs, match, status, fail): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
933 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
934 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
935 |
def commit(text='', user=None, date=None, match=None, force=False, |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
936 |
editor=False, extra=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
937 |
"""Add a new revision to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
938 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
939 |
def commitctx(ctx, error=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
940 |
"""Commit a commitctx instance to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
941 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
942 |
def destroying(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
943 |
"""Inform the repository that nodes are about to be destroyed.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
944 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
945 |
def destroyed(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
946 |
"""Inform the repository that nodes have been destroyed.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
947 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
948 |
def status(node1='.', node2=None, match=None, ignored=False, |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
949 |
clean=False, unknown=False, listsubrepos=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
950 |
"""Convenience method to call repo[x].status().""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
951 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
952 |
def addpostdsstatus(ps): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
953 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
954 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
955 |
def postdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
956 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
957 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
958 |
def clearpostdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
959 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
960 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
961 |
def heads(start=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
962 |
"""Obtain list of nodes that are DAG heads.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
963 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
964 |
def branchheads(branch=None, start=None, closed=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
965 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
966 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
967 |
def branches(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
968 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
969 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
970 |
def between(pairs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
971 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
972 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
973 |
def checkpush(pushop): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
974 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
975 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
976 |
prepushoutgoinghooks = zi.Attribute( |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
977 |
"""util.hooks instance.""") |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
978 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
979 |
def pushkey(namespace, key, old, new): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
980 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
981 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
982 |
def listkeys(namespace): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
983 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
984 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
985 |
def debugwireargs(one, two, three=None, four=None, five=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
986 |
pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
987 |
|
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
988 |
def savecommitmessage(text): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
989 |
pass |