author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Tue, 03 Sep 2019 23:51:17 +0200 | |
changeset 42987 | 36a0a1951d64 |
parent 42814 | 2c4f656c8e9f |
child 43076 | 2372284d9457 |
permissions | -rw-r--r-- |
1089 | 1 |
# filelog.py - file history class for mercurial |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 |
# |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4258
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 |
# |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
7634
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
10263 | 6 |
# GNU General Public License version 2 or any later version. |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
|
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
8 |
from __future__ import absolute_import |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
9 |
|
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
10 |
from .i18n import _ |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
11 |
from .node import ( |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
12 |
nullid, |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
13 |
nullrev, |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
14 |
) |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
15 |
from . import ( |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
16 |
error, |
42813
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
17 |
revlog, |
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
18 |
) |
268662aac075
interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42720
diff
changeset
|
19 |
from .interfaces import ( |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
20 |
repository, |
42814
2c4f656c8e9f
interfaceutil: move to interfaces/
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42813
diff
changeset
|
21 |
util as interfaceutil, |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
22 |
) |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
23 |
from .utils import ( |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39876
diff
changeset
|
24 |
storageutil, |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
25 |
) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
26 |
|
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37497
diff
changeset
|
27 |
@interfaceutil.implementer(repository.ifilestorage) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
28 |
class filelog(object): |
4258
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4257
diff
changeset
|
29 |
def __init__(self, opener, path): |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
30 |
self._revlog = revlog.revlog(opener, |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
31 |
'/'.join(('data', path + '.i')), |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
32 |
censorable=True) |
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
33 |
# Full name of the user visible file, relative to the repository root. |
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
34 |
# Used by LFS. |
39856
96838b620b9c
filelog: store filename directly on revlog instance
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39855
diff
changeset
|
35 |
self._revlog.filename = path |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
36 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
37 |
def __len__(self): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
38 |
return len(self._revlog) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
39 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
40 |
def __iter__(self): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
41 |
return self._revlog.__iter__() |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
42 |
|
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
43 |
def hasnode(self, node): |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
44 |
if node in (nullid, nullrev): |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
45 |
return False |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
46 |
|
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
47 |
try: |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
48 |
self._revlog.rev(node) |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
49 |
return True |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
50 |
except (TypeError, ValueError, IndexError, error.LookupError): |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
51 |
return False |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40056
diff
changeset
|
52 |
|
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
53 |
def revs(self, start=0, stop=None): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
54 |
return self._revlog.revs(start=start, stop=stop) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
55 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
56 |
def parents(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
57 |
return self._revlog.parents(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
58 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
59 |
def parentrevs(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
60 |
return self._revlog.parentrevs(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
61 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
62 |
def rev(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
63 |
return self._revlog.rev(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
64 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
65 |
def node(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
66 |
return self._revlog.node(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
67 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
68 |
def lookup(self, node): |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
69 |
return storageutil.fileidlookup(self._revlog, node, |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39998
diff
changeset
|
70 |
self._revlog.indexfile) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
71 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
72 |
def linkrev(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
73 |
return self._revlog.linkrev(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
74 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
75 |
def commonancestorsheads(self, node1, node2): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
76 |
return self._revlog.commonancestorsheads(node1, node2) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
77 |
|
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
78 |
# Used by dagop.blockdescendants(). |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
79 |
def descendants(self, revs): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
80 |
return self._revlog.descendants(revs) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
81 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
82 |
def heads(self, start=None, stop=None): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
83 |
return self._revlog.heads(start, stop) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
84 |
|
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
85 |
# Used by hgweb, children extension. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
86 |
def children(self, node): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
87 |
return self._revlog.children(node) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
88 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
89 |
def iscensored(self, rev): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
90 |
return self._revlog.iscensored(rev) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
91 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
92 |
def revision(self, node, _df=None, raw=False): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
93 |
return self._revlog.revision(node, _df=_df, raw=raw) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
94 |
|
42720
bf1e8d2ab900
rawdata: forward the method call on `filelog` object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
95 |
def rawdata(self, node, _df=None): |
bf1e8d2ab900
rawdata: forward the method call on `filelog` object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
96 |
return self._revlog.rawdata(node, _df=_df) |
bf1e8d2ab900
rawdata: forward the method call on `filelog` object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
40430
diff
changeset
|
97 |
|
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
98 |
def emitrevisions(self, nodes, nodesorder=None, |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
99 |
revisiondata=False, assumehaveparentrevisions=False, |
40430
6a917075535a
storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents:
40389
diff
changeset
|
100 |
deltamode=repository.CG_DELTAMODE_STD): |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
101 |
return self._revlog.emitrevisions( |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
102 |
nodes, nodesorder=nodesorder, revisiondata=revisiondata, |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
103 |
assumehaveparentrevisions=assumehaveparentrevisions, |
40430
6a917075535a
storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents:
40389
diff
changeset
|
104 |
deltamode=deltamode) |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
105 |
|
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
106 |
def addrevision(self, revisiondata, transaction, linkrev, p1, p2, |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
107 |
node=None, flags=revlog.REVIDX_DEFAULT_FLAGS, |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
108 |
cachedelta=None): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
109 |
return self._revlog.addrevision(revisiondata, transaction, linkrev, |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
110 |
p1, p2, node=node, flags=flags, |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
111 |
cachedelta=cachedelta) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
112 |
|
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
113 |
def addgroup(self, deltas, linkmapper, transaction, addrevisioncb=None, |
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
114 |
maybemissingparents=False): |
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
115 |
if maybemissingparents: |
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
116 |
raise error.Abort(_('revlog storage does not support missing ' |
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
117 |
'parents write mode')) |
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
118 |
|
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
119 |
return self._revlog.addgroup(deltas, linkmapper, transaction, |
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
120 |
addrevisioncb=addrevisioncb) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
121 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
122 |
def getstrippoint(self, minlink): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
123 |
return self._revlog.getstrippoint(minlink) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
124 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
125 |
def strip(self, minlink, transaction): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
126 |
return self._revlog.strip(minlink, transaction) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
127 |
|
39778
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39765
diff
changeset
|
128 |
def censorrevision(self, tr, node, tombstone=b''): |
40056
324b4b10351e
revlog: rewrite censoring logic
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40007
diff
changeset
|
129 |
return self._revlog.censorrevision(tr, node, tombstone=tombstone) |
39778
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39765
diff
changeset
|
130 |
|
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
131 |
def files(self): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
132 |
return self._revlog.files() |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
133 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
134 |
def read(self, node): |
39880
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
135 |
return storageutil.filtermetadata(self.revision(node)) |
360 | 136 |
|
137 |
def add(self, text, meta, transaction, link, p1=None, p2=None): |
|
686
d7d68d27ebe5
Reapply startswith() changes that got lost with stale edit
Matt Mackall <mpm@selenic.com>
parents:
681
diff
changeset
|
138 |
if meta or text.startswith('\1\n'): |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39876
diff
changeset
|
139 |
text = storageutil.packmeta(meta, text) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
140 |
return self.addrevision(text, transaction, link, p1, p2) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
141 |
|
1116 | 142 |
def renamed(self, node): |
40005
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
143 |
return storageutil.filerevisioncopied(self, node) |
1116 | 144 |
|
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
145 |
def size(self, rev): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
146 |
"""return the size of a given revision""" |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
147 |
|
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
148 |
# for revisions with renames, we have to go the slow way |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
149 |
node = self.node(rev) |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
150 |
if self.renamed(node): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
151 |
return len(self.read(node)) |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24117
diff
changeset
|
152 |
if self.iscensored(rev): |
22597
58ec36686f0e
filelog: censored files compare against empty data, have 0 size
Mike Edgar <adgar@google.com>
parents:
22596
diff
changeset
|
153 |
return 0 |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
154 |
|
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11539
diff
changeset
|
155 |
# XXX if self.read(node).startswith("\1\n"), this returns (size+4) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
156 |
return self._revlog.size(rev) |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
157 |
|
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
158 |
def cmp(self, node, text): |
11539
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
159 |
"""compare text with a given file revision |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
160 |
|
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
161 |
returns True if text is different than what is stored. |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
162 |
""" |
40007
1470183068b8
storageutil: invert logic of file data comparison
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40006
diff
changeset
|
163 |
return not storageutil.filedataequivalent(self, node, text) |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
164 |
|
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
165 |
def verifyintegrity(self, state): |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
166 |
return self._revlog.verifyintegrity(state) |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
167 |
|
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
168 |
def storageinfo(self, exclusivefiles=False, sharedfiles=False, |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
169 |
revisionscount=False, trackedsize=False, |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
170 |
storedsize=False): |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
171 |
return self._revlog.storageinfo( |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
172 |
exclusivefiles=exclusivefiles, sharedfiles=sharedfiles, |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
173 |
revisionscount=revisionscount, trackedsize=trackedsize, |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
174 |
storedsize=storedsize) |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
175 |
|
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
176 |
# TODO these aren't part of the interface and aren't internal methods. |
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
177 |
# Callers should be fixed to not use them. |
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
178 |
|
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
179 |
# Used by bundlefilelog, unionfilelog. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
180 |
@property |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
181 |
def indexfile(self): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
182 |
return self._revlog.indexfile |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
183 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
184 |
@indexfile.setter |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
185 |
def indexfile(self, value): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
186 |
self._revlog.indexfile = value |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
187 |
|
39783
76f92d208f7a
filelog: record what's using attributes
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39782
diff
changeset
|
188 |
# Used by repo upgrade. |
37497
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
189 |
def clone(self, tr, destrevlog, **kwargs): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
190 |
if not isinstance(destrevlog, filelog): |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
191 |
raise error.ProgrammingError('expected filelog to clone()') |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
192 |
|
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
193 |
return self._revlog.clone(tr, destrevlog._revlog, **kwargs) |
1541e1a8e87d
filelog: wrap revlog instead of inheriting it (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37443
diff
changeset
|
194 |
|
39765
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
195 |
class narrowfilelog(filelog): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
196 |
"""Filelog variation to be used with narrow stores.""" |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
197 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
198 |
def __init__(self, opener, path, narrowmatch): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
199 |
super(narrowfilelog, self).__init__(opener, path) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
200 |
self._narrowmatch = narrowmatch |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
201 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
202 |
def renamed(self, node): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
203 |
res = super(narrowfilelog, self).renamed(node) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
204 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
205 |
# Renames that come from outside the narrowspec are problematic |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
206 |
# because we may lack the base text for the rename. This can result |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
207 |
# in code attempting to walk the ancestry or compute a diff |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
208 |
# encountering a missing revision. We address this by silently |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
209 |
# removing rename metadata if the source file is outside the |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
210 |
# narrow spec. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
211 |
# |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
212 |
# A better solution would be to see if the base revision is available, |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
213 |
# rather than assuming it isn't. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
214 |
# |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
215 |
# An even better solution would be to teach all consumers of rename |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
216 |
# metadata that the base revision may not be available. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
217 |
# |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
218 |
# TODO consider better ways of doing this. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
219 |
if res and not self._narrowmatch(res[0]): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
220 |
return None |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
221 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
222 |
return res |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
223 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
224 |
def size(self, rev): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
225 |
# Because we have a custom renamed() that may lie, we need to call |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
226 |
# the base renamed() to report accurate results. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
227 |
node = self.node(rev) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
228 |
if super(narrowfilelog, self).renamed(node): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
229 |
return len(self.read(node)) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
230 |
else: |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
231 |
return super(narrowfilelog, self).size(rev) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
232 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
233 |
def cmp(self, node, text): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
234 |
different = super(narrowfilelog, self).cmp(node, text) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
235 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
236 |
# Because renamed() may lie, we may get false positives for |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
237 |
# different content. Check for this by comparing against the original |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
238 |
# renamed() implementation. |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
239 |
if different: |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
240 |
if super(narrowfilelog, self).renamed(node): |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
241 |
t2 = self.read(node) |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
242 |
return t2 != text |
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
243 |
|
3e801ffd7269
filelog: custom filelog to be used with narrow repos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39283
diff
changeset
|
244 |
return different |