Mercurial > hg-stable
annotate mercurial/filelog.py @ 37441:a3202fa83aff
filelog: declare that filelog implements a storage interface
Now that we have a declared interface, let's declare that filelog
implements it.
Tests have been added that confirm the object conforms to the
interface.
The existing interface checks verify there are no extra public
attributes outside the declared interface. filelog has several
extra attributes. So we added a mechanism to suppress this check.
The goal is to modify the filelog class so we can drop this check.
Differential Revision: https://phab.mercurial-scm.org/D3149
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 05 Apr 2018 15:18:23 -0700 |
parents | 07769a04bc66 |
children | 0596d27457c6 |
rev | line source |
---|---|
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 |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
10 import re |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
11 import struct |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
12 |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
13 from .thirdparty.zope import ( |
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
14 interface as zi, |
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
15 ) |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
16 from . import ( |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
17 error, |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
18 mdiff, |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
19 repository, |
25948
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
20 revlog, |
34bd1a5eef5b
filelog: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24255
diff
changeset
|
21 ) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
22 |
14074
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
23 _mdre = re.compile('\1\n') |
22421
30a610424eff
filelog: make parsemeta a public module function, to be used by censor module
Mike Edgar <adgar@google.com>
parents:
22420
diff
changeset
|
24 def parsemeta(text): |
32177 | 25 """return (metadatadict, metadatasize)""" |
14074
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
26 # text can be buffer, so we can't use .startswith or .index |
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
27 if text[:2] != '\1\n': |
22422
75bb7c702317
filelog: parsemeta stops returning unused key list
Mike Edgar <adgar@google.com>
parents:
22421
diff
changeset
|
28 return None, None |
14074
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
29 s = _mdre.search(text, 2).start() |
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
30 mtext = text[2:s] |
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
31 meta = {} |
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
32 for l in mtext.splitlines(): |
13240
e5060aa22043
filelog: move metadata parsing to a helper function
Matt Mackall <mpm@selenic.com>
parents:
11541
diff
changeset
|
33 k, v = l.split(": ", 1) |
14074
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
34 meta[k] = v |
22422
75bb7c702317
filelog: parsemeta stops returning unused key list
Mike Edgar <adgar@google.com>
parents:
22421
diff
changeset
|
35 return meta, (s + 2) |
14074
e8271159c8c2
filelog: extract metadata parsing and packing
Sune Foldager <cryo@cyanite.org>
parents:
13240
diff
changeset
|
36 |
22420
4669e26747c3
filelog: make packmeta a public module function, to be used by censor
Mike Edgar <adgar@google.com>
parents:
19148
diff
changeset
|
37 def packmeta(meta, text): |
34041
ba479850c9c7
python3: replace sorted(<dict>.iterkeys()) with sorted(<dict>)
Augie Fackler <raf@durin42.com>
parents:
32177
diff
changeset
|
38 keys = sorted(meta) |
22420
4669e26747c3
filelog: make packmeta a public module function, to be used by censor
Mike Edgar <adgar@google.com>
parents:
19148
diff
changeset
|
39 metatext = "".join("%s: %s\n" % (k, meta[k]) for k in keys) |
4669e26747c3
filelog: make packmeta a public module function, to be used by censor
Mike Edgar <adgar@google.com>
parents:
19148
diff
changeset
|
40 return "\1\n%s\1\n%s" % (metatext, text) |
13240
e5060aa22043
filelog: move metadata parsing to a helper function
Matt Mackall <mpm@selenic.com>
parents:
11541
diff
changeset
|
41 |
22596
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
42 def _censoredtext(text): |
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
43 m, offs = parsemeta(text) |
24117
9cfd7c4f22f5
filelog: allow censored files to contain padding data
Mike Edgar <adgar@google.com>
parents:
24003
diff
changeset
|
44 return m and "censored" in m |
22596
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
45 |
37441
a3202fa83aff
filelog: declare that filelog implements a storage interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35567
diff
changeset
|
46 @zi.implementer(repository.ifilestorage) |
7634
14a4337a9b9b
revlog: kill from-style imports
Matt Mackall <mpm@selenic.com>
parents:
7622
diff
changeset
|
47 class filelog(revlog.revlog): |
4258
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4257
diff
changeset
|
48 def __init__(self, opener, path): |
19148
3bda242bf244
filelog: use super() for calling base functions
Durham Goode <durham@fb.com>
parents:
14287
diff
changeset
|
49 super(filelog, self).__init__(opener, |
8531
810387f59696
filelog encoding: move the encoding/decoding into store
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8225
diff
changeset
|
50 "/".join(("data", path + ".i"))) |
35567
07769a04bc66
filelog: add the ability to report the user facing name
Matt Harbison <matt_harbison@yahoo.com>
parents:
34041
diff
changeset
|
51 # full name of the user visible file, relative to the repository root |
07769a04bc66
filelog: add the ability to report the user facing name
Matt Harbison <matt_harbison@yahoo.com>
parents:
34041
diff
changeset
|
52 self.filename = path |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
53 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
54 def read(self, node): |
360 | 55 t = self.revision(node) |
686
d7d68d27ebe5
Reapply startswith() changes that got lost with stale edit
Matt Mackall <mpm@selenic.com>
parents:
681
diff
changeset
|
56 if not t.startswith('\1\n'): |
360 | 57 return t |
2579
0875cda033fd
use __contains__, index or split instead of str.find
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2470
diff
changeset
|
58 s = t.index('\1\n', 2) |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
59 return t[s + 2:] |
360 | 60 |
61 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
|
62 if meta or text.startswith('\1\n'): |
22420
4669e26747c3
filelog: make packmeta a public module function, to be used by censor
Mike Edgar <adgar@google.com>
parents:
19148
diff
changeset
|
63 text = packmeta(meta, text) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
64 return self.addrevision(text, transaction, link, p1, p2) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
65 |
1116 | 66 def renamed(self, node): |
7634
14a4337a9b9b
revlog: kill from-style imports
Matt Mackall <mpm@selenic.com>
parents:
7622
diff
changeset
|
67 if self.parents(node)[0] != revlog.nullid: |
1116 | 68 return False |
13240
e5060aa22043
filelog: move metadata parsing to a helper function
Matt Mackall <mpm@selenic.com>
parents:
11541
diff
changeset
|
69 t = self.revision(node) |
22421
30a610424eff
filelog: make parsemeta a public module function, to be used by censor module
Mike Edgar <adgar@google.com>
parents:
22420
diff
changeset
|
70 m = parsemeta(t)[0] |
5915
d0576d065993
Prefer i in d over d.has_key(i)
Christian Ebert <blacktrash@gmx.net>
parents:
4635
diff
changeset
|
71 if m and "copy" in m: |
7634
14a4337a9b9b
revlog: kill from-style imports
Matt Mackall <mpm@selenic.com>
parents:
7622
diff
changeset
|
72 return (m["copy"], revlog.bin(m["copyrev"])) |
1116 | 73 return False |
74 | |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
75 def size(self, rev): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
76 """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
|
77 |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
78 # 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
|
79 node = self.node(rev) |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
80 if self.renamed(node): |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
81 return len(self.read(node)) |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24117
diff
changeset
|
82 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
|
83 return 0 |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
84 |
11540
2370e270a29a
filelog: test behaviour for data starting with "\1\n"
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11539
diff
changeset
|
85 # XXX if self.read(node).startswith("\1\n"), this returns (size+4) |
19148
3bda242bf244
filelog: use super() for calling base functions
Durham Goode <durham@fb.com>
parents:
14287
diff
changeset
|
86 return super(filelog, self).size(rev) |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2895
diff
changeset
|
87 |
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
88 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
|
89 """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
|
90 |
a463e3c50212
cmp: document the fact that we return True if content is different
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
10706
diff
changeset
|
91 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
|
92 """ |
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
93 |
11541
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
94 t = text |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
95 if text.startswith('\1\n'): |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
96 t = '\1\n\1\n' + text |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
97 |
19148
3bda242bf244
filelog: use super() for calling base functions
Durham Goode <durham@fb.com>
parents:
14287
diff
changeset
|
98 samehashes = not super(filelog, self).cmp(node, t) |
11541
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
99 if samehashes: |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
100 return False |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
101 |
22597
58ec36686f0e
filelog: censored files compare against empty data, have 0 size
Mike Edgar <adgar@google.com>
parents:
22596
diff
changeset
|
102 # censored files compare against the empty file |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24117
diff
changeset
|
103 if self.iscensored(self.rev(node)): |
22597
58ec36686f0e
filelog: censored files compare against empty data, have 0 size
Mike Edgar <adgar@google.com>
parents:
22596
diff
changeset
|
104 return text != '' |
58ec36686f0e
filelog: censored files compare against empty data, have 0 size
Mike Edgar <adgar@google.com>
parents:
22596
diff
changeset
|
105 |
11541
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
106 # renaming a file produces a different hash, even if the data |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
107 # remains unchanged. Check if it's the case (slow): |
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
108 if self.renamed(node): |
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
109 t2 = self.read(node) |
2895
21631c2c09a5
filelog.cmp: return 0 for equality
Matt Mackall <mpm@selenic.com>
parents:
2890
diff
changeset
|
110 return t2 != text |
2887
05257fd28591
filelog: add hash-based comparisons
Matt Mackall <mpm@selenic.com>
parents:
2859
diff
changeset
|
111 |
11541
ab9fa7a85dd9
filelog: cmp: don't read data if hashes are identical (issue2273)
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
11540
diff
changeset
|
112 return True |
14287
7c231754a621
filelog: add file function to open other filelogs
Sune Foldager <cryo@cyanite.org>
parents:
14074
diff
changeset
|
113 |
30589
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
25948
diff
changeset
|
114 def checkhash(self, text, node, p1=None, p2=None, rev=None): |
22596
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
115 try: |
30589
be5b2098a817
revlog: merge hash checking subfunctions
Remi Chaintron <remi@fb.com>
parents:
25948
diff
changeset
|
116 super(filelog, self).checkhash(text, node, p1=p1, p2=p2, rev=rev) |
22596
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
117 except error.RevlogError: |
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
118 if _censoredtext(text): |
24190
903c7e8c97ad
changegroup: emit full-replacement deltas if either revision is censored
Mike Edgar <adgar@google.com>
parents:
24118
diff
changeset
|
119 raise error.CensoredNodeError(self.indexfile, node, text) |
22596
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
120 raise |
27e2317efe89
filelog: raise CensoredNodeError when hash checks fail with censor metadata
Mike Edgar <adgar@google.com>
parents:
22422
diff
changeset
|
121 |
24118
76f6ae06ddf5
revlog: add "iscensored()" to revlog public API
Mike Edgar <adgar@google.com>
parents:
24117
diff
changeset
|
122 def iscensored(self, rev): |
22597
58ec36686f0e
filelog: censored files compare against empty data, have 0 size
Mike Edgar <adgar@google.com>
parents:
22596
diff
changeset
|
123 """Check if a file revision is censored.""" |
23858
22a979d1ae56
filelog: use censored revlog flag bit to quickly check if a node is censored
Mike Edgar <adgar@google.com>
parents:
22597
diff
changeset
|
124 return self.flags(rev) & revlog.REVIDX_ISCENSORED |
24255
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
125 |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
126 def _peek_iscensored(self, baserev, delta, flush): |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
127 """Quickly check if a delta produces a censored revision.""" |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
128 # Fragile heuristic: unless new file meta keys are added alphabetically |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
129 # preceding "censored", all censored revisions are prefixed by |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
130 # "\1\ncensored:". A delta producing such a censored revision must be a |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
131 # full-replacement delta, so we inspect the first and only patch in the |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
132 # delta for this prefix. |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
133 hlen = struct.calcsize(">lll") |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
134 if len(delta) <= hlen: |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
135 return False |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
136 |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
137 oldlen = self.rawsize(baserev) |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
138 newlen = len(delta) - hlen |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
139 if delta[:hlen] != mdiff.replacediffheader(oldlen, newlen): |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
140 return False |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
141 |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
142 add = "\1\ncensored:" |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
143 addlen = len(add) |
4bfe9f2d9761
revlog: addgroup checks if incoming deltas add censored revs, sets flag bit
Mike Edgar <adgar@google.com>
parents:
24190
diff
changeset
|
144 return newlen >= addlen and delta[hlen:hlen + addlen] == add |