Mercurial > hg
annotate mercurial/changelog.py @ 23278:aa19432764d6
transaction: handle missing file in backupentries (instead of using entries)
The case where a backup of a missing file was requested was previously
handled by the 'entries' list. As the 'backupentries' is about to gain
ability to backup files outside of '.hg/store', we want it to be able
to handle the missing file too.
Reminder: using 'addbackup' on a missing file means that such file needs to be
deleted if we rollback the transaction.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 05 Nov 2014 01:38:48 +0000 |
parents | 2d54aa5397cd |
children | b01c491af0cf |
rev | line source |
---|---|
1095 | 1 # changelog.py - changelog 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:
4269
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:
8209
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 |
23205
2d54aa5397cd
changelog: rely on transaction for finalization
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
8 import weakref |
6211
f89fd07fc51d
Expand import * to allow Pyflakes to find problems
Joel Rosdahl <joel@rosdahl.net>
parents:
5791
diff
changeset
|
9 from node import bin, hex, nullid |
7035
9d023ef7b467
forbid username with '\n' at the changelog level
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6259
diff
changeset
|
10 from i18n import _ |
7948
de377b1a9a84
move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents:
7807
diff
changeset
|
11 import util, error, revlog, encoding |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
12 |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
13 _defaultextra = {'branch': 'default'} |
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
14 |
3232
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
15 def _string_escape(text): |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
16 """ |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
17 >>> d = {'nl': chr(10), 'bs': chr(92), 'cr': chr(13), 'nul': chr(0)} |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
18 >>> s = "ab%(nl)scd%(bs)s%(bs)sn%(nul)sab%(cr)scd%(bs)s%(nl)s" % d |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
19 >>> s |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
20 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
21 >>> res = _string_escape(s) |
5745
234e40e636a8
changelog: inline trivial call for extra data unescaping
Matt Mackall <mpm@selenic.com>
parents:
5744
diff
changeset
|
22 >>> s == res.decode('string_escape') |
3232
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
23 True |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
24 """ |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
25 # subset of the string_escape codec |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
26 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
27 return text.replace('\0', '\\0') |
394ac87f3b74
[extendedchangelog] encode/decode function
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3077
diff
changeset
|
28 |
8443
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
29 def decodeextra(text): |
15661
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
30 """ |
18379
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
31 >>> sorted(decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}) |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
32 ... ).iteritems()) |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
33 [('baz', '\\x002'), ('branch', 'default'), ('foo', 'bar')] |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
34 >>> sorted(decodeextra(encodeextra({'foo': 'bar', |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
35 ... 'baz': chr(92) + chr(0) + '2'}) |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
36 ... ).iteritems()) |
e0c4f4ba624c
tests: fix doctest stability over Python versions
Mads Kiilerich <madski@unity3d.com>
parents:
18378
diff
changeset
|
37 [('baz', '\\\\\\x002'), ('branch', 'default'), ('foo', 'bar')] |
15661
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
38 """ |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
39 extra = _defaultextra.copy() |
8443
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
40 for l in text.split('\0'): |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
41 if l: |
15661
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
42 if '\\0' in l: |
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
43 # fix up \0 without getting into trouble with \\0 |
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
44 l = l.replace('\\\\', '\\\\\n') |
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
45 l = l.replace('\\0', '\0') |
20ae902c43ec
changelog: handle decoding of NULs in extra more carefully (issue3156)
Matt Mackall <mpm@selenic.com>
parents:
14643
diff
changeset
|
46 l = l.replace('\n', '') |
8443
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
47 k, v = l.decode('string_escape').split(':', 1) |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
48 extra[k] = v |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
49 return extra |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
50 |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
51 def encodeextra(d): |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
52 # keys must be sorted to produce a deterministic changelog entry |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
53 items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)] |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
54 return "\0".join(items) |
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
55 |
17810
2894d180afa1
changelog: extract description cleaning logic in a dedicated function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17677
diff
changeset
|
56 def stripdesc(desc): |
2894d180afa1
changelog: extract description cleaning logic in a dedicated function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17677
diff
changeset
|
57 """strip trailing whitespace and leading and trailing empty lines""" |
2894d180afa1
changelog: extract description cleaning logic in a dedicated function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17677
diff
changeset
|
58 return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') |
2894d180afa1
changelog: extract description cleaning logic in a dedicated function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17677
diff
changeset
|
59 |
8778
c5f36402daad
use new style classes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8644
diff
changeset
|
60 class appender(object): |
7807
bd8f44638847
help: miscellaneous language fixes
timeless <timeless@gmail.com>
parents:
7787
diff
changeset
|
61 '''the changelog index must be updated last on disk, so we use this class |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
62 to delay writes to it''' |
19899
8c3dcbbfb5de
changelog: use "vfs.fstat()" instead of "util.fstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19898
diff
changeset
|
63 def __init__(self, vfs, name, mode, buf): |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
64 self.data = buf |
19899
8c3dcbbfb5de
changelog: use "vfs.fstat()" instead of "util.fstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19898
diff
changeset
|
65 fp = vfs(name, mode) |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
66 self.fp = fp |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
67 self.offset = fp.tell() |
19899
8c3dcbbfb5de
changelog: use "vfs.fstat()" instead of "util.fstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19898
diff
changeset
|
68 self.size = vfs.fstat(fp).st_size |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
69 |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
70 def end(self): |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
71 return self.size + len("".join(self.data)) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
72 def tell(self): |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
73 return self.offset |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
74 def flush(self): |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
75 pass |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
76 def close(self): |
4961
3fdd09ad6cce
fix bogus close spotted by pychecker (no close() in global scope)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
4635
diff
changeset
|
77 self.fp.close() |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
78 |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
79 def seek(self, offset, whence=0): |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
80 '''virtual file offset spans real file and data''' |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
81 if whence == 0: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
82 self.offset = offset |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
83 elif whence == 1: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
84 self.offset += offset |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
85 elif whence == 2: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
86 self.offset = self.end() + offset |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
87 if self.offset < self.size: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
88 self.fp.seek(self.offset) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
89 |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
90 def read(self, count=-1): |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
91 '''only trick here is reads that span real file and data''' |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
92 ret = "" |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
93 if self.offset < self.size: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
94 s = self.fp.read(count) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
95 ret = s |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
96 self.offset += len(s) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
97 if count > 0: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
98 count -= len(s) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
99 if count != 0: |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
100 doff = self.offset - self.size |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
101 self.data.insert(0, "".join(self.data)) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
102 del self.data[1:] |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
103 s = self.data[0][doff:doff + count] |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
104 self.offset += len(s) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
105 ret += s |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
106 return ret |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
107 |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
108 def write(self, s): |
5450
c728424d44c6
revlog: fix caching of buffer objects
Matt Mackall <mpm@selenic.com>
parents:
4963
diff
changeset
|
109 self.data.append(str(s)) |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
110 self.offset += len(s) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
111 |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
112 def _divertopener(opener, target): |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
113 """build an opener that writes in 'target.a' instead of 'target'""" |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
114 def _divert(name, mode='r'): |
9166
e6162b854ed5
changelog: move delayopener outside of class to eliminate reference cycle
Matt Mackall <mpm@selenic.com>
parents:
9165
diff
changeset
|
115 if name != target: |
e6162b854ed5
changelog: move delayopener outside of class to eliminate reference cycle
Matt Mackall <mpm@selenic.com>
parents:
9165
diff
changeset
|
116 return opener(name, mode) |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
117 return opener(name + ".a", mode) |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
118 return _divert |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
119 |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
120 def _delayopener(opener, target, buf): |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
121 """build an opener that stores chunks in 'buf' instead of 'target'""" |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
122 def _delay(name, mode='r'): |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
123 if name != target: |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
124 return opener(name, mode) |
19899
8c3dcbbfb5de
changelog: use "vfs.fstat()" instead of "util.fstat()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19898
diff
changeset
|
125 return appender(opener, name, mode, buf) |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
126 return _delay |
9166
e6162b854ed5
changelog: move delayopener outside of class to eliminate reference cycle
Matt Mackall <mpm@selenic.com>
parents:
9165
diff
changeset
|
127 |
7634
14a4337a9b9b
revlog: kill from-style imports
Matt Mackall <mpm@selenic.com>
parents:
7633
diff
changeset
|
128 class changelog(revlog.revlog): |
4258
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4257
diff
changeset
|
129 def __init__(self, opener): |
9165
07f9b2f4a9aa
changelog: swap opener to switch delay modes
Matt Mackall <mpm@selenic.com>
parents:
9164
diff
changeset
|
130 revlog.revlog.__init__(self, opener, "00changelog.i") |
14334
85c82ebc96a3
changelog: don't use generaldelta
Sune Foldager <cryo@cyanite.org>
parents:
14207
diff
changeset
|
131 if self._initempty: |
85c82ebc96a3
changelog: don't use generaldelta
Sune Foldager <cryo@cyanite.org>
parents:
14207
diff
changeset
|
132 # changelogs don't benefit from generaldelta |
85c82ebc96a3
changelog: don't use generaldelta
Sune Foldager <cryo@cyanite.org>
parents:
14207
diff
changeset
|
133 self.version &= ~revlog.REVLOGGENERALDELTA |
85c82ebc96a3
changelog: don't use generaldelta
Sune Foldager <cryo@cyanite.org>
parents:
14207
diff
changeset
|
134 self._generaldelta = False |
8644
c2ef478b2efa
changelog: make delayopener less intrusive
Matt Mackall <mpm@selenic.com>
parents:
8499
diff
changeset
|
135 self._realopener = opener |
c2ef478b2efa
changelog: make delayopener less intrusive
Matt Mackall <mpm@selenic.com>
parents:
8499
diff
changeset
|
136 self._delayed = False |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
137 self._delaybuf = None |
9163
f193b643d1b1
changelog: _delaycount -> _divert
Matt Mackall <mpm@selenic.com>
parents:
8778
diff
changeset
|
138 self._divert = False |
18231
c0c943ef4e55
clfilter: use empty frozenset intead of empty tuple
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17951
diff
changeset
|
139 self.filteredrevs = frozenset() |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
140 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
141 def tip(self): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
142 """filtered version of revlog.tip""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
143 for i in xrange(len(self) -1, -2, -1): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
144 if i not in self.filteredrevs: |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
145 return self.node(i) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
146 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
147 def __iter__(self): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
148 """filtered version of revlog.__iter__""" |
17951
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
149 if len(self.filteredrevs) == 0: |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
150 return revlog.revlog.__iter__(self) |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
151 |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
152 def filterediter(): |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
153 for i in xrange(len(self)): |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
154 if i not in self.filteredrevs: |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
155 yield i |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
156 |
6f79c32c0bdf
commit: increase perf by avoiding unnecessary filteredrevs check
Durham Goode <durham@fb.com>
parents:
17810
diff
changeset
|
157 return filterediter() |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
158 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
159 def revs(self, start=0, stop=None): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
160 """filtered version of revlog.revs""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
161 for i in super(changelog, self).revs(start, stop): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
162 if i not in self.filteredrevs: |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
163 yield i |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
164 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
165 @util.propertycache |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
166 def nodemap(self): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
167 # XXX need filtering too |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
168 self.rev(self.node(0)) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
169 return self._nodecache |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
170 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
171 def hasnode(self, node): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
172 """filtered version of revlog.hasnode""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
173 try: |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
174 i = self.rev(node) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
175 return i not in self.filteredrevs |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
176 except KeyError: |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
177 return False |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
178 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
179 def headrevs(self): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
180 if self.filteredrevs: |
22484
2b5940f64750
obsolete: use C code for headrevs calculation
Durham Goode <durham@fb.com>
parents:
21544
diff
changeset
|
181 try: |
23088
fe5f044b753d
changelog: use headrevsfiltered
Mads Kiilerich <madski@unity3d.com>
parents:
23015
diff
changeset
|
182 return self.index.headrevsfiltered(self.filteredrevs) |
fe5f044b753d
changelog: use headrevsfiltered
Mads Kiilerich <madski@unity3d.com>
parents:
23015
diff
changeset
|
183 # AttributeError covers non-c-extension environments and |
fe5f044b753d
changelog: use headrevsfiltered
Mads Kiilerich <madski@unity3d.com>
parents:
23015
diff
changeset
|
184 # old c extensions without filter handling. |
fe5f044b753d
changelog: use headrevsfiltered
Mads Kiilerich <madski@unity3d.com>
parents:
23015
diff
changeset
|
185 except AttributeError: |
22484
2b5940f64750
obsolete: use C code for headrevs calculation
Durham Goode <durham@fb.com>
parents:
21544
diff
changeset
|
186 return self._headrevs() |
2b5940f64750
obsolete: use C code for headrevs calculation
Durham Goode <durham@fb.com>
parents:
21544
diff
changeset
|
187 |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
188 return super(changelog, self).headrevs() |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
189 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
190 def strip(self, *args, **kwargs): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
191 # XXX make something better than assert |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
192 # We can't expect proper strip behavior if we are filtered. |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
193 assert not self.filteredrevs |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
194 super(changelog, self).strip(*args, **kwargs) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
195 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
196 def rev(self, node): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
197 """filtered version of revlog.rev""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
198 r = super(changelog, self).rev(node) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
199 if r in self.filteredrevs: |
23015
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
200 raise error.FilteredLookupError(hex(node), self.indexfile, |
21c44c1aed87
repoview: add a FilteredLookupError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23014
diff
changeset
|
201 _('filtered node')) |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
202 return r |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
203 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
204 def node(self, rev): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
205 """filtered version of revlog.node""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
206 if rev in self.filteredrevs: |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22484
diff
changeset
|
207 raise error.FilteredIndexError(rev) |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
208 return super(changelog, self).node(rev) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
209 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
210 def linkrev(self, rev): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
211 """filtered version of revlog.linkrev""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
212 if rev in self.filteredrevs: |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22484
diff
changeset
|
213 raise error.FilteredIndexError(rev) |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
214 return super(changelog, self).linkrev(rev) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
215 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
216 def parentrevs(self, rev): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
217 """filtered version of revlog.parentrevs""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
218 if rev in self.filteredrevs: |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22484
diff
changeset
|
219 raise error.FilteredIndexError(rev) |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
220 return super(changelog, self).parentrevs(rev) |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
221 |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
222 def flags(self, rev): |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
223 """filtered version of revlog.flags""" |
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
224 if rev in self.filteredrevs: |
23014
f00813325c5a
repoview: add a FilteredIndexError class
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22484
diff
changeset
|
225 raise error.FilteredIndexError(rev) |
17677
5c89e7fa5bc2
clfilter: introduce `filteredrevs` attribute on changelog
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17424
diff
changeset
|
226 return super(changelog, self).flags(rev) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
227 |
23203
3872d563e01a
changelog: handle writepending in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23201
diff
changeset
|
228 def delayupdate(self, tr): |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
229 "delay visibility of index updates to other readers" |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
230 |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
231 if not self._delayed: |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
232 if len(self) == 0: |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
233 self._divert = True |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
234 if self._realopener.exists(self.indexfile + '.a'): |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
235 self._realopener.unlink(self.indexfile + '.a') |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
236 self.opener = _divertopener(self._realopener, self.indexfile) |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
237 else: |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
238 self._delaybuf = [] |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
239 self.opener = _delayopener(self._realopener, self.indexfile, |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
240 self._delaybuf) |
8644
c2ef478b2efa
changelog: make delayopener less intrusive
Matt Mackall <mpm@selenic.com>
parents:
8499
diff
changeset
|
241 self._delayed = True |
23203
3872d563e01a
changelog: handle writepending in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23201
diff
changeset
|
242 tr.addpending('cl-%i' % id(self), self._writepending) |
23205
2d54aa5397cd
changelog: rely on transaction for finalization
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
243 trp = weakref.proxy(tr) |
2d54aa5397cd
changelog: rely on transaction for finalization
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
244 tr.addfinalize('cl-%i' % id(self), lambda: self._finalize(trp)) |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
245 |
23205
2d54aa5397cd
changelog: rely on transaction for finalization
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23203
diff
changeset
|
246 def _finalize(self, tr): |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
247 "finalize index updates" |
8644
c2ef478b2efa
changelog: make delayopener less intrusive
Matt Mackall <mpm@selenic.com>
parents:
8499
diff
changeset
|
248 self._delayed = False |
9165
07f9b2f4a9aa
changelog: swap opener to switch delay modes
Matt Mackall <mpm@selenic.com>
parents:
9164
diff
changeset
|
249 self.opener = self._realopener |
4269
73c918c71300
changelog: optimize delayed updates for clone vs pull
Matt Mackall <mpm@selenic.com>
parents:
4261
diff
changeset
|
250 # move redirected index data back into place |
9164
b0d995b6b0a6
changelog: factor out _delayname
Matt Mackall <mpm@selenic.com>
parents:
9163
diff
changeset
|
251 if self._divert: |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
252 assert not self._delaybuf |
19898
3f92e749d381
changelog: use "vfs.rename()" instead of "util.rename()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18587
diff
changeset
|
253 tmpname = self.indexfile + ".a" |
3f92e749d381
changelog: use "vfs.rename()" instead of "util.rename()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18587
diff
changeset
|
254 nfile = self.opener.open(tmpname) |
14207
c1cca38818b9
changelog: fixes leaked file handle
Zachary Gramana <zgramana@pottsconsultinggroup.com>
parents:
14004
diff
changeset
|
255 nfile.close() |
19898
3f92e749d381
changelog: use "vfs.rename()" instead of "util.rename()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
18587
diff
changeset
|
256 self.opener.rename(tmpname, self.indexfile) |
4269
73c918c71300
changelog: optimize delayed updates for clone vs pull
Matt Mackall <mpm@selenic.com>
parents:
4261
diff
changeset
|
257 elif self._delaybuf: |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
258 fp = self.opener(self.indexfile, 'a') |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
259 fp.write("".join(self._delaybuf)) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
260 fp.close() |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
261 self._delaybuf = None |
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
262 self._divert = False |
4269
73c918c71300
changelog: optimize delayed updates for clone vs pull
Matt Mackall <mpm@selenic.com>
parents:
4261
diff
changeset
|
263 # split when we're done |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
264 self.checkinlinesize(tr) |
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
265 |
7787
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
266 def readpending(self, file): |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
267 r = revlog.revlog(self.opener, file) |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
268 self.index = r.index |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
269 self.nodemap = r.nodemap |
16619
bc84a1aeaf5a
changelog: ensure that nodecache is valid (issue3428)
Bryan O'Sullivan <bryano@fb.com>
parents:
16267
diff
changeset
|
270 self._nodecache = r._nodecache |
7787
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
271 self._chunkcache = r._chunkcache |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
272 |
23203
3872d563e01a
changelog: handle writepending in the transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23201
diff
changeset
|
273 def _writepending(self): |
7787
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
274 "create a file containing the unfinalized state for pretxnchangegroup" |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
275 if self._delaybuf: |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
276 # make a temporary copy of the index |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
277 fp1 = self._realopener(self.indexfile) |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
278 fp2 = self._realopener(self.indexfile + ".a", "w") |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
279 fp2.write(fp1.read()) |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
280 # add pending data |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
281 fp2.write("".join(self._delaybuf)) |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
282 fp2.close() |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
283 # switch modes so finalize can simply rename |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
284 self._delaybuf = None |
9164
b0d995b6b0a6
changelog: factor out _delayname
Matt Mackall <mpm@selenic.com>
parents:
9163
diff
changeset
|
285 self._divert = True |
23201
7e97bf6ee2d6
changelog: rework the delayupdate mechanism
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23088
diff
changeset
|
286 self.opener = _divertopener(self._realopener, self.indexfile) |
7787
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
287 |
9164
b0d995b6b0a6
changelog: factor out _delayname
Matt Mackall <mpm@selenic.com>
parents:
9163
diff
changeset
|
288 if self._divert: |
7787
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
289 return True |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
290 |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
291 return False |
b8d750daadde
Introduce HG_PREPEND to solve pretxn races
Matt Mackall <mpm@selenic.com>
parents:
7634
diff
changeset
|
292 |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
293 def checkinlinesize(self, tr, fp=None): |
9165
07f9b2f4a9aa
changelog: swap opener to switch delay modes
Matt Mackall <mpm@selenic.com>
parents:
9164
diff
changeset
|
294 if not self._delayed: |
07f9b2f4a9aa
changelog: swap opener to switch delay modes
Matt Mackall <mpm@selenic.com>
parents:
9164
diff
changeset
|
295 revlog.revlog.checkinlinesize(self, tr, fp) |
4261
cd7b36b7869c
restructure changelog file appending
Matt Mackall <mpm@selenic.com>
parents:
4258
diff
changeset
|
296 |
5744
9db7fd77417d
changelog: remove extract function
Matt Mackall <mpm@selenic.com>
parents:
5450
diff
changeset
|
297 def read(self, node): |
3077
ad6aecaf4eed
document changelog format
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2859
diff
changeset
|
298 """ |
ad6aecaf4eed
document changelog format
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2859
diff
changeset
|
299 format used: |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
300 nodeid\n : manifest node in ascii |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
301 user\n : user, no \n or \r allowed |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
302 time tz extra\n : date (time is int or float, timezone is int) |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17207
diff
changeset
|
303 : extra is metadata, encoded and separated by '\0' |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
304 : older versions ignore it |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
305 files\n\n : files modified by the cset, no \n or \r allowed |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
306 (.*) : comment (free text, ideally utf-8) |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
307 |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
308 changelog v0 doesn't use extra |
3077
ad6aecaf4eed
document changelog format
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2859
diff
changeset
|
309 """ |
5744
9db7fd77417d
changelog: remove extract function
Matt Mackall <mpm@selenic.com>
parents:
5450
diff
changeset
|
310 text = self.revision(node) |
37 | 311 if not text: |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
312 return (nullid, "", (0, 0), [], "", _defaultextra) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
313 last = text.index("\n\n") |
7948
de377b1a9a84
move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents:
7807
diff
changeset
|
314 desc = encoding.tolocal(text[last + 2:]) |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
315 l = text[:last].split('\n') |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
316 manifest = bin(l[0]) |
7948
de377b1a9a84
move encoding bits from util to encoding
Matt Mackall <mpm@selenic.com>
parents:
7807
diff
changeset
|
317 user = encoding.tolocal(l[1]) |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
318 |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
319 tdata = l[2].split(' ', 2) |
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
320 if len(tdata) != 3: |
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
321 time = float(tdata[0]) |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
322 try: |
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
323 # various tools did silly things with the time zone field. |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
324 timezone = int(tdata[1]) |
14004
97ed99d1f419
eliminate various naked except clauses
Idan Kamara <idankk86@gmail.com>
parents:
10420
diff
changeset
|
325 except ValueError: |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
326 timezone = 0 |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
327 extra = _defaultextra |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
328 else: |
16267
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
329 time, timezone = float(tdata[0]), int(tdata[1]) |
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
330 extra = decodeextra(tdata[2]) |
aa6821a7b52f
changelog: micro-optimizations to changelog.read()
Matt Mackall <mpm@selenic.com>
parents:
15661
diff
changeset
|
331 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
332 files = l[3:] |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
333 return (manifest, user, (time, timezone), files, desc, extra) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
334 |
8422
437e06bbd11e
changelog: removed bad default arguments in add method
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
335 def add(self, manifest, files, desc, transaction, p1, p2, |
9677
0c072e63e3e7
changelog: do not use a mutable default value
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
9166
diff
changeset
|
336 user, date=None, extra=None): |
14379
bd23d5f28bbb
changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents:
10420
diff
changeset
|
337 # Convert to UTF-8 encoded bytestrings as the very first |
bd23d5f28bbb
changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents:
10420
diff
changeset
|
338 # thing: calling any method on a localstr object will turn it |
bd23d5f28bbb
changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents:
10420
diff
changeset
|
339 # into a str object and the cached UTF-8 string is thus lost. |
bd23d5f28bbb
changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents:
10420
diff
changeset
|
340 user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) |
bd23d5f28bbb
changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents:
10420
diff
changeset
|
341 |
7035
9d023ef7b467
forbid username with '\n' at the changelog level
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6259
diff
changeset
|
342 user = user.strip() |
8424
c5b3d3e30de7
changelog: refuse to add revisions with empty usernames
Martin Geisler <mg@lazybytes.net>
parents:
7807
diff
changeset
|
343 # An empty username or a username with a "\n" will make the |
c5b3d3e30de7
changelog: refuse to add revisions with empty usernames
Martin Geisler <mg@lazybytes.net>
parents:
7807
diff
changeset
|
344 # revision text contain two "\n\n" sequences -> corrupt |
c5b3d3e30de7
changelog: refuse to add revisions with empty usernames
Martin Geisler <mg@lazybytes.net>
parents:
7807
diff
changeset
|
345 # repository since read cannot unpack the revision. |
c5b3d3e30de7
changelog: refuse to add revisions with empty usernames
Martin Geisler <mg@lazybytes.net>
parents:
7807
diff
changeset
|
346 if not user: |
c5b3d3e30de7
changelog: refuse to add revisions with empty usernames
Martin Geisler <mg@lazybytes.net>
parents:
7807
diff
changeset
|
347 raise error.RevlogError(_("empty username")) |
7035
9d023ef7b467
forbid username with '\n' at the changelog level
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
6259
diff
changeset
|
348 if "\n" in user: |
7633 | 349 raise error.RevlogError(_("username %s contains a newline") |
350 % repr(user)) | |
8499
fb9b83df45f3
commit: move description trimming into changelog
Matt Mackall <mpm@selenic.com>
parents:
8443
diff
changeset
|
351 |
17810
2894d180afa1
changelog: extract description cleaning logic in a dedicated function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17677
diff
changeset
|
352 desc = stripdesc(desc) |
8499
fb9b83df45f3
commit: move description trimming into changelog
Matt Mackall <mpm@selenic.com>
parents:
8443
diff
changeset
|
353 |
1195
f92af8d53330
Validate user input of dates when adding a changelog entry.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1095
diff
changeset
|
354 if date: |
2523
4ab59a3acd16
validate the resulting date in parsedate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2522
diff
changeset
|
355 parseddate = "%d %d" % util.parsedate(date) |
1195
f92af8d53330
Validate user input of dates when adding a changelog entry.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1095
diff
changeset
|
356 else: |
2522
85f796baab10
Allow the use of human readable dates (issue 251)
Jose M. Prieto <jmprieto@gmx.net>
parents:
2142
diff
changeset
|
357 parseddate = "%d %d" % util.makedate() |
10417
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
358 if extra: |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
359 branch = extra.get("branch") |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
360 if branch in ("default", ""): |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
361 del extra["branch"] |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
362 elif branch in (".", "null", "tip"): |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
363 raise error.RevlogError(_('the name \'%s\' is reserved') |
58e040c51231
branch: avoid using reserved tag names
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
10263
diff
changeset
|
364 % branch) |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
365 if extra: |
8443
53ff4a5af284
changelog: turn {de,en}code_extra methods into functions
Martin Geisler <mg@lazybytes.net>
parents:
8442
diff
changeset
|
366 extra = encodeextra(extra) |
3233
2f35961854fb
[extendedchangelog] add extra metadata in the changelog entry
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3232
diff
changeset
|
367 parseddate = "%s %s" % (parseddate, extra) |
8209
a1a5a57efe90
replace util.sort with sorted built-in
Matt Mackall <mpm@selenic.com>
parents:
7948
diff
changeset
|
368 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
369 text = "\n".join(l) |
6750
fb42030d79d6
add __len__ and __iter__ methods to repo and revlog
Matt Mackall <mpm@selenic.com>
parents:
6259
diff
changeset
|
370 return self.addrevision(text, transaction, len(self), p1, p2) |
18306
06185554e7e3
changelog: add a `branch` method, bypassing changectx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18231
diff
changeset
|
371 |
20185
7d4219512823
branchmap: cache open/closed branch head information
Brodie Rao <brodie@sf.io>
parents:
19899
diff
changeset
|
372 def branchinfo(self, rev): |
7d4219512823
branchmap: cache open/closed branch head information
Brodie Rao <brodie@sf.io>
parents:
19899
diff
changeset
|
373 """return the branch name and open/close state of a revision |
18306
06185554e7e3
changelog: add a `branch` method, bypassing changectx
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18231
diff
changeset
|
374 |
18308
4e27b06a0fd9
changelog: please check-code and remove tabs
Mads Kiilerich <mads@kiilerich.com>
parents:
18306
diff
changeset
|
375 This function exists because creating a changectx object |
4e27b06a0fd9
changelog: please check-code and remove tabs
Mads Kiilerich <mads@kiilerich.com>
parents:
18306
diff
changeset
|
376 just to access this is costly.""" |
20185
7d4219512823
branchmap: cache open/closed branch head information
Brodie Rao <brodie@sf.io>
parents:
19899
diff
changeset
|
377 extra = self.read(rev)[5] |
7d4219512823
branchmap: cache open/closed branch head information
Brodie Rao <brodie@sf.io>
parents:
19899
diff
changeset
|
378 return encoding.tolocal(extra.get("branch")), 'close' in extra |