Mercurial > hg
annotate mercurial/utils/storageutil.py @ 40006:422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
As part of implementing an alternate storage backend, I found myself
reimplementing this code.
With a little massaging, we can extract filelog.cmp() to a standalone
function.
As part of this, the call to revlog.cmp() was inlined (it is just a
2-line function).
I also tweaked some variable names to improve readability. I'll
further tweak names in a subsequent commit.
Differential Revision: https://phab.mercurial-scm.org/D4801
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 28 Sep 2018 11:47:53 -0700 |
parents | 1d97a332c6d9 |
children | 1470183068b8 |
rev | line source |
---|---|
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # storageutil.py - Storage functionality agnostic of backend implementation. |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 from __future__ import absolute_import |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 import hashlib |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
11 import re |
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
13 from ..i18n import _ |
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 from ..node import ( |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
15 bin, |
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 nullid, |
40004
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
17 nullrev, |
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 ) |
39881
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
19 from .. import ( |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
20 error, |
39881
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
21 pycompat, |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
22 ) |
39877
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
23 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
24 _nullhash = hashlib.sha1(nullid) |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
25 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 def hashrevisionsha1(text, p1, p2): |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
27 """Compute the SHA-1 for revision data and its parents. |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
28 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 This hash combines both the current file contents and its history |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
30 in a manner that makes it easy to distinguish nodes with the same |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 content in the revision graph. |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 """ |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 # As of now, if one of the parent node is null, p2 is null |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
34 if p2 == nullid: |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
35 # deep copy of a hash is faster than creating one |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
36 s = _nullhash.copy() |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 s.update(p1) |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 else: |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 # none of the parent nodes are nullid |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
40 if p1 < p2: |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
41 a = p1 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
42 b = p2 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
43 else: |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
44 a = p2 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 b = p1 |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 s = hashlib.sha1(a) |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 s.update(b) |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 s.update(text) |
f8eb71f9e3bd
storageutil: new module for storage primitives (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 return s.digest() |
39878
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
50 |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
51 METADATA_RE = re.compile(b'\x01\n') |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
52 |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
53 def parsemeta(text): |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
54 """Parse metadata header from revision data. |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
55 |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
56 Returns a 2-tuple of (metadata, offset), where both can be None if there |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
57 is no metadata. |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
58 """ |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
59 # text can be buffer, so we can't use .startswith or .index |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
60 if text[:2] != b'\x01\n': |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
61 return None, None |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
62 s = METADATA_RE.search(text, 2).start() |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
63 mtext = text[2:s] |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
64 meta = {} |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
65 for l in mtext.splitlines(): |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
66 k, v = l.split(b': ', 1) |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
67 meta[k] = v |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
68 return meta, s + 2 |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
69 |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
70 def packmeta(meta, text): |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
71 """Add metadata to fulltext to produce revision text.""" |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
72 keys = sorted(meta) |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
73 metatext = b''.join(b'%s: %s\n' % (k, meta[k]) for k in keys) |
3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39877
diff
changeset
|
74 return b'\x01\n%s\x01\n%s' % (metatext, text) |
39879
d269ddbf54f0
storageutil: move _censoredtext() from revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
75 |
d269ddbf54f0
storageutil: move _censoredtext() from revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
76 def iscensoredtext(text): |
d269ddbf54f0
storageutil: move _censoredtext() from revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
77 meta = parsemeta(text)[0] |
d269ddbf54f0
storageutil: move _censoredtext() from revlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39878
diff
changeset
|
78 return meta and b'censored' in meta |
39880
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
79 |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
80 def filtermetadata(text): |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
81 """Extract just the revision data from source text. |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
82 |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
83 Returns ``text`` unless it has a metadata header, in which case we return |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
84 a new buffer without hte metadata. |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
85 """ |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
86 if not text.startswith(b'\x01\n'): |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
87 return text |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
88 |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
89 offset = text.index(b'\x01\n', 2) |
1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39879
diff
changeset
|
90 return text[offset + 2:] |
39881
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
91 |
40005
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
92 def filerevisioncopied(store, node): |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
93 """Resolve file revision copy metadata. |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
94 |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
95 Returns ``False`` if the file has no copy metadata. Otherwise a |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
96 2-tuple of the source filename and node. |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
97 """ |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
98 if store.parents(node)[0] != nullid: |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
99 return False |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
100 |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
101 meta = parsemeta(store.revision(node))[0] |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
102 |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
103 # copy and copyrev occur in pairs. In rare cases due to old bugs, |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
104 # one can occur without the other. So ensure both are present to flag |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
105 # as a copy. |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
106 if meta and b'copy' in meta and b'copyrev' in meta: |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
107 return meta[b'copy'], bin(meta[b'copyrev']) |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
108 |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
109 return False |
1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40004
diff
changeset
|
110 |
40006
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
111 def filerevisiondifferent(store, node, filedata): |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
112 """Determines whether file data is equivalent to a stored node.""" |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
113 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
114 if filedata.startswith(b'\x01\n'): |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
115 revisiontext = b'\x01\n\x01\n' + filedata |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
116 else: |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
117 revisiontext = filedata |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
118 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
119 p1, p2 = store.parents(node) |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
120 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
121 computednode = hashrevisionsha1(revisiontext, p1, p2) |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
122 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
123 if computednode == node: |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
124 return False |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
125 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
126 # Censored files compare against the empty file. |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
127 if store.iscensored(store.rev(node)): |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
128 return filedata != b'' |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
129 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
130 # Renaming a file produces a different hash, even if the data |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
131 # remains unchanged. Check if that's the case. |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
132 if store.renamed(node): |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
133 return store.read(node) != filedata |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
134 |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
135 return True |
422beffd71ba
storageutil: extract filelog.cmp() to a standalone function
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40005
diff
changeset
|
136 |
39881
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
137 def iterrevs(storelen, start=0, stop=None): |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
138 """Iterate over revision numbers in a store.""" |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
139 step = 1 |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
140 |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
141 if stop is not None: |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
142 if start > stop: |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
143 step = -1 |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
144 stop += step |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
145 if stop > storelen: |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
146 stop = storelen |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
147 else: |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
148 stop = storelen |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
149 |
d63153611ed5
storageutil: extract revision number iteration
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39880
diff
changeset
|
150 return pycompat.xrange(start, stop, step) |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
151 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
152 def fileidlookup(store, fileid, identifier): |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
153 """Resolve the file node for a value. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
154 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
155 ``store`` is an object implementing the ``ifileindex`` interface. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
156 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
157 ``fileid`` can be: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
158 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
159 * A 20 byte binary node. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
160 * An integer revision number |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
161 * A 40 byte hex node. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
162 * A bytes that can be parsed as an integer representing a revision number. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
163 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
164 ``identifier`` is used to populate ``error.LookupError`` with an identifier |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
165 for the store. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
166 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
167 Raises ``error.LookupError`` on failure. |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
168 """ |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
169 if isinstance(fileid, int): |
40003
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
170 try: |
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
171 return store.node(fileid) |
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
172 except IndexError: |
ad8389ecd3f5
storageutil: consistently raise LookupError (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
173 raise error.LookupError(fileid, identifier, _('no match found')) |
40002
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
174 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
175 if len(fileid) == 20: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
176 try: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
177 store.rev(fileid) |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
178 return fileid |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
179 except error.LookupError: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
180 pass |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
181 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
182 if len(fileid) == 40: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
183 try: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
184 rawnode = bin(fileid) |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
185 store.rev(rawnode) |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
186 return rawnode |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
187 except TypeError: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
188 pass |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
189 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
190 try: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
191 rev = int(fileid) |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
192 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
193 if b'%d' % rev != fileid: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
194 raise ValueError |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
195 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
196 try: |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
197 return store.node(rev) |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
198 except (IndexError, TypeError): |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
199 pass |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
200 except (ValueError, OverflowError): |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
201 pass |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
202 |
0e8836be9541
storageutil: implement file identifier resolution method (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39881
diff
changeset
|
203 raise error.LookupError(fileid, identifier, _('no match found')) |
40004
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
204 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
205 def resolvestripinfo(minlinkrev, tiprev, headrevs, linkrevfn, parentrevsfn): |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
206 """Resolve information needed to strip revisions. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
207 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
208 Finds the minimum revision number that must be stripped in order to |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
209 strip ``minlinkrev``. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
210 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
211 Returns a 2-tuple of the minimum revision number to do that and a set |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
212 of all revision numbers that have linkrevs that would be broken |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
213 by that strip. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
214 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
215 ``tiprev`` is the current tip-most revision. It is ``len(store) - 1``. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
216 ``headrevs`` is an iterable of head revisions. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
217 ``linkrevfn`` is a callable that receives a revision and returns a linked |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
218 revision. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
219 ``parentrevsfn`` is a callable that receives a revision number and returns |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
220 an iterable of its parent revision numbers. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
221 """ |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
222 brokenrevs = set() |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
223 strippoint = tiprev + 1 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
224 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
225 heads = {} |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
226 futurelargelinkrevs = set() |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
227 for head in headrevs: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
228 headlinkrev = linkrevfn(head) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
229 heads[head] = headlinkrev |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
230 if headlinkrev >= minlinkrev: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
231 futurelargelinkrevs.add(headlinkrev) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
232 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
233 # This algorithm involves walking down the rev graph, starting at the |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
234 # heads. Since the revs are topologically sorted according to linkrev, |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
235 # once all head linkrevs are below the minlink, we know there are |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
236 # no more revs that could have a linkrev greater than minlink. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
237 # So we can stop walking. |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
238 while futurelargelinkrevs: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
239 strippoint -= 1 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
240 linkrev = heads.pop(strippoint) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
241 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
242 if linkrev < minlinkrev: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
243 brokenrevs.add(strippoint) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
244 else: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
245 futurelargelinkrevs.remove(linkrev) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
246 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
247 for p in parentrevsfn(strippoint): |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
248 if p != nullrev: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
249 plinkrev = linkrevfn(p) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
250 heads[p] = plinkrev |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
251 if plinkrev >= minlinkrev: |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
252 futurelargelinkrevs.add(plinkrev) |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
253 |
fa3dc85a747e
storageutil: extract functionality for resolving strip revisions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40003
diff
changeset
|
254 return strippoint, brokenrevs |