Show More
@@ -0,0 +1,105 | |||
|
1 | ||
|
2 | $ cat >> $HGRCPATH << EOF | |
|
3 | > [experimental] | |
|
4 | > copies.write-to=changeset-only | |
|
5 | > [alias] | |
|
6 | > changesetcopies = log -r . -T 'files: {files} | |
|
7 | > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' | |
|
8 | > EOF | |
|
9 | ||
|
10 | Check that copies are recorded correctly | |
|
11 | ||
|
12 | $ hg init repo | |
|
13 | $ cd repo | |
|
14 | $ echo a > a | |
|
15 | $ hg add a | |
|
16 | $ hg ci -m initial | |
|
17 | $ hg cp a b | |
|
18 | $ hg cp a c | |
|
19 | $ hg cp a d | |
|
20 | $ hg ci -m 'copy a to b, c, and d' | |
|
21 | $ hg changesetcopies | |
|
22 | files: b c d | |
|
23 | p1copies: b\x00a (esc) | |
|
24 | c\x00a (esc) | |
|
25 | d\x00a (esc) | |
|
26 | ||
|
27 | Check that renames are recorded correctly | |
|
28 | ||
|
29 | $ hg mv b b2 | |
|
30 | $ hg ci -m 'rename b to b2' | |
|
31 | $ hg changesetcopies | |
|
32 | files: b b2 | |
|
33 | p1copies: b2\x00b (esc) | |
|
34 | ||
|
35 | Rename onto existing file. This should get recorded in the changeset files list and in the extras, | |
|
36 | even though there is no filelog entry. | |
|
37 | ||
|
38 | $ hg cp b2 c --force | |
|
39 | $ hg st --copies | |
|
40 | M c | |
|
41 | b2 | |
|
42 | $ hg debugindex c | |
|
43 | rev linkrev nodeid p1 p2 | |
|
44 | 0 1 b789fdd96dc2 000000000000 000000000000 | |
|
45 | $ hg ci -m 'move b onto d' | |
|
46 | $ hg changesetcopies | |
|
47 | files: c | |
|
48 | p1copies: c\x00b2 (esc) | |
|
49 | $ hg debugindex c | |
|
50 | rev linkrev nodeid p1 p2 | |
|
51 | 0 1 b789fdd96dc2 000000000000 000000000000 | |
|
52 | ||
|
53 | Create a merge commit with copying done during merge. | |
|
54 | ||
|
55 | $ hg co 0 | |
|
56 | 0 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
|
57 | $ hg cp a e | |
|
58 | $ hg cp a f | |
|
59 | $ hg ci -m 'copy a to e and f' | |
|
60 | created new head | |
|
61 | $ hg merge 3 | |
|
62 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
63 | (branch merge, don't forget to commit) | |
|
64 | File 'a' exists on both sides, so 'g' could be recorded as being from p1 or p2, but we currently | |
|
65 | always record it as being from p1 | |
|
66 | $ hg cp a g | |
|
67 | File 'd' exists only in p2, so 'h' should be from p2 | |
|
68 | $ hg cp d h | |
|
69 | File 'f' exists only in p1, so 'i' should be from p1 | |
|
70 | $ hg cp f i | |
|
71 | $ hg ci -m 'merge' | |
|
72 | $ hg changesetcopies | |
|
73 | files: g h i | |
|
74 | p1copies: g\x00a (esc) | |
|
75 | i\x00f (esc) | |
|
76 | p2copies: h\x00d (esc) | |
|
77 | ||
|
78 | Test writing to both changeset and filelog | |
|
79 | ||
|
80 | $ hg cp a j | |
|
81 | $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility | |
|
82 | $ hg changesetcopies | |
|
83 | files: j | |
|
84 | p1copies: j\x00a (esc) | |
|
85 | $ hg debugdata j 0 | |
|
86 | \x01 (esc) | |
|
87 | copy: a | |
|
88 | copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 | |
|
89 | \x01 (esc) | |
|
90 | a | |
|
91 | ||
|
92 | Test writing only to filelog | |
|
93 | ||
|
94 | $ hg cp a k | |
|
95 | $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only | |
|
96 | $ hg changesetcopies | |
|
97 | files: k | |
|
98 | $ hg debugdata k 0 | |
|
99 | \x01 (esc) | |
|
100 | copy: a | |
|
101 | copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 | |
|
102 | \x01 (esc) | |
|
103 | a | |
|
104 | ||
|
105 | $ cd .. |
@@ -1,585 +1,599 | |||
|
1 | 1 | # changelog.py - changelog class for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | from .i18n import _ |
|
11 | 11 | from .node import ( |
|
12 | 12 | bin, |
|
13 | 13 | hex, |
|
14 | 14 | nullid, |
|
15 | 15 | ) |
|
16 | 16 | from .thirdparty import ( |
|
17 | 17 | attr, |
|
18 | 18 | ) |
|
19 | 19 | |
|
20 | 20 | from . import ( |
|
21 | 21 | encoding, |
|
22 | 22 | error, |
|
23 | 23 | pycompat, |
|
24 | 24 | revlog, |
|
25 | 25 | util, |
|
26 | 26 | ) |
|
27 | 27 | from .utils import ( |
|
28 | 28 | dateutil, |
|
29 | 29 | stringutil, |
|
30 | 30 | ) |
|
31 | 31 | |
|
32 | 32 | _defaultextra = {'branch': 'default'} |
|
33 | 33 | |
|
34 | 34 | def _string_escape(text): |
|
35 | 35 | """ |
|
36 | 36 | >>> from .pycompat import bytechr as chr |
|
37 | 37 | >>> d = {b'nl': chr(10), b'bs': chr(92), b'cr': chr(13), b'nul': chr(0)} |
|
38 | 38 | >>> s = b"ab%(nl)scd%(bs)s%(bs)sn%(nul)s12ab%(cr)scd%(bs)s%(nl)s" % d |
|
39 | 39 | >>> s |
|
40 | 40 | 'ab\\ncd\\\\\\\\n\\x0012ab\\rcd\\\\\\n' |
|
41 | 41 | >>> res = _string_escape(s) |
|
42 | 42 | >>> s == _string_unescape(res) |
|
43 | 43 | True |
|
44 | 44 | """ |
|
45 | 45 | # subset of the string_escape codec |
|
46 | 46 | text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') |
|
47 | 47 | return text.replace('\0', '\\0') |
|
48 | 48 | |
|
49 | 49 | def _string_unescape(text): |
|
50 | 50 | if '\\0' in text: |
|
51 | 51 | # fix up \0 without getting into trouble with \\0 |
|
52 | 52 | text = text.replace('\\\\', '\\\\\n') |
|
53 | 53 | text = text.replace('\\0', '\0') |
|
54 | 54 | text = text.replace('\n', '') |
|
55 | 55 | return stringutil.unescapestr(text) |
|
56 | 56 | |
|
57 | 57 | def decodeextra(text): |
|
58 | 58 | """ |
|
59 | 59 | >>> from .pycompat import bytechr as chr |
|
60 | 60 | >>> sorted(decodeextra(encodeextra({b'foo': b'bar', b'baz': chr(0) + b'2'}) |
|
61 | 61 | ... ).items()) |
|
62 | 62 | [('baz', '\\x002'), ('branch', 'default'), ('foo', 'bar')] |
|
63 | 63 | >>> sorted(decodeextra(encodeextra({b'foo': b'bar', |
|
64 | 64 | ... b'baz': chr(92) + chr(0) + b'2'}) |
|
65 | 65 | ... ).items()) |
|
66 | 66 | [('baz', '\\\\\\x002'), ('branch', 'default'), ('foo', 'bar')] |
|
67 | 67 | """ |
|
68 | 68 | extra = _defaultextra.copy() |
|
69 | 69 | for l in text.split('\0'): |
|
70 | 70 | if l: |
|
71 | 71 | k, v = _string_unescape(l).split(':', 1) |
|
72 | 72 | extra[k] = v |
|
73 | 73 | return extra |
|
74 | 74 | |
|
75 | 75 | def encodeextra(d): |
|
76 | 76 | # keys must be sorted to produce a deterministic changelog entry |
|
77 | 77 | items = [ |
|
78 | 78 | _string_escape('%s:%s' % (k, pycompat.bytestr(d[k]))) |
|
79 | 79 | for k in sorted(d) |
|
80 | 80 | ] |
|
81 | 81 | return "\0".join(items) |
|
82 | 82 | |
|
83 | def encodecopies(copies): | |
|
84 | items = [ | |
|
85 | '%s\0%s' % (k, copies[k]) | |
|
86 | for k in sorted(copies) | |
|
87 | ] | |
|
88 | return "\n".join(items) | |
|
89 | ||
|
83 | 90 | def stripdesc(desc): |
|
84 | 91 | """strip trailing whitespace and leading and trailing empty lines""" |
|
85 | 92 | return '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n') |
|
86 | 93 | |
|
87 | 94 | class appender(object): |
|
88 | 95 | '''the changelog index must be updated last on disk, so we use this class |
|
89 | 96 | to delay writes to it''' |
|
90 | 97 | def __init__(self, vfs, name, mode, buf): |
|
91 | 98 | self.data = buf |
|
92 | 99 | fp = vfs(name, mode) |
|
93 | 100 | self.fp = fp |
|
94 | 101 | self.offset = fp.tell() |
|
95 | 102 | self.size = vfs.fstat(fp).st_size |
|
96 | 103 | self._end = self.size |
|
97 | 104 | |
|
98 | 105 | def end(self): |
|
99 | 106 | return self._end |
|
100 | 107 | def tell(self): |
|
101 | 108 | return self.offset |
|
102 | 109 | def flush(self): |
|
103 | 110 | pass |
|
104 | 111 | |
|
105 | 112 | @property |
|
106 | 113 | def closed(self): |
|
107 | 114 | return self.fp.closed |
|
108 | 115 | |
|
109 | 116 | def close(self): |
|
110 | 117 | self.fp.close() |
|
111 | 118 | |
|
112 | 119 | def seek(self, offset, whence=0): |
|
113 | 120 | '''virtual file offset spans real file and data''' |
|
114 | 121 | if whence == 0: |
|
115 | 122 | self.offset = offset |
|
116 | 123 | elif whence == 1: |
|
117 | 124 | self.offset += offset |
|
118 | 125 | elif whence == 2: |
|
119 | 126 | self.offset = self.end() + offset |
|
120 | 127 | if self.offset < self.size: |
|
121 | 128 | self.fp.seek(self.offset) |
|
122 | 129 | |
|
123 | 130 | def read(self, count=-1): |
|
124 | 131 | '''only trick here is reads that span real file and data''' |
|
125 | 132 | ret = "" |
|
126 | 133 | if self.offset < self.size: |
|
127 | 134 | s = self.fp.read(count) |
|
128 | 135 | ret = s |
|
129 | 136 | self.offset += len(s) |
|
130 | 137 | if count > 0: |
|
131 | 138 | count -= len(s) |
|
132 | 139 | if count != 0: |
|
133 | 140 | doff = self.offset - self.size |
|
134 | 141 | self.data.insert(0, "".join(self.data)) |
|
135 | 142 | del self.data[1:] |
|
136 | 143 | s = self.data[0][doff:doff + count] |
|
137 | 144 | self.offset += len(s) |
|
138 | 145 | ret += s |
|
139 | 146 | return ret |
|
140 | 147 | |
|
141 | 148 | def write(self, s): |
|
142 | 149 | self.data.append(bytes(s)) |
|
143 | 150 | self.offset += len(s) |
|
144 | 151 | self._end += len(s) |
|
145 | 152 | |
|
146 | 153 | def __enter__(self): |
|
147 | 154 | self.fp.__enter__() |
|
148 | 155 | return self |
|
149 | 156 | |
|
150 | 157 | def __exit__(self, *args): |
|
151 | 158 | return self.fp.__exit__(*args) |
|
152 | 159 | |
|
153 | 160 | def _divertopener(opener, target): |
|
154 | 161 | """build an opener that writes in 'target.a' instead of 'target'""" |
|
155 | 162 | def _divert(name, mode='r', checkambig=False): |
|
156 | 163 | if name != target: |
|
157 | 164 | return opener(name, mode) |
|
158 | 165 | return opener(name + ".a", mode) |
|
159 | 166 | return _divert |
|
160 | 167 | |
|
161 | 168 | def _delayopener(opener, target, buf): |
|
162 | 169 | """build an opener that stores chunks in 'buf' instead of 'target'""" |
|
163 | 170 | def _delay(name, mode='r', checkambig=False): |
|
164 | 171 | if name != target: |
|
165 | 172 | return opener(name, mode) |
|
166 | 173 | return appender(opener, name, mode, buf) |
|
167 | 174 | return _delay |
|
168 | 175 | |
|
169 | 176 | @attr.s |
|
170 | 177 | class _changelogrevision(object): |
|
171 | 178 | # Extensions might modify _defaultextra, so let the constructor below pass |
|
172 | 179 | # it in |
|
173 | 180 | extra = attr.ib() |
|
174 | 181 | manifest = attr.ib(default=nullid) |
|
175 | 182 | user = attr.ib(default='') |
|
176 | 183 | date = attr.ib(default=(0, 0)) |
|
177 | 184 | files = attr.ib(default=attr.Factory(list)) |
|
178 | 185 | description = attr.ib(default='') |
|
179 | 186 | |
|
180 | 187 | class changelogrevision(object): |
|
181 | 188 | """Holds results of a parsed changelog revision. |
|
182 | 189 | |
|
183 | 190 | Changelog revisions consist of multiple pieces of data, including |
|
184 | 191 | the manifest node, user, and date. This object exposes a view into |
|
185 | 192 | the parsed object. |
|
186 | 193 | """ |
|
187 | 194 | |
|
188 | 195 | __slots__ = ( |
|
189 | 196 | r'_offsets', |
|
190 | 197 | r'_text', |
|
191 | 198 | ) |
|
192 | 199 | |
|
193 | 200 | def __new__(cls, text): |
|
194 | 201 | if not text: |
|
195 | 202 | return _changelogrevision(extra=_defaultextra) |
|
196 | 203 | |
|
197 | 204 | self = super(changelogrevision, cls).__new__(cls) |
|
198 | 205 | # We could return here and implement the following as an __init__. |
|
199 | 206 | # But doing it here is equivalent and saves an extra function call. |
|
200 | 207 | |
|
201 | 208 | # format used: |
|
202 | 209 | # nodeid\n : manifest node in ascii |
|
203 | 210 | # user\n : user, no \n or \r allowed |
|
204 | 211 | # time tz extra\n : date (time is int or float, timezone is int) |
|
205 | 212 | # : extra is metadata, encoded and separated by '\0' |
|
206 | 213 | # : older versions ignore it |
|
207 | 214 | # files\n\n : files modified by the cset, no \n or \r allowed |
|
208 | 215 | # (.*) : comment (free text, ideally utf-8) |
|
209 | 216 | # |
|
210 | 217 | # changelog v0 doesn't use extra |
|
211 | 218 | |
|
212 | 219 | nl1 = text.index('\n') |
|
213 | 220 | nl2 = text.index('\n', nl1 + 1) |
|
214 | 221 | nl3 = text.index('\n', nl2 + 1) |
|
215 | 222 | |
|
216 | 223 | # The list of files may be empty. Which means nl3 is the first of the |
|
217 | 224 | # double newline that precedes the description. |
|
218 | 225 | if text[nl3 + 1:nl3 + 2] == '\n': |
|
219 | 226 | doublenl = nl3 |
|
220 | 227 | else: |
|
221 | 228 | doublenl = text.index('\n\n', nl3 + 1) |
|
222 | 229 | |
|
223 | 230 | self._offsets = (nl1, nl2, nl3, doublenl) |
|
224 | 231 | self._text = text |
|
225 | 232 | |
|
226 | 233 | return self |
|
227 | 234 | |
|
228 | 235 | @property |
|
229 | 236 | def manifest(self): |
|
230 | 237 | return bin(self._text[0:self._offsets[0]]) |
|
231 | 238 | |
|
232 | 239 | @property |
|
233 | 240 | def user(self): |
|
234 | 241 | off = self._offsets |
|
235 | 242 | return encoding.tolocal(self._text[off[0] + 1:off[1]]) |
|
236 | 243 | |
|
237 | 244 | @property |
|
238 | 245 | def _rawdate(self): |
|
239 | 246 | off = self._offsets |
|
240 | 247 | dateextra = self._text[off[1] + 1:off[2]] |
|
241 | 248 | return dateextra.split(' ', 2)[0:2] |
|
242 | 249 | |
|
243 | 250 | @property |
|
244 | 251 | def _rawextra(self): |
|
245 | 252 | off = self._offsets |
|
246 | 253 | dateextra = self._text[off[1] + 1:off[2]] |
|
247 | 254 | fields = dateextra.split(' ', 2) |
|
248 | 255 | if len(fields) != 3: |
|
249 | 256 | return None |
|
250 | 257 | |
|
251 | 258 | return fields[2] |
|
252 | 259 | |
|
253 | 260 | @property |
|
254 | 261 | def date(self): |
|
255 | 262 | raw = self._rawdate |
|
256 | 263 | time = float(raw[0]) |
|
257 | 264 | # Various tools did silly things with the timezone. |
|
258 | 265 | try: |
|
259 | 266 | timezone = int(raw[1]) |
|
260 | 267 | except ValueError: |
|
261 | 268 | timezone = 0 |
|
262 | 269 | |
|
263 | 270 | return time, timezone |
|
264 | 271 | |
|
265 | 272 | @property |
|
266 | 273 | def extra(self): |
|
267 | 274 | raw = self._rawextra |
|
268 | 275 | if raw is None: |
|
269 | 276 | return _defaultextra |
|
270 | 277 | |
|
271 | 278 | return decodeextra(raw) |
|
272 | 279 | |
|
273 | 280 | @property |
|
274 | 281 | def files(self): |
|
275 | 282 | off = self._offsets |
|
276 | 283 | if off[2] == off[3]: |
|
277 | 284 | return [] |
|
278 | 285 | |
|
279 | 286 | return self._text[off[2] + 1:off[3]].split('\n') |
|
280 | 287 | |
|
281 | 288 | @property |
|
282 | 289 | def description(self): |
|
283 | 290 | return encoding.tolocal(self._text[self._offsets[3] + 2:]) |
|
284 | 291 | |
|
285 | 292 | class changelog(revlog.revlog): |
|
286 | 293 | def __init__(self, opener, trypending=False): |
|
287 | 294 | """Load a changelog revlog using an opener. |
|
288 | 295 | |
|
289 | 296 | If ``trypending`` is true, we attempt to load the index from a |
|
290 | 297 | ``00changelog.i.a`` file instead of the default ``00changelog.i``. |
|
291 | 298 | The ``00changelog.i.a`` file contains index (and possibly inline |
|
292 | 299 | revision) data for a transaction that hasn't been finalized yet. |
|
293 | 300 | It exists in a separate file to facilitate readers (such as |
|
294 | 301 | hooks processes) accessing data before a transaction is finalized. |
|
295 | 302 | """ |
|
296 | 303 | if trypending and opener.exists('00changelog.i.a'): |
|
297 | 304 | indexfile = '00changelog.i.a' |
|
298 | 305 | else: |
|
299 | 306 | indexfile = '00changelog.i' |
|
300 | 307 | |
|
301 | 308 | datafile = '00changelog.d' |
|
302 | 309 | revlog.revlog.__init__(self, opener, indexfile, datafile=datafile, |
|
303 | 310 | checkambig=True, mmaplargeindex=True) |
|
304 | 311 | |
|
305 | 312 | if self._initempty and (self.version & 0xFFFF == revlog.REVLOGV1): |
|
306 | 313 | # changelogs don't benefit from generaldelta. |
|
307 | 314 | |
|
308 | 315 | self.version &= ~revlog.FLAG_GENERALDELTA |
|
309 | 316 | self._generaldelta = False |
|
310 | 317 | |
|
311 | 318 | # Delta chains for changelogs tend to be very small because entries |
|
312 | 319 | # tend to be small and don't delta well with each. So disable delta |
|
313 | 320 | # chains. |
|
314 | 321 | self._storedeltachains = False |
|
315 | 322 | |
|
316 | 323 | self._realopener = opener |
|
317 | 324 | self._delayed = False |
|
318 | 325 | self._delaybuf = None |
|
319 | 326 | self._divert = False |
|
320 | 327 | self.filteredrevs = frozenset() |
|
321 | 328 | |
|
322 | 329 | def tiprev(self): |
|
323 | 330 | for i in pycompat.xrange(len(self) -1, -2, -1): |
|
324 | 331 | if i not in self.filteredrevs: |
|
325 | 332 | return i |
|
326 | 333 | |
|
327 | 334 | def tip(self): |
|
328 | 335 | """filtered version of revlog.tip""" |
|
329 | 336 | return self.node(self.tiprev()) |
|
330 | 337 | |
|
331 | 338 | def __contains__(self, rev): |
|
332 | 339 | """filtered version of revlog.__contains__""" |
|
333 | 340 | return (0 <= rev < len(self) |
|
334 | 341 | and rev not in self.filteredrevs) |
|
335 | 342 | |
|
336 | 343 | def __iter__(self): |
|
337 | 344 | """filtered version of revlog.__iter__""" |
|
338 | 345 | if len(self.filteredrevs) == 0: |
|
339 | 346 | return revlog.revlog.__iter__(self) |
|
340 | 347 | |
|
341 | 348 | def filterediter(): |
|
342 | 349 | for i in pycompat.xrange(len(self)): |
|
343 | 350 | if i not in self.filteredrevs: |
|
344 | 351 | yield i |
|
345 | 352 | |
|
346 | 353 | return filterediter() |
|
347 | 354 | |
|
348 | 355 | def revs(self, start=0, stop=None): |
|
349 | 356 | """filtered version of revlog.revs""" |
|
350 | 357 | for i in super(changelog, self).revs(start, stop): |
|
351 | 358 | if i not in self.filteredrevs: |
|
352 | 359 | yield i |
|
353 | 360 | |
|
354 | 361 | def reachableroots(self, minroot, heads, roots, includepath=False): |
|
355 | 362 | return self.index.reachableroots2(minroot, heads, roots, includepath) |
|
356 | 363 | |
|
357 | 364 | def _checknofilteredinrevs(self, revs): |
|
358 | 365 | """raise the appropriate error if 'revs' contains a filtered revision |
|
359 | 366 | |
|
360 | 367 | This returns a version of 'revs' to be used thereafter by the caller. |
|
361 | 368 | In particular, if revs is an iterator, it is converted into a set. |
|
362 | 369 | """ |
|
363 | 370 | safehasattr = util.safehasattr |
|
364 | 371 | if safehasattr(revs, '__next__'): |
|
365 | 372 | # Note that inspect.isgenerator() is not true for iterators, |
|
366 | 373 | revs = set(revs) |
|
367 | 374 | |
|
368 | 375 | filteredrevs = self.filteredrevs |
|
369 | 376 | if safehasattr(revs, 'first'): # smartset |
|
370 | 377 | offenders = revs & filteredrevs |
|
371 | 378 | else: |
|
372 | 379 | offenders = filteredrevs.intersection(revs) |
|
373 | 380 | |
|
374 | 381 | for rev in offenders: |
|
375 | 382 | raise error.FilteredIndexError(rev) |
|
376 | 383 | return revs |
|
377 | 384 | |
|
378 | 385 | def headrevs(self, revs=None): |
|
379 | 386 | if revs is None and self.filteredrevs: |
|
380 | 387 | try: |
|
381 | 388 | return self.index.headrevsfiltered(self.filteredrevs) |
|
382 | 389 | # AttributeError covers non-c-extension environments and |
|
383 | 390 | # old c extensions without filter handling. |
|
384 | 391 | except AttributeError: |
|
385 | 392 | return self._headrevs() |
|
386 | 393 | |
|
387 | 394 | if self.filteredrevs: |
|
388 | 395 | revs = self._checknofilteredinrevs(revs) |
|
389 | 396 | return super(changelog, self).headrevs(revs) |
|
390 | 397 | |
|
391 | 398 | def strip(self, *args, **kwargs): |
|
392 | 399 | # XXX make something better than assert |
|
393 | 400 | # We can't expect proper strip behavior if we are filtered. |
|
394 | 401 | assert not self.filteredrevs |
|
395 | 402 | super(changelog, self).strip(*args, **kwargs) |
|
396 | 403 | |
|
397 | 404 | def rev(self, node): |
|
398 | 405 | """filtered version of revlog.rev""" |
|
399 | 406 | r = super(changelog, self).rev(node) |
|
400 | 407 | if r in self.filteredrevs: |
|
401 | 408 | raise error.FilteredLookupError(hex(node), self.indexfile, |
|
402 | 409 | _('filtered node')) |
|
403 | 410 | return r |
|
404 | 411 | |
|
405 | 412 | def node(self, rev): |
|
406 | 413 | """filtered version of revlog.node""" |
|
407 | 414 | if rev in self.filteredrevs: |
|
408 | 415 | raise error.FilteredIndexError(rev) |
|
409 | 416 | return super(changelog, self).node(rev) |
|
410 | 417 | |
|
411 | 418 | def linkrev(self, rev): |
|
412 | 419 | """filtered version of revlog.linkrev""" |
|
413 | 420 | if rev in self.filteredrevs: |
|
414 | 421 | raise error.FilteredIndexError(rev) |
|
415 | 422 | return super(changelog, self).linkrev(rev) |
|
416 | 423 | |
|
417 | 424 | def parentrevs(self, rev): |
|
418 | 425 | """filtered version of revlog.parentrevs""" |
|
419 | 426 | if rev in self.filteredrevs: |
|
420 | 427 | raise error.FilteredIndexError(rev) |
|
421 | 428 | return super(changelog, self).parentrevs(rev) |
|
422 | 429 | |
|
423 | 430 | def flags(self, rev): |
|
424 | 431 | """filtered version of revlog.flags""" |
|
425 | 432 | if rev in self.filteredrevs: |
|
426 | 433 | raise error.FilteredIndexError(rev) |
|
427 | 434 | return super(changelog, self).flags(rev) |
|
428 | 435 | |
|
429 | 436 | def delayupdate(self, tr): |
|
430 | 437 | "delay visibility of index updates to other readers" |
|
431 | 438 | |
|
432 | 439 | if not self._delayed: |
|
433 | 440 | if len(self) == 0: |
|
434 | 441 | self._divert = True |
|
435 | 442 | if self._realopener.exists(self.indexfile + '.a'): |
|
436 | 443 | self._realopener.unlink(self.indexfile + '.a') |
|
437 | 444 | self.opener = _divertopener(self._realopener, self.indexfile) |
|
438 | 445 | else: |
|
439 | 446 | self._delaybuf = [] |
|
440 | 447 | self.opener = _delayopener(self._realopener, self.indexfile, |
|
441 | 448 | self._delaybuf) |
|
442 | 449 | self._delayed = True |
|
443 | 450 | tr.addpending('cl-%i' % id(self), self._writepending) |
|
444 | 451 | tr.addfinalize('cl-%i' % id(self), self._finalize) |
|
445 | 452 | |
|
446 | 453 | def _finalize(self, tr): |
|
447 | 454 | "finalize index updates" |
|
448 | 455 | self._delayed = False |
|
449 | 456 | self.opener = self._realopener |
|
450 | 457 | # move redirected index data back into place |
|
451 | 458 | if self._divert: |
|
452 | 459 | assert not self._delaybuf |
|
453 | 460 | tmpname = self.indexfile + ".a" |
|
454 | 461 | nfile = self.opener.open(tmpname) |
|
455 | 462 | nfile.close() |
|
456 | 463 | self.opener.rename(tmpname, self.indexfile, checkambig=True) |
|
457 | 464 | elif self._delaybuf: |
|
458 | 465 | fp = self.opener(self.indexfile, 'a', checkambig=True) |
|
459 | 466 | fp.write("".join(self._delaybuf)) |
|
460 | 467 | fp.close() |
|
461 | 468 | self._delaybuf = None |
|
462 | 469 | self._divert = False |
|
463 | 470 | # split when we're done |
|
464 | 471 | self._enforceinlinesize(tr) |
|
465 | 472 | |
|
466 | 473 | def _writepending(self, tr): |
|
467 | 474 | "create a file containing the unfinalized state for pretxnchangegroup" |
|
468 | 475 | if self._delaybuf: |
|
469 | 476 | # make a temporary copy of the index |
|
470 | 477 | fp1 = self._realopener(self.indexfile) |
|
471 | 478 | pendingfilename = self.indexfile + ".a" |
|
472 | 479 | # register as a temp file to ensure cleanup on failure |
|
473 | 480 | tr.registertmp(pendingfilename) |
|
474 | 481 | # write existing data |
|
475 | 482 | fp2 = self._realopener(pendingfilename, "w") |
|
476 | 483 | fp2.write(fp1.read()) |
|
477 | 484 | # add pending data |
|
478 | 485 | fp2.write("".join(self._delaybuf)) |
|
479 | 486 | fp2.close() |
|
480 | 487 | # switch modes so finalize can simply rename |
|
481 | 488 | self._delaybuf = None |
|
482 | 489 | self._divert = True |
|
483 | 490 | self.opener = _divertopener(self._realopener, self.indexfile) |
|
484 | 491 | |
|
485 | 492 | if self._divert: |
|
486 | 493 | return True |
|
487 | 494 | |
|
488 | 495 | return False |
|
489 | 496 | |
|
490 | 497 | def _enforceinlinesize(self, tr, fp=None): |
|
491 | 498 | if not self._delayed: |
|
492 | 499 | revlog.revlog._enforceinlinesize(self, tr, fp) |
|
493 | 500 | |
|
494 | 501 | def read(self, node): |
|
495 | 502 | """Obtain data from a parsed changelog revision. |
|
496 | 503 | |
|
497 | 504 | Returns a 6-tuple of: |
|
498 | 505 | |
|
499 | 506 | - manifest node in binary |
|
500 | 507 | - author/user as a localstr |
|
501 | 508 | - date as a 2-tuple of (time, timezone) |
|
502 | 509 | - list of files |
|
503 | 510 | - commit message as a localstr |
|
504 | 511 | - dict of extra metadata |
|
505 | 512 | |
|
506 | 513 | Unless you need to access all fields, consider calling |
|
507 | 514 | ``changelogrevision`` instead, as it is faster for partial object |
|
508 | 515 | access. |
|
509 | 516 | """ |
|
510 | 517 | c = changelogrevision(self.revision(node)) |
|
511 | 518 | return ( |
|
512 | 519 | c.manifest, |
|
513 | 520 | c.user, |
|
514 | 521 | c.date, |
|
515 | 522 | c.files, |
|
516 | 523 | c.description, |
|
517 | 524 | c.extra |
|
518 | 525 | ) |
|
519 | 526 | |
|
520 | 527 | def changelogrevision(self, nodeorrev): |
|
521 | 528 | """Obtain a ``changelogrevision`` for a node or revision.""" |
|
522 | 529 | return changelogrevision(self.revision(nodeorrev)) |
|
523 | 530 | |
|
524 | 531 | def readfiles(self, node): |
|
525 | 532 | """ |
|
526 | 533 | short version of read that only returns the files modified by the cset |
|
527 | 534 | """ |
|
528 | 535 | text = self.revision(node) |
|
529 | 536 | if not text: |
|
530 | 537 | return [] |
|
531 | 538 | last = text.index("\n\n") |
|
532 | 539 | l = text[:last].split('\n') |
|
533 | 540 | return l[3:] |
|
534 | 541 | |
|
535 | 542 | def add(self, manifest, files, desc, transaction, p1, p2, |
|
536 | user, date=None, extra=None): | |
|
543 | user, date=None, extra=None, p1copies=None, p2copies=None): | |
|
537 | 544 | # Convert to UTF-8 encoded bytestrings as the very first |
|
538 | 545 | # thing: calling any method on a localstr object will turn it |
|
539 | 546 | # into a str object and the cached UTF-8 string is thus lost. |
|
540 | 547 | user, desc = encoding.fromlocal(user), encoding.fromlocal(desc) |
|
541 | 548 | |
|
542 | 549 | user = user.strip() |
|
543 | 550 | # An empty username or a username with a "\n" will make the |
|
544 | 551 | # revision text contain two "\n\n" sequences -> corrupt |
|
545 | 552 | # repository since read cannot unpack the revision. |
|
546 | 553 | if not user: |
|
547 | 554 | raise error.StorageError(_("empty username")) |
|
548 | 555 | if "\n" in user: |
|
549 | 556 | raise error.StorageError(_("username %r contains a newline") |
|
550 | 557 | % pycompat.bytestr(user)) |
|
551 | 558 | |
|
552 | 559 | desc = stripdesc(desc) |
|
553 | 560 | |
|
554 | 561 | if date: |
|
555 | 562 | parseddate = "%d %d" % dateutil.parsedate(date) |
|
556 | 563 | else: |
|
557 | 564 | parseddate = "%d %d" % dateutil.makedate() |
|
558 | 565 | if extra: |
|
559 | 566 | branch = extra.get("branch") |
|
560 | 567 | if branch in ("default", ""): |
|
561 | 568 | del extra["branch"] |
|
562 | 569 | elif branch in (".", "null", "tip"): |
|
563 | 570 | raise error.StorageError(_('the name \'%s\' is reserved') |
|
564 | 571 | % branch) |
|
572 | if (p1copies or p2copies) and extra is None: | |
|
573 | extra = {} | |
|
574 | if p1copies: | |
|
575 | extra['p1copies'] = encodecopies(p1copies) | |
|
576 | if p2copies: | |
|
577 | extra['p2copies'] = encodecopies(p2copies) | |
|
578 | ||
|
565 | 579 | if extra: |
|
566 | 580 | extra = encodeextra(extra) |
|
567 | 581 | parseddate = "%s %s" % (parseddate, extra) |
|
568 | 582 | l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc] |
|
569 | 583 | text = "\n".join(l) |
|
570 | 584 | return self.addrevision(text, transaction, len(self), p1, p2) |
|
571 | 585 | |
|
572 | 586 | def branchinfo(self, rev): |
|
573 | 587 | """return the branch name and open/close state of a revision |
|
574 | 588 | |
|
575 | 589 | This function exists because creating a changectx object |
|
576 | 590 | just to access this is costly.""" |
|
577 | 591 | extra = self.read(rev)[5] |
|
578 | 592 | return encoding.tolocal(extra.get("branch")), 'close' in extra |
|
579 | 593 | |
|
580 | 594 | def _nodeduplicatecallback(self, transaction, node): |
|
581 | 595 | # keep track of revisions that got "re-added", eg: unbunde of know rev. |
|
582 | 596 | # |
|
583 | 597 | # We track them in a list to preserve their order from the source bundle |
|
584 | 598 | duplicates = transaction.changes.setdefault('revduplicates', []) |
|
585 | 599 | duplicates.append(self.rev(node)) |
@@ -1,1474 +1,1477 | |||
|
1 | 1 | # configitems.py - centralized declaration of configuration option |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2017 Pierre-Yves David <pierre-yves.david@octobus.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import functools |
|
11 | 11 | import re |
|
12 | 12 | |
|
13 | 13 | from . import ( |
|
14 | 14 | encoding, |
|
15 | 15 | error, |
|
16 | 16 | ) |
|
17 | 17 | |
|
18 | 18 | def loadconfigtable(ui, extname, configtable): |
|
19 | 19 | """update config item known to the ui with the extension ones""" |
|
20 | 20 | for section, items in sorted(configtable.items()): |
|
21 | 21 | knownitems = ui._knownconfig.setdefault(section, itemregister()) |
|
22 | 22 | knownkeys = set(knownitems) |
|
23 | 23 | newkeys = set(items) |
|
24 | 24 | for key in sorted(knownkeys & newkeys): |
|
25 | 25 | msg = "extension '%s' overwrite config item '%s.%s'" |
|
26 | 26 | msg %= (extname, section, key) |
|
27 | 27 | ui.develwarn(msg, config='warn-config') |
|
28 | 28 | |
|
29 | 29 | knownitems.update(items) |
|
30 | 30 | |
|
31 | 31 | class configitem(object): |
|
32 | 32 | """represent a known config item |
|
33 | 33 | |
|
34 | 34 | :section: the official config section where to find this item, |
|
35 | 35 | :name: the official name within the section, |
|
36 | 36 | :default: default value for this item, |
|
37 | 37 | :alias: optional list of tuples as alternatives, |
|
38 | 38 | :generic: this is a generic definition, match name using regular expression. |
|
39 | 39 | """ |
|
40 | 40 | |
|
41 | 41 | def __init__(self, section, name, default=None, alias=(), |
|
42 | 42 | generic=False, priority=0): |
|
43 | 43 | self.section = section |
|
44 | 44 | self.name = name |
|
45 | 45 | self.default = default |
|
46 | 46 | self.alias = list(alias) |
|
47 | 47 | self.generic = generic |
|
48 | 48 | self.priority = priority |
|
49 | 49 | self._re = None |
|
50 | 50 | if generic: |
|
51 | 51 | self._re = re.compile(self.name) |
|
52 | 52 | |
|
53 | 53 | class itemregister(dict): |
|
54 | 54 | """A specialized dictionary that can handle wild-card selection""" |
|
55 | 55 | |
|
56 | 56 | def __init__(self): |
|
57 | 57 | super(itemregister, self).__init__() |
|
58 | 58 | self._generics = set() |
|
59 | 59 | |
|
60 | 60 | def update(self, other): |
|
61 | 61 | super(itemregister, self).update(other) |
|
62 | 62 | self._generics.update(other._generics) |
|
63 | 63 | |
|
64 | 64 | def __setitem__(self, key, item): |
|
65 | 65 | super(itemregister, self).__setitem__(key, item) |
|
66 | 66 | if item.generic: |
|
67 | 67 | self._generics.add(item) |
|
68 | 68 | |
|
69 | 69 | def get(self, key): |
|
70 | 70 | baseitem = super(itemregister, self).get(key) |
|
71 | 71 | if baseitem is not None and not baseitem.generic: |
|
72 | 72 | return baseitem |
|
73 | 73 | |
|
74 | 74 | # search for a matching generic item |
|
75 | 75 | generics = sorted(self._generics, key=(lambda x: (x.priority, x.name))) |
|
76 | 76 | for item in generics: |
|
77 | 77 | # we use 'match' instead of 'search' to make the matching simpler |
|
78 | 78 | # for people unfamiliar with regular expression. Having the match |
|
79 | 79 | # rooted to the start of the string will produce less surprising |
|
80 | 80 | # result for user writing simple regex for sub-attribute. |
|
81 | 81 | # |
|
82 | 82 | # For example using "color\..*" match produces an unsurprising |
|
83 | 83 | # result, while using search could suddenly match apparently |
|
84 | 84 | # unrelated configuration that happens to contains "color." |
|
85 | 85 | # anywhere. This is a tradeoff where we favor requiring ".*" on |
|
86 | 86 | # some match to avoid the need to prefix most pattern with "^". |
|
87 | 87 | # The "^" seems more error prone. |
|
88 | 88 | if item._re.match(key): |
|
89 | 89 | return item |
|
90 | 90 | |
|
91 | 91 | return None |
|
92 | 92 | |
|
93 | 93 | coreitems = {} |
|
94 | 94 | |
|
95 | 95 | def _register(configtable, *args, **kwargs): |
|
96 | 96 | item = configitem(*args, **kwargs) |
|
97 | 97 | section = configtable.setdefault(item.section, itemregister()) |
|
98 | 98 | if item.name in section: |
|
99 | 99 | msg = "duplicated config item registration for '%s.%s'" |
|
100 | 100 | raise error.ProgrammingError(msg % (item.section, item.name)) |
|
101 | 101 | section[item.name] = item |
|
102 | 102 | |
|
103 | 103 | # special value for case where the default is derived from other values |
|
104 | 104 | dynamicdefault = object() |
|
105 | 105 | |
|
106 | 106 | # Registering actual config items |
|
107 | 107 | |
|
108 | 108 | def getitemregister(configtable): |
|
109 | 109 | f = functools.partial(_register, configtable) |
|
110 | 110 | # export pseudo enum as configitem.* |
|
111 | 111 | f.dynamicdefault = dynamicdefault |
|
112 | 112 | return f |
|
113 | 113 | |
|
114 | 114 | coreconfigitem = getitemregister(coreitems) |
|
115 | 115 | |
|
116 | 116 | def _registerdiffopts(section, configprefix=''): |
|
117 | 117 | coreconfigitem(section, configprefix + 'nodates', |
|
118 | 118 | default=False, |
|
119 | 119 | ) |
|
120 | 120 | coreconfigitem(section, configprefix + 'showfunc', |
|
121 | 121 | default=False, |
|
122 | 122 | ) |
|
123 | 123 | coreconfigitem(section, configprefix + 'unified', |
|
124 | 124 | default=None, |
|
125 | 125 | ) |
|
126 | 126 | coreconfigitem(section, configprefix + 'git', |
|
127 | 127 | default=False, |
|
128 | 128 | ) |
|
129 | 129 | coreconfigitem(section, configprefix + 'ignorews', |
|
130 | 130 | default=False, |
|
131 | 131 | ) |
|
132 | 132 | coreconfigitem(section, configprefix + 'ignorewsamount', |
|
133 | 133 | default=False, |
|
134 | 134 | ) |
|
135 | 135 | coreconfigitem(section, configprefix + 'ignoreblanklines', |
|
136 | 136 | default=False, |
|
137 | 137 | ) |
|
138 | 138 | coreconfigitem(section, configprefix + 'ignorewseol', |
|
139 | 139 | default=False, |
|
140 | 140 | ) |
|
141 | 141 | coreconfigitem(section, configprefix + 'nobinary', |
|
142 | 142 | default=False, |
|
143 | 143 | ) |
|
144 | 144 | coreconfigitem(section, configprefix + 'noprefix', |
|
145 | 145 | default=False, |
|
146 | 146 | ) |
|
147 | 147 | coreconfigitem(section, configprefix + 'word-diff', |
|
148 | 148 | default=False, |
|
149 | 149 | ) |
|
150 | 150 | |
|
151 | 151 | coreconfigitem('alias', '.*', |
|
152 | 152 | default=dynamicdefault, |
|
153 | 153 | generic=True, |
|
154 | 154 | ) |
|
155 | 155 | coreconfigitem('auth', 'cookiefile', |
|
156 | 156 | default=None, |
|
157 | 157 | ) |
|
158 | 158 | _registerdiffopts(section='annotate') |
|
159 | 159 | # bookmarks.pushing: internal hack for discovery |
|
160 | 160 | coreconfigitem('bookmarks', 'pushing', |
|
161 | 161 | default=list, |
|
162 | 162 | ) |
|
163 | 163 | # bundle.mainreporoot: internal hack for bundlerepo |
|
164 | 164 | coreconfigitem('bundle', 'mainreporoot', |
|
165 | 165 | default='', |
|
166 | 166 | ) |
|
167 | 167 | coreconfigitem('censor', 'policy', |
|
168 | 168 | default='abort', |
|
169 | 169 | ) |
|
170 | 170 | coreconfigitem('chgserver', 'idletimeout', |
|
171 | 171 | default=3600, |
|
172 | 172 | ) |
|
173 | 173 | coreconfigitem('chgserver', 'skiphash', |
|
174 | 174 | default=False, |
|
175 | 175 | ) |
|
176 | 176 | coreconfigitem('cmdserver', 'log', |
|
177 | 177 | default=None, |
|
178 | 178 | ) |
|
179 | 179 | coreconfigitem('cmdserver', 'max-log-files', |
|
180 | 180 | default=7, |
|
181 | 181 | ) |
|
182 | 182 | coreconfigitem('cmdserver', 'max-log-size', |
|
183 | 183 | default='1 MB', |
|
184 | 184 | ) |
|
185 | 185 | coreconfigitem('cmdserver', 'max-repo-cache', |
|
186 | 186 | default=0, |
|
187 | 187 | ) |
|
188 | 188 | coreconfigitem('cmdserver', 'message-encodings', |
|
189 | 189 | default=list, |
|
190 | 190 | ) |
|
191 | 191 | coreconfigitem('cmdserver', 'track-log', |
|
192 | 192 | default=lambda: ['chgserver', 'cmdserver', 'repocache'], |
|
193 | 193 | ) |
|
194 | 194 | coreconfigitem('color', '.*', |
|
195 | 195 | default=None, |
|
196 | 196 | generic=True, |
|
197 | 197 | ) |
|
198 | 198 | coreconfigitem('color', 'mode', |
|
199 | 199 | default='auto', |
|
200 | 200 | ) |
|
201 | 201 | coreconfigitem('color', 'pagermode', |
|
202 | 202 | default=dynamicdefault, |
|
203 | 203 | ) |
|
204 | 204 | _registerdiffopts(section='commands', configprefix='commit.interactive.') |
|
205 | 205 | coreconfigitem('commands', 'grep.all-files', |
|
206 | 206 | default=False, |
|
207 | 207 | ) |
|
208 | 208 | coreconfigitem('commands', 'resolve.confirm', |
|
209 | 209 | default=False, |
|
210 | 210 | ) |
|
211 | 211 | coreconfigitem('commands', 'resolve.explicit-re-merge', |
|
212 | 212 | default=False, |
|
213 | 213 | ) |
|
214 | 214 | coreconfigitem('commands', 'resolve.mark-check', |
|
215 | 215 | default='none', |
|
216 | 216 | ) |
|
217 | 217 | _registerdiffopts(section='commands', configprefix='revert.interactive.') |
|
218 | 218 | coreconfigitem('commands', 'show.aliasprefix', |
|
219 | 219 | default=list, |
|
220 | 220 | ) |
|
221 | 221 | coreconfigitem('commands', 'status.relative', |
|
222 | 222 | default=False, |
|
223 | 223 | ) |
|
224 | 224 | coreconfigitem('commands', 'status.skipstates', |
|
225 | 225 | default=[], |
|
226 | 226 | ) |
|
227 | 227 | coreconfigitem('commands', 'status.terse', |
|
228 | 228 | default='', |
|
229 | 229 | ) |
|
230 | 230 | coreconfigitem('commands', 'status.verbose', |
|
231 | 231 | default=False, |
|
232 | 232 | ) |
|
233 | 233 | coreconfigitem('commands', 'update.check', |
|
234 | 234 | default=None, |
|
235 | 235 | ) |
|
236 | 236 | coreconfigitem('commands', 'update.requiredest', |
|
237 | 237 | default=False, |
|
238 | 238 | ) |
|
239 | 239 | coreconfigitem('committemplate', '.*', |
|
240 | 240 | default=None, |
|
241 | 241 | generic=True, |
|
242 | 242 | ) |
|
243 | 243 | coreconfigitem('convert', 'bzr.saverev', |
|
244 | 244 | default=True, |
|
245 | 245 | ) |
|
246 | 246 | coreconfigitem('convert', 'cvsps.cache', |
|
247 | 247 | default=True, |
|
248 | 248 | ) |
|
249 | 249 | coreconfigitem('convert', 'cvsps.fuzz', |
|
250 | 250 | default=60, |
|
251 | 251 | ) |
|
252 | 252 | coreconfigitem('convert', 'cvsps.logencoding', |
|
253 | 253 | default=None, |
|
254 | 254 | ) |
|
255 | 255 | coreconfigitem('convert', 'cvsps.mergefrom', |
|
256 | 256 | default=None, |
|
257 | 257 | ) |
|
258 | 258 | coreconfigitem('convert', 'cvsps.mergeto', |
|
259 | 259 | default=None, |
|
260 | 260 | ) |
|
261 | 261 | coreconfigitem('convert', 'git.committeractions', |
|
262 | 262 | default=lambda: ['messagedifferent'], |
|
263 | 263 | ) |
|
264 | 264 | coreconfigitem('convert', 'git.extrakeys', |
|
265 | 265 | default=list, |
|
266 | 266 | ) |
|
267 | 267 | coreconfigitem('convert', 'git.findcopiesharder', |
|
268 | 268 | default=False, |
|
269 | 269 | ) |
|
270 | 270 | coreconfigitem('convert', 'git.remoteprefix', |
|
271 | 271 | default='remote', |
|
272 | 272 | ) |
|
273 | 273 | coreconfigitem('convert', 'git.renamelimit', |
|
274 | 274 | default=400, |
|
275 | 275 | ) |
|
276 | 276 | coreconfigitem('convert', 'git.saverev', |
|
277 | 277 | default=True, |
|
278 | 278 | ) |
|
279 | 279 | coreconfigitem('convert', 'git.similarity', |
|
280 | 280 | default=50, |
|
281 | 281 | ) |
|
282 | 282 | coreconfigitem('convert', 'git.skipsubmodules', |
|
283 | 283 | default=False, |
|
284 | 284 | ) |
|
285 | 285 | coreconfigitem('convert', 'hg.clonebranches', |
|
286 | 286 | default=False, |
|
287 | 287 | ) |
|
288 | 288 | coreconfigitem('convert', 'hg.ignoreerrors', |
|
289 | 289 | default=False, |
|
290 | 290 | ) |
|
291 | 291 | coreconfigitem('convert', 'hg.revs', |
|
292 | 292 | default=None, |
|
293 | 293 | ) |
|
294 | 294 | coreconfigitem('convert', 'hg.saverev', |
|
295 | 295 | default=False, |
|
296 | 296 | ) |
|
297 | 297 | coreconfigitem('convert', 'hg.sourcename', |
|
298 | 298 | default=None, |
|
299 | 299 | ) |
|
300 | 300 | coreconfigitem('convert', 'hg.startrev', |
|
301 | 301 | default=None, |
|
302 | 302 | ) |
|
303 | 303 | coreconfigitem('convert', 'hg.tagsbranch', |
|
304 | 304 | default='default', |
|
305 | 305 | ) |
|
306 | 306 | coreconfigitem('convert', 'hg.usebranchnames', |
|
307 | 307 | default=True, |
|
308 | 308 | ) |
|
309 | 309 | coreconfigitem('convert', 'ignoreancestorcheck', |
|
310 | 310 | default=False, |
|
311 | 311 | ) |
|
312 | 312 | coreconfigitem('convert', 'localtimezone', |
|
313 | 313 | default=False, |
|
314 | 314 | ) |
|
315 | 315 | coreconfigitem('convert', 'p4.encoding', |
|
316 | 316 | default=dynamicdefault, |
|
317 | 317 | ) |
|
318 | 318 | coreconfigitem('convert', 'p4.startrev', |
|
319 | 319 | default=0, |
|
320 | 320 | ) |
|
321 | 321 | coreconfigitem('convert', 'skiptags', |
|
322 | 322 | default=False, |
|
323 | 323 | ) |
|
324 | 324 | coreconfigitem('convert', 'svn.debugsvnlog', |
|
325 | 325 | default=True, |
|
326 | 326 | ) |
|
327 | 327 | coreconfigitem('convert', 'svn.trunk', |
|
328 | 328 | default=None, |
|
329 | 329 | ) |
|
330 | 330 | coreconfigitem('convert', 'svn.tags', |
|
331 | 331 | default=None, |
|
332 | 332 | ) |
|
333 | 333 | coreconfigitem('convert', 'svn.branches', |
|
334 | 334 | default=None, |
|
335 | 335 | ) |
|
336 | 336 | coreconfigitem('convert', 'svn.startrev', |
|
337 | 337 | default=0, |
|
338 | 338 | ) |
|
339 | 339 | coreconfigitem('debug', 'dirstate.delaywrite', |
|
340 | 340 | default=0, |
|
341 | 341 | ) |
|
342 | 342 | coreconfigitem('defaults', '.*', |
|
343 | 343 | default=None, |
|
344 | 344 | generic=True, |
|
345 | 345 | ) |
|
346 | 346 | coreconfigitem('devel', 'all-warnings', |
|
347 | 347 | default=False, |
|
348 | 348 | ) |
|
349 | 349 | coreconfigitem('devel', 'bundle2.debug', |
|
350 | 350 | default=False, |
|
351 | 351 | ) |
|
352 | 352 | coreconfigitem('devel', 'bundle.delta', |
|
353 | 353 | default='', |
|
354 | 354 | ) |
|
355 | 355 | coreconfigitem('devel', 'cache-vfs', |
|
356 | 356 | default=None, |
|
357 | 357 | ) |
|
358 | 358 | coreconfigitem('devel', 'check-locks', |
|
359 | 359 | default=False, |
|
360 | 360 | ) |
|
361 | 361 | coreconfigitem('devel', 'check-relroot', |
|
362 | 362 | default=False, |
|
363 | 363 | ) |
|
364 | 364 | coreconfigitem('devel', 'default-date', |
|
365 | 365 | default=None, |
|
366 | 366 | ) |
|
367 | 367 | coreconfigitem('devel', 'deprec-warn', |
|
368 | 368 | default=False, |
|
369 | 369 | ) |
|
370 | 370 | coreconfigitem('devel', 'disableloaddefaultcerts', |
|
371 | 371 | default=False, |
|
372 | 372 | ) |
|
373 | 373 | coreconfigitem('devel', 'warn-empty-changegroup', |
|
374 | 374 | default=False, |
|
375 | 375 | ) |
|
376 | 376 | coreconfigitem('devel', 'legacy.exchange', |
|
377 | 377 | default=list, |
|
378 | 378 | ) |
|
379 | 379 | coreconfigitem('devel', 'servercafile', |
|
380 | 380 | default='', |
|
381 | 381 | ) |
|
382 | 382 | coreconfigitem('devel', 'serverexactprotocol', |
|
383 | 383 | default='', |
|
384 | 384 | ) |
|
385 | 385 | coreconfigitem('devel', 'serverrequirecert', |
|
386 | 386 | default=False, |
|
387 | 387 | ) |
|
388 | 388 | coreconfigitem('devel', 'strip-obsmarkers', |
|
389 | 389 | default=True, |
|
390 | 390 | ) |
|
391 | 391 | coreconfigitem('devel', 'warn-config', |
|
392 | 392 | default=None, |
|
393 | 393 | ) |
|
394 | 394 | coreconfigitem('devel', 'warn-config-default', |
|
395 | 395 | default=None, |
|
396 | 396 | ) |
|
397 | 397 | coreconfigitem('devel', 'user.obsmarker', |
|
398 | 398 | default=None, |
|
399 | 399 | ) |
|
400 | 400 | coreconfigitem('devel', 'warn-config-unknown', |
|
401 | 401 | default=None, |
|
402 | 402 | ) |
|
403 | 403 | coreconfigitem('devel', 'debug.copies', |
|
404 | 404 | default=False, |
|
405 | 405 | ) |
|
406 | 406 | coreconfigitem('devel', 'debug.extensions', |
|
407 | 407 | default=False, |
|
408 | 408 | ) |
|
409 | 409 | coreconfigitem('devel', 'debug.peer-request', |
|
410 | 410 | default=False, |
|
411 | 411 | ) |
|
412 | 412 | _registerdiffopts(section='diff') |
|
413 | 413 | coreconfigitem('email', 'bcc', |
|
414 | 414 | default=None, |
|
415 | 415 | ) |
|
416 | 416 | coreconfigitem('email', 'cc', |
|
417 | 417 | default=None, |
|
418 | 418 | ) |
|
419 | 419 | coreconfigitem('email', 'charsets', |
|
420 | 420 | default=list, |
|
421 | 421 | ) |
|
422 | 422 | coreconfigitem('email', 'from', |
|
423 | 423 | default=None, |
|
424 | 424 | ) |
|
425 | 425 | coreconfigitem('email', 'method', |
|
426 | 426 | default='smtp', |
|
427 | 427 | ) |
|
428 | 428 | coreconfigitem('email', 'reply-to', |
|
429 | 429 | default=None, |
|
430 | 430 | ) |
|
431 | 431 | coreconfigitem('email', 'to', |
|
432 | 432 | default=None, |
|
433 | 433 | ) |
|
434 | 434 | coreconfigitem('experimental', 'archivemetatemplate', |
|
435 | 435 | default=dynamicdefault, |
|
436 | 436 | ) |
|
437 | 437 | coreconfigitem('experimental', 'auto-publish', |
|
438 | 438 | default='publish', |
|
439 | 439 | ) |
|
440 | 440 | coreconfigitem('experimental', 'bundle-phases', |
|
441 | 441 | default=False, |
|
442 | 442 | ) |
|
443 | 443 | coreconfigitem('experimental', 'bundle2-advertise', |
|
444 | 444 | default=True, |
|
445 | 445 | ) |
|
446 | 446 | coreconfigitem('experimental', 'bundle2-output-capture', |
|
447 | 447 | default=False, |
|
448 | 448 | ) |
|
449 | 449 | coreconfigitem('experimental', 'bundle2.pushback', |
|
450 | 450 | default=False, |
|
451 | 451 | ) |
|
452 | 452 | coreconfigitem('experimental', 'bundle2lazylocking', |
|
453 | 453 | default=False, |
|
454 | 454 | ) |
|
455 | 455 | coreconfigitem('experimental', 'bundlecomplevel', |
|
456 | 456 | default=None, |
|
457 | 457 | ) |
|
458 | 458 | coreconfigitem('experimental', 'bundlecomplevel.bzip2', |
|
459 | 459 | default=None, |
|
460 | 460 | ) |
|
461 | 461 | coreconfigitem('experimental', 'bundlecomplevel.gzip', |
|
462 | 462 | default=None, |
|
463 | 463 | ) |
|
464 | 464 | coreconfigitem('experimental', 'bundlecomplevel.none', |
|
465 | 465 | default=None, |
|
466 | 466 | ) |
|
467 | 467 | coreconfigitem('experimental', 'bundlecomplevel.zstd', |
|
468 | 468 | default=None, |
|
469 | 469 | ) |
|
470 | 470 | coreconfigitem('experimental', 'changegroup3', |
|
471 | 471 | default=False, |
|
472 | 472 | ) |
|
473 | 473 | coreconfigitem('experimental', 'cleanup-as-archived', |
|
474 | 474 | default=False, |
|
475 | 475 | ) |
|
476 | 476 | coreconfigitem('experimental', 'clientcompressionengines', |
|
477 | 477 | default=list, |
|
478 | 478 | ) |
|
479 | 479 | coreconfigitem('experimental', 'copytrace', |
|
480 | 480 | default='on', |
|
481 | 481 | ) |
|
482 | 482 | coreconfigitem('experimental', 'copytrace.movecandidateslimit', |
|
483 | 483 | default=100, |
|
484 | 484 | ) |
|
485 | 485 | coreconfigitem('experimental', 'copytrace.sourcecommitlimit', |
|
486 | 486 | default=100, |
|
487 | 487 | ) |
|
488 | 488 | coreconfigitem('experimental', 'copies.read-from', |
|
489 | 489 | default="filelog-only", |
|
490 | 490 | ) |
|
491 | coreconfigitem('experimental', 'copies.write-to', | |
|
492 | default='filelog-only', | |
|
493 | ) | |
|
491 | 494 | coreconfigitem('experimental', 'crecordtest', |
|
492 | 495 | default=None, |
|
493 | 496 | ) |
|
494 | 497 | coreconfigitem('experimental', 'directaccess', |
|
495 | 498 | default=False, |
|
496 | 499 | ) |
|
497 | 500 | coreconfigitem('experimental', 'directaccess.revnums', |
|
498 | 501 | default=False, |
|
499 | 502 | ) |
|
500 | 503 | coreconfigitem('experimental', 'editortmpinhg', |
|
501 | 504 | default=False, |
|
502 | 505 | ) |
|
503 | 506 | coreconfigitem('experimental', 'evolution', |
|
504 | 507 | default=list, |
|
505 | 508 | ) |
|
506 | 509 | coreconfigitem('experimental', 'evolution.allowdivergence', |
|
507 | 510 | default=False, |
|
508 | 511 | alias=[('experimental', 'allowdivergence')] |
|
509 | 512 | ) |
|
510 | 513 | coreconfigitem('experimental', 'evolution.allowunstable', |
|
511 | 514 | default=None, |
|
512 | 515 | ) |
|
513 | 516 | coreconfigitem('experimental', 'evolution.createmarkers', |
|
514 | 517 | default=None, |
|
515 | 518 | ) |
|
516 | 519 | coreconfigitem('experimental', 'evolution.effect-flags', |
|
517 | 520 | default=True, |
|
518 | 521 | alias=[('experimental', 'effect-flags')] |
|
519 | 522 | ) |
|
520 | 523 | coreconfigitem('experimental', 'evolution.exchange', |
|
521 | 524 | default=None, |
|
522 | 525 | ) |
|
523 | 526 | coreconfigitem('experimental', 'evolution.bundle-obsmarker', |
|
524 | 527 | default=False, |
|
525 | 528 | ) |
|
526 | 529 | coreconfigitem('experimental', 'evolution.report-instabilities', |
|
527 | 530 | default=True, |
|
528 | 531 | ) |
|
529 | 532 | coreconfigitem('experimental', 'evolution.track-operation', |
|
530 | 533 | default=True, |
|
531 | 534 | ) |
|
532 | 535 | coreconfigitem('experimental', 'maxdeltachainspan', |
|
533 | 536 | default=-1, |
|
534 | 537 | ) |
|
535 | 538 | coreconfigitem('experimental', 'mergetempdirprefix', |
|
536 | 539 | default=None, |
|
537 | 540 | ) |
|
538 | 541 | coreconfigitem('experimental', 'mmapindexthreshold', |
|
539 | 542 | default=None, |
|
540 | 543 | ) |
|
541 | 544 | coreconfigitem('experimental', 'narrow', |
|
542 | 545 | default=False, |
|
543 | 546 | ) |
|
544 | 547 | coreconfigitem('experimental', 'nonnormalparanoidcheck', |
|
545 | 548 | default=False, |
|
546 | 549 | ) |
|
547 | 550 | coreconfigitem('experimental', 'exportableenviron', |
|
548 | 551 | default=list, |
|
549 | 552 | ) |
|
550 | 553 | coreconfigitem('experimental', 'extendedheader.index', |
|
551 | 554 | default=None, |
|
552 | 555 | ) |
|
553 | 556 | coreconfigitem('experimental', 'extendedheader.similarity', |
|
554 | 557 | default=False, |
|
555 | 558 | ) |
|
556 | 559 | coreconfigitem('experimental', 'graphshorten', |
|
557 | 560 | default=False, |
|
558 | 561 | ) |
|
559 | 562 | coreconfigitem('experimental', 'graphstyle.parent', |
|
560 | 563 | default=dynamicdefault, |
|
561 | 564 | ) |
|
562 | 565 | coreconfigitem('experimental', 'graphstyle.missing', |
|
563 | 566 | default=dynamicdefault, |
|
564 | 567 | ) |
|
565 | 568 | coreconfigitem('experimental', 'graphstyle.grandparent', |
|
566 | 569 | default=dynamicdefault, |
|
567 | 570 | ) |
|
568 | 571 | coreconfigitem('experimental', 'hook-track-tags', |
|
569 | 572 | default=False, |
|
570 | 573 | ) |
|
571 | 574 | coreconfigitem('experimental', 'httppeer.advertise-v2', |
|
572 | 575 | default=False, |
|
573 | 576 | ) |
|
574 | 577 | coreconfigitem('experimental', 'httppeer.v2-encoder-order', |
|
575 | 578 | default=None, |
|
576 | 579 | ) |
|
577 | 580 | coreconfigitem('experimental', 'httppostargs', |
|
578 | 581 | default=False, |
|
579 | 582 | ) |
|
580 | 583 | coreconfigitem('experimental', 'mergedriver', |
|
581 | 584 | default=None, |
|
582 | 585 | ) |
|
583 | 586 | coreconfigitem('experimental', 'nointerrupt', default=False) |
|
584 | 587 | coreconfigitem('experimental', 'nointerrupt-interactiveonly', default=True) |
|
585 | 588 | |
|
586 | 589 | coreconfigitem('experimental', 'obsmarkers-exchange-debug', |
|
587 | 590 | default=False, |
|
588 | 591 | ) |
|
589 | 592 | coreconfigitem('experimental', 'remotenames', |
|
590 | 593 | default=False, |
|
591 | 594 | ) |
|
592 | 595 | coreconfigitem('experimental', 'removeemptydirs', |
|
593 | 596 | default=True, |
|
594 | 597 | ) |
|
595 | 598 | coreconfigitem('experimental', 'revert.interactive.select-to-keep', |
|
596 | 599 | default=False, |
|
597 | 600 | ) |
|
598 | 601 | coreconfigitem('experimental', 'revisions.prefixhexnode', |
|
599 | 602 | default=False, |
|
600 | 603 | ) |
|
601 | 604 | coreconfigitem('experimental', 'revlogv2', |
|
602 | 605 | default=None, |
|
603 | 606 | ) |
|
604 | 607 | coreconfigitem('experimental', 'revisions.disambiguatewithin', |
|
605 | 608 | default=None, |
|
606 | 609 | ) |
|
607 | 610 | coreconfigitem('experimental', 'server.filesdata.recommended-batch-size', |
|
608 | 611 | default=50000, |
|
609 | 612 | ) |
|
610 | 613 | coreconfigitem('experimental', 'server.manifestdata.recommended-batch-size', |
|
611 | 614 | default=100000, |
|
612 | 615 | ) |
|
613 | 616 | coreconfigitem('experimental', 'server.stream-narrow-clones', |
|
614 | 617 | default=False, |
|
615 | 618 | ) |
|
616 | 619 | coreconfigitem('experimental', 'single-head-per-branch', |
|
617 | 620 | default=False, |
|
618 | 621 | ) |
|
619 | 622 | coreconfigitem('experimental', 'sshserver.support-v2', |
|
620 | 623 | default=False, |
|
621 | 624 | ) |
|
622 | 625 | coreconfigitem('experimental', 'sparse-read', |
|
623 | 626 | default=False, |
|
624 | 627 | ) |
|
625 | 628 | coreconfigitem('experimental', 'sparse-read.density-threshold', |
|
626 | 629 | default=0.50, |
|
627 | 630 | ) |
|
628 | 631 | coreconfigitem('experimental', 'sparse-read.min-gap-size', |
|
629 | 632 | default='65K', |
|
630 | 633 | ) |
|
631 | 634 | coreconfigitem('experimental', 'treemanifest', |
|
632 | 635 | default=False, |
|
633 | 636 | ) |
|
634 | 637 | coreconfigitem('experimental', 'update.atomic-file', |
|
635 | 638 | default=False, |
|
636 | 639 | ) |
|
637 | 640 | coreconfigitem('experimental', 'sshpeer.advertise-v2', |
|
638 | 641 | default=False, |
|
639 | 642 | ) |
|
640 | 643 | coreconfigitem('experimental', 'web.apiserver', |
|
641 | 644 | default=False, |
|
642 | 645 | ) |
|
643 | 646 | coreconfigitem('experimental', 'web.api.http-v2', |
|
644 | 647 | default=False, |
|
645 | 648 | ) |
|
646 | 649 | coreconfigitem('experimental', 'web.api.debugreflect', |
|
647 | 650 | default=False, |
|
648 | 651 | ) |
|
649 | 652 | coreconfigitem('experimental', 'worker.wdir-get-thread-safe', |
|
650 | 653 | default=False, |
|
651 | 654 | ) |
|
652 | 655 | coreconfigitem('experimental', 'xdiff', |
|
653 | 656 | default=False, |
|
654 | 657 | ) |
|
655 | 658 | coreconfigitem('extensions', '.*', |
|
656 | 659 | default=None, |
|
657 | 660 | generic=True, |
|
658 | 661 | ) |
|
659 | 662 | coreconfigitem('extdata', '.*', |
|
660 | 663 | default=None, |
|
661 | 664 | generic=True, |
|
662 | 665 | ) |
|
663 | 666 | coreconfigitem('format', 'chunkcachesize', |
|
664 | 667 | default=None, |
|
665 | 668 | ) |
|
666 | 669 | coreconfigitem('format', 'dotencode', |
|
667 | 670 | default=True, |
|
668 | 671 | ) |
|
669 | 672 | coreconfigitem('format', 'generaldelta', |
|
670 | 673 | default=False, |
|
671 | 674 | ) |
|
672 | 675 | coreconfigitem('format', 'manifestcachesize', |
|
673 | 676 | default=None, |
|
674 | 677 | ) |
|
675 | 678 | coreconfigitem('format', 'maxchainlen', |
|
676 | 679 | default=dynamicdefault, |
|
677 | 680 | ) |
|
678 | 681 | coreconfigitem('format', 'obsstore-version', |
|
679 | 682 | default=None, |
|
680 | 683 | ) |
|
681 | 684 | coreconfigitem('format', 'sparse-revlog', |
|
682 | 685 | default=True, |
|
683 | 686 | ) |
|
684 | 687 | coreconfigitem('format', 'revlog-compression', |
|
685 | 688 | default='zlib', |
|
686 | 689 | alias=[('experimental', 'format.compression')] |
|
687 | 690 | ) |
|
688 | 691 | coreconfigitem('format', 'usefncache', |
|
689 | 692 | default=True, |
|
690 | 693 | ) |
|
691 | 694 | coreconfigitem('format', 'usegeneraldelta', |
|
692 | 695 | default=True, |
|
693 | 696 | ) |
|
694 | 697 | coreconfigitem('format', 'usestore', |
|
695 | 698 | default=True, |
|
696 | 699 | ) |
|
697 | 700 | coreconfigitem('format', 'internal-phase', |
|
698 | 701 | default=False, |
|
699 | 702 | ) |
|
700 | 703 | coreconfigitem('fsmonitor', 'warn_when_unused', |
|
701 | 704 | default=True, |
|
702 | 705 | ) |
|
703 | 706 | coreconfigitem('fsmonitor', 'warn_update_file_count', |
|
704 | 707 | default=50000, |
|
705 | 708 | ) |
|
706 | 709 | coreconfigitem('help', br'hidden-command\..*', |
|
707 | 710 | default=False, |
|
708 | 711 | generic=True, |
|
709 | 712 | ) |
|
710 | 713 | coreconfigitem('help', br'hidden-topic\..*', |
|
711 | 714 | default=False, |
|
712 | 715 | generic=True, |
|
713 | 716 | ) |
|
714 | 717 | coreconfigitem('hooks', '.*', |
|
715 | 718 | default=dynamicdefault, |
|
716 | 719 | generic=True, |
|
717 | 720 | ) |
|
718 | 721 | coreconfigitem('hgweb-paths', '.*', |
|
719 | 722 | default=list, |
|
720 | 723 | generic=True, |
|
721 | 724 | ) |
|
722 | 725 | coreconfigitem('hostfingerprints', '.*', |
|
723 | 726 | default=list, |
|
724 | 727 | generic=True, |
|
725 | 728 | ) |
|
726 | 729 | coreconfigitem('hostsecurity', 'ciphers', |
|
727 | 730 | default=None, |
|
728 | 731 | ) |
|
729 | 732 | coreconfigitem('hostsecurity', 'disabletls10warning', |
|
730 | 733 | default=False, |
|
731 | 734 | ) |
|
732 | 735 | coreconfigitem('hostsecurity', 'minimumprotocol', |
|
733 | 736 | default=dynamicdefault, |
|
734 | 737 | ) |
|
735 | 738 | coreconfigitem('hostsecurity', '.*:minimumprotocol$', |
|
736 | 739 | default=dynamicdefault, |
|
737 | 740 | generic=True, |
|
738 | 741 | ) |
|
739 | 742 | coreconfigitem('hostsecurity', '.*:ciphers$', |
|
740 | 743 | default=dynamicdefault, |
|
741 | 744 | generic=True, |
|
742 | 745 | ) |
|
743 | 746 | coreconfigitem('hostsecurity', '.*:fingerprints$', |
|
744 | 747 | default=list, |
|
745 | 748 | generic=True, |
|
746 | 749 | ) |
|
747 | 750 | coreconfigitem('hostsecurity', '.*:verifycertsfile$', |
|
748 | 751 | default=None, |
|
749 | 752 | generic=True, |
|
750 | 753 | ) |
|
751 | 754 | |
|
752 | 755 | coreconfigitem('http_proxy', 'always', |
|
753 | 756 | default=False, |
|
754 | 757 | ) |
|
755 | 758 | coreconfigitem('http_proxy', 'host', |
|
756 | 759 | default=None, |
|
757 | 760 | ) |
|
758 | 761 | coreconfigitem('http_proxy', 'no', |
|
759 | 762 | default=list, |
|
760 | 763 | ) |
|
761 | 764 | coreconfigitem('http_proxy', 'passwd', |
|
762 | 765 | default=None, |
|
763 | 766 | ) |
|
764 | 767 | coreconfigitem('http_proxy', 'user', |
|
765 | 768 | default=None, |
|
766 | 769 | ) |
|
767 | 770 | |
|
768 | 771 | coreconfigitem('http', 'timeout', |
|
769 | 772 | default=None, |
|
770 | 773 | ) |
|
771 | 774 | |
|
772 | 775 | coreconfigitem('logtoprocess', 'commandexception', |
|
773 | 776 | default=None, |
|
774 | 777 | ) |
|
775 | 778 | coreconfigitem('logtoprocess', 'commandfinish', |
|
776 | 779 | default=None, |
|
777 | 780 | ) |
|
778 | 781 | coreconfigitem('logtoprocess', 'command', |
|
779 | 782 | default=None, |
|
780 | 783 | ) |
|
781 | 784 | coreconfigitem('logtoprocess', 'develwarn', |
|
782 | 785 | default=None, |
|
783 | 786 | ) |
|
784 | 787 | coreconfigitem('logtoprocess', 'uiblocked', |
|
785 | 788 | default=None, |
|
786 | 789 | ) |
|
787 | 790 | coreconfigitem('merge', 'checkunknown', |
|
788 | 791 | default='abort', |
|
789 | 792 | ) |
|
790 | 793 | coreconfigitem('merge', 'checkignored', |
|
791 | 794 | default='abort', |
|
792 | 795 | ) |
|
793 | 796 | coreconfigitem('experimental', 'merge.checkpathconflicts', |
|
794 | 797 | default=False, |
|
795 | 798 | ) |
|
796 | 799 | coreconfigitem('merge', 'followcopies', |
|
797 | 800 | default=True, |
|
798 | 801 | ) |
|
799 | 802 | coreconfigitem('merge', 'on-failure', |
|
800 | 803 | default='continue', |
|
801 | 804 | ) |
|
802 | 805 | coreconfigitem('merge', 'preferancestor', |
|
803 | 806 | default=lambda: ['*'], |
|
804 | 807 | ) |
|
805 | 808 | coreconfigitem('merge', 'strict-capability-check', |
|
806 | 809 | default=False, |
|
807 | 810 | ) |
|
808 | 811 | coreconfigitem('merge-tools', '.*', |
|
809 | 812 | default=None, |
|
810 | 813 | generic=True, |
|
811 | 814 | ) |
|
812 | 815 | coreconfigitem('merge-tools', br'.*\.args$', |
|
813 | 816 | default="$local $base $other", |
|
814 | 817 | generic=True, |
|
815 | 818 | priority=-1, |
|
816 | 819 | ) |
|
817 | 820 | coreconfigitem('merge-tools', br'.*\.binary$', |
|
818 | 821 | default=False, |
|
819 | 822 | generic=True, |
|
820 | 823 | priority=-1, |
|
821 | 824 | ) |
|
822 | 825 | coreconfigitem('merge-tools', br'.*\.check$', |
|
823 | 826 | default=list, |
|
824 | 827 | generic=True, |
|
825 | 828 | priority=-1, |
|
826 | 829 | ) |
|
827 | 830 | coreconfigitem('merge-tools', br'.*\.checkchanged$', |
|
828 | 831 | default=False, |
|
829 | 832 | generic=True, |
|
830 | 833 | priority=-1, |
|
831 | 834 | ) |
|
832 | 835 | coreconfigitem('merge-tools', br'.*\.executable$', |
|
833 | 836 | default=dynamicdefault, |
|
834 | 837 | generic=True, |
|
835 | 838 | priority=-1, |
|
836 | 839 | ) |
|
837 | 840 | coreconfigitem('merge-tools', br'.*\.fixeol$', |
|
838 | 841 | default=False, |
|
839 | 842 | generic=True, |
|
840 | 843 | priority=-1, |
|
841 | 844 | ) |
|
842 | 845 | coreconfigitem('merge-tools', br'.*\.gui$', |
|
843 | 846 | default=False, |
|
844 | 847 | generic=True, |
|
845 | 848 | priority=-1, |
|
846 | 849 | ) |
|
847 | 850 | coreconfigitem('merge-tools', br'.*\.mergemarkers$', |
|
848 | 851 | default='basic', |
|
849 | 852 | generic=True, |
|
850 | 853 | priority=-1, |
|
851 | 854 | ) |
|
852 | 855 | coreconfigitem('merge-tools', br'.*\.mergemarkertemplate$', |
|
853 | 856 | default=dynamicdefault, # take from ui.mergemarkertemplate |
|
854 | 857 | generic=True, |
|
855 | 858 | priority=-1, |
|
856 | 859 | ) |
|
857 | 860 | coreconfigitem('merge-tools', br'.*\.priority$', |
|
858 | 861 | default=0, |
|
859 | 862 | generic=True, |
|
860 | 863 | priority=-1, |
|
861 | 864 | ) |
|
862 | 865 | coreconfigitem('merge-tools', br'.*\.premerge$', |
|
863 | 866 | default=dynamicdefault, |
|
864 | 867 | generic=True, |
|
865 | 868 | priority=-1, |
|
866 | 869 | ) |
|
867 | 870 | coreconfigitem('merge-tools', br'.*\.symlink$', |
|
868 | 871 | default=False, |
|
869 | 872 | generic=True, |
|
870 | 873 | priority=-1, |
|
871 | 874 | ) |
|
872 | 875 | coreconfigitem('pager', 'attend-.*', |
|
873 | 876 | default=dynamicdefault, |
|
874 | 877 | generic=True, |
|
875 | 878 | ) |
|
876 | 879 | coreconfigitem('pager', 'ignore', |
|
877 | 880 | default=list, |
|
878 | 881 | ) |
|
879 | 882 | coreconfigitem('pager', 'pager', |
|
880 | 883 | default=dynamicdefault, |
|
881 | 884 | ) |
|
882 | 885 | coreconfigitem('patch', 'eol', |
|
883 | 886 | default='strict', |
|
884 | 887 | ) |
|
885 | 888 | coreconfigitem('patch', 'fuzz', |
|
886 | 889 | default=2, |
|
887 | 890 | ) |
|
888 | 891 | coreconfigitem('paths', 'default', |
|
889 | 892 | default=None, |
|
890 | 893 | ) |
|
891 | 894 | coreconfigitem('paths', 'default-push', |
|
892 | 895 | default=None, |
|
893 | 896 | ) |
|
894 | 897 | coreconfigitem('paths', '.*', |
|
895 | 898 | default=None, |
|
896 | 899 | generic=True, |
|
897 | 900 | ) |
|
898 | 901 | coreconfigitem('phases', 'checksubrepos', |
|
899 | 902 | default='follow', |
|
900 | 903 | ) |
|
901 | 904 | coreconfigitem('phases', 'new-commit', |
|
902 | 905 | default='draft', |
|
903 | 906 | ) |
|
904 | 907 | coreconfigitem('phases', 'publish', |
|
905 | 908 | default=True, |
|
906 | 909 | ) |
|
907 | 910 | coreconfigitem('profiling', 'enabled', |
|
908 | 911 | default=False, |
|
909 | 912 | ) |
|
910 | 913 | coreconfigitem('profiling', 'format', |
|
911 | 914 | default='text', |
|
912 | 915 | ) |
|
913 | 916 | coreconfigitem('profiling', 'freq', |
|
914 | 917 | default=1000, |
|
915 | 918 | ) |
|
916 | 919 | coreconfigitem('profiling', 'limit', |
|
917 | 920 | default=30, |
|
918 | 921 | ) |
|
919 | 922 | coreconfigitem('profiling', 'nested', |
|
920 | 923 | default=0, |
|
921 | 924 | ) |
|
922 | 925 | coreconfigitem('profiling', 'output', |
|
923 | 926 | default=None, |
|
924 | 927 | ) |
|
925 | 928 | coreconfigitem('profiling', 'showmax', |
|
926 | 929 | default=0.999, |
|
927 | 930 | ) |
|
928 | 931 | coreconfigitem('profiling', 'showmin', |
|
929 | 932 | default=dynamicdefault, |
|
930 | 933 | ) |
|
931 | 934 | coreconfigitem('profiling', 'sort', |
|
932 | 935 | default='inlinetime', |
|
933 | 936 | ) |
|
934 | 937 | coreconfigitem('profiling', 'statformat', |
|
935 | 938 | default='hotpath', |
|
936 | 939 | ) |
|
937 | 940 | coreconfigitem('profiling', 'time-track', |
|
938 | 941 | default=dynamicdefault, |
|
939 | 942 | ) |
|
940 | 943 | coreconfigitem('profiling', 'type', |
|
941 | 944 | default='stat', |
|
942 | 945 | ) |
|
943 | 946 | coreconfigitem('progress', 'assume-tty', |
|
944 | 947 | default=False, |
|
945 | 948 | ) |
|
946 | 949 | coreconfigitem('progress', 'changedelay', |
|
947 | 950 | default=1, |
|
948 | 951 | ) |
|
949 | 952 | coreconfigitem('progress', 'clear-complete', |
|
950 | 953 | default=True, |
|
951 | 954 | ) |
|
952 | 955 | coreconfigitem('progress', 'debug', |
|
953 | 956 | default=False, |
|
954 | 957 | ) |
|
955 | 958 | coreconfigitem('progress', 'delay', |
|
956 | 959 | default=3, |
|
957 | 960 | ) |
|
958 | 961 | coreconfigitem('progress', 'disable', |
|
959 | 962 | default=False, |
|
960 | 963 | ) |
|
961 | 964 | coreconfigitem('progress', 'estimateinterval', |
|
962 | 965 | default=60.0, |
|
963 | 966 | ) |
|
964 | 967 | coreconfigitem('progress', 'format', |
|
965 | 968 | default=lambda: ['topic', 'bar', 'number', 'estimate'], |
|
966 | 969 | ) |
|
967 | 970 | coreconfigitem('progress', 'refresh', |
|
968 | 971 | default=0.1, |
|
969 | 972 | ) |
|
970 | 973 | coreconfigitem('progress', 'width', |
|
971 | 974 | default=dynamicdefault, |
|
972 | 975 | ) |
|
973 | 976 | coreconfigitem('push', 'pushvars.server', |
|
974 | 977 | default=False, |
|
975 | 978 | ) |
|
976 | 979 | coreconfigitem('rewrite', 'backup-bundle', |
|
977 | 980 | default=True, |
|
978 | 981 | alias=[('ui', 'history-editing-backup')], |
|
979 | 982 | ) |
|
980 | 983 | coreconfigitem('rewrite', 'update-timestamp', |
|
981 | 984 | default=False, |
|
982 | 985 | ) |
|
983 | 986 | coreconfigitem('storage', 'new-repo-backend', |
|
984 | 987 | default='revlogv1', |
|
985 | 988 | ) |
|
986 | 989 | coreconfigitem('storage', 'revlog.optimize-delta-parent-choice', |
|
987 | 990 | default=True, |
|
988 | 991 | alias=[('format', 'aggressivemergedeltas')], |
|
989 | 992 | ) |
|
990 | 993 | coreconfigitem('storage', 'revlog.reuse-external-delta', |
|
991 | 994 | default=True, |
|
992 | 995 | ) |
|
993 | 996 | coreconfigitem('storage', 'revlog.reuse-external-delta-parent', |
|
994 | 997 | default=None, |
|
995 | 998 | ) |
|
996 | 999 | coreconfigitem('storage', 'revlog.zlib.level', |
|
997 | 1000 | default=None, |
|
998 | 1001 | ) |
|
999 | 1002 | coreconfigitem('storage', 'revlog.zstd.level', |
|
1000 | 1003 | default=None, |
|
1001 | 1004 | ) |
|
1002 | 1005 | coreconfigitem('server', 'bookmarks-pushkey-compat', |
|
1003 | 1006 | default=True, |
|
1004 | 1007 | ) |
|
1005 | 1008 | coreconfigitem('server', 'bundle1', |
|
1006 | 1009 | default=True, |
|
1007 | 1010 | ) |
|
1008 | 1011 | coreconfigitem('server', 'bundle1gd', |
|
1009 | 1012 | default=None, |
|
1010 | 1013 | ) |
|
1011 | 1014 | coreconfigitem('server', 'bundle1.pull', |
|
1012 | 1015 | default=None, |
|
1013 | 1016 | ) |
|
1014 | 1017 | coreconfigitem('server', 'bundle1gd.pull', |
|
1015 | 1018 | default=None, |
|
1016 | 1019 | ) |
|
1017 | 1020 | coreconfigitem('server', 'bundle1.push', |
|
1018 | 1021 | default=None, |
|
1019 | 1022 | ) |
|
1020 | 1023 | coreconfigitem('server', 'bundle1gd.push', |
|
1021 | 1024 | default=None, |
|
1022 | 1025 | ) |
|
1023 | 1026 | coreconfigitem('server', 'bundle2.stream', |
|
1024 | 1027 | default=True, |
|
1025 | 1028 | alias=[('experimental', 'bundle2.stream')] |
|
1026 | 1029 | ) |
|
1027 | 1030 | coreconfigitem('server', 'compressionengines', |
|
1028 | 1031 | default=list, |
|
1029 | 1032 | ) |
|
1030 | 1033 | coreconfigitem('server', 'concurrent-push-mode', |
|
1031 | 1034 | default='strict', |
|
1032 | 1035 | ) |
|
1033 | 1036 | coreconfigitem('server', 'disablefullbundle', |
|
1034 | 1037 | default=False, |
|
1035 | 1038 | ) |
|
1036 | 1039 | coreconfigitem('server', 'maxhttpheaderlen', |
|
1037 | 1040 | default=1024, |
|
1038 | 1041 | ) |
|
1039 | 1042 | coreconfigitem('server', 'pullbundle', |
|
1040 | 1043 | default=False, |
|
1041 | 1044 | ) |
|
1042 | 1045 | coreconfigitem('server', 'preferuncompressed', |
|
1043 | 1046 | default=False, |
|
1044 | 1047 | ) |
|
1045 | 1048 | coreconfigitem('server', 'streamunbundle', |
|
1046 | 1049 | default=False, |
|
1047 | 1050 | ) |
|
1048 | 1051 | coreconfigitem('server', 'uncompressed', |
|
1049 | 1052 | default=True, |
|
1050 | 1053 | ) |
|
1051 | 1054 | coreconfigitem('server', 'uncompressedallowsecret', |
|
1052 | 1055 | default=False, |
|
1053 | 1056 | ) |
|
1054 | 1057 | coreconfigitem('server', 'view', |
|
1055 | 1058 | default='served', |
|
1056 | 1059 | ) |
|
1057 | 1060 | coreconfigitem('server', 'validate', |
|
1058 | 1061 | default=False, |
|
1059 | 1062 | ) |
|
1060 | 1063 | coreconfigitem('server', 'zliblevel', |
|
1061 | 1064 | default=-1, |
|
1062 | 1065 | ) |
|
1063 | 1066 | coreconfigitem('server', 'zstdlevel', |
|
1064 | 1067 | default=3, |
|
1065 | 1068 | ) |
|
1066 | 1069 | coreconfigitem('share', 'pool', |
|
1067 | 1070 | default=None, |
|
1068 | 1071 | ) |
|
1069 | 1072 | coreconfigitem('share', 'poolnaming', |
|
1070 | 1073 | default='identity', |
|
1071 | 1074 | ) |
|
1072 | 1075 | coreconfigitem('smtp', 'host', |
|
1073 | 1076 | default=None, |
|
1074 | 1077 | ) |
|
1075 | 1078 | coreconfigitem('smtp', 'local_hostname', |
|
1076 | 1079 | default=None, |
|
1077 | 1080 | ) |
|
1078 | 1081 | coreconfigitem('smtp', 'password', |
|
1079 | 1082 | default=None, |
|
1080 | 1083 | ) |
|
1081 | 1084 | coreconfigitem('smtp', 'port', |
|
1082 | 1085 | default=dynamicdefault, |
|
1083 | 1086 | ) |
|
1084 | 1087 | coreconfigitem('smtp', 'tls', |
|
1085 | 1088 | default='none', |
|
1086 | 1089 | ) |
|
1087 | 1090 | coreconfigitem('smtp', 'username', |
|
1088 | 1091 | default=None, |
|
1089 | 1092 | ) |
|
1090 | 1093 | coreconfigitem('sparse', 'missingwarning', |
|
1091 | 1094 | default=True, |
|
1092 | 1095 | ) |
|
1093 | 1096 | coreconfigitem('subrepos', 'allowed', |
|
1094 | 1097 | default=dynamicdefault, # to make backporting simpler |
|
1095 | 1098 | ) |
|
1096 | 1099 | coreconfigitem('subrepos', 'hg:allowed', |
|
1097 | 1100 | default=dynamicdefault, |
|
1098 | 1101 | ) |
|
1099 | 1102 | coreconfigitem('subrepos', 'git:allowed', |
|
1100 | 1103 | default=dynamicdefault, |
|
1101 | 1104 | ) |
|
1102 | 1105 | coreconfigitem('subrepos', 'svn:allowed', |
|
1103 | 1106 | default=dynamicdefault, |
|
1104 | 1107 | ) |
|
1105 | 1108 | coreconfigitem('templates', '.*', |
|
1106 | 1109 | default=None, |
|
1107 | 1110 | generic=True, |
|
1108 | 1111 | ) |
|
1109 | 1112 | coreconfigitem('templateconfig', '.*', |
|
1110 | 1113 | default=dynamicdefault, |
|
1111 | 1114 | generic=True, |
|
1112 | 1115 | ) |
|
1113 | 1116 | coreconfigitem('trusted', 'groups', |
|
1114 | 1117 | default=list, |
|
1115 | 1118 | ) |
|
1116 | 1119 | coreconfigitem('trusted', 'users', |
|
1117 | 1120 | default=list, |
|
1118 | 1121 | ) |
|
1119 | 1122 | coreconfigitem('ui', '_usedassubrepo', |
|
1120 | 1123 | default=False, |
|
1121 | 1124 | ) |
|
1122 | 1125 | coreconfigitem('ui', 'allowemptycommit', |
|
1123 | 1126 | default=False, |
|
1124 | 1127 | ) |
|
1125 | 1128 | coreconfigitem('ui', 'archivemeta', |
|
1126 | 1129 | default=True, |
|
1127 | 1130 | ) |
|
1128 | 1131 | coreconfigitem('ui', 'askusername', |
|
1129 | 1132 | default=False, |
|
1130 | 1133 | ) |
|
1131 | 1134 | coreconfigitem('ui', 'clonebundlefallback', |
|
1132 | 1135 | default=False, |
|
1133 | 1136 | ) |
|
1134 | 1137 | coreconfigitem('ui', 'clonebundleprefers', |
|
1135 | 1138 | default=list, |
|
1136 | 1139 | ) |
|
1137 | 1140 | coreconfigitem('ui', 'clonebundles', |
|
1138 | 1141 | default=True, |
|
1139 | 1142 | ) |
|
1140 | 1143 | coreconfigitem('ui', 'color', |
|
1141 | 1144 | default='auto', |
|
1142 | 1145 | ) |
|
1143 | 1146 | coreconfigitem('ui', 'commitsubrepos', |
|
1144 | 1147 | default=False, |
|
1145 | 1148 | ) |
|
1146 | 1149 | coreconfigitem('ui', 'debug', |
|
1147 | 1150 | default=False, |
|
1148 | 1151 | ) |
|
1149 | 1152 | coreconfigitem('ui', 'debugger', |
|
1150 | 1153 | default=None, |
|
1151 | 1154 | ) |
|
1152 | 1155 | coreconfigitem('ui', 'editor', |
|
1153 | 1156 | default=dynamicdefault, |
|
1154 | 1157 | ) |
|
1155 | 1158 | coreconfigitem('ui', 'fallbackencoding', |
|
1156 | 1159 | default=None, |
|
1157 | 1160 | ) |
|
1158 | 1161 | coreconfigitem('ui', 'forcecwd', |
|
1159 | 1162 | default=None, |
|
1160 | 1163 | ) |
|
1161 | 1164 | coreconfigitem('ui', 'forcemerge', |
|
1162 | 1165 | default=None, |
|
1163 | 1166 | ) |
|
1164 | 1167 | coreconfigitem('ui', 'formatdebug', |
|
1165 | 1168 | default=False, |
|
1166 | 1169 | ) |
|
1167 | 1170 | coreconfigitem('ui', 'formatjson', |
|
1168 | 1171 | default=False, |
|
1169 | 1172 | ) |
|
1170 | 1173 | coreconfigitem('ui', 'formatted', |
|
1171 | 1174 | default=None, |
|
1172 | 1175 | ) |
|
1173 | 1176 | coreconfigitem('ui', 'graphnodetemplate', |
|
1174 | 1177 | default=None, |
|
1175 | 1178 | ) |
|
1176 | 1179 | coreconfigitem('ui', 'interactive', |
|
1177 | 1180 | default=None, |
|
1178 | 1181 | ) |
|
1179 | 1182 | coreconfigitem('ui', 'interface', |
|
1180 | 1183 | default=None, |
|
1181 | 1184 | ) |
|
1182 | 1185 | coreconfigitem('ui', 'interface.chunkselector', |
|
1183 | 1186 | default=None, |
|
1184 | 1187 | ) |
|
1185 | 1188 | coreconfigitem('ui', 'large-file-limit', |
|
1186 | 1189 | default=10000000, |
|
1187 | 1190 | ) |
|
1188 | 1191 | coreconfigitem('ui', 'logblockedtimes', |
|
1189 | 1192 | default=False, |
|
1190 | 1193 | ) |
|
1191 | 1194 | coreconfigitem('ui', 'logtemplate', |
|
1192 | 1195 | default=None, |
|
1193 | 1196 | ) |
|
1194 | 1197 | coreconfigitem('ui', 'merge', |
|
1195 | 1198 | default=None, |
|
1196 | 1199 | ) |
|
1197 | 1200 | coreconfigitem('ui', 'mergemarkers', |
|
1198 | 1201 | default='basic', |
|
1199 | 1202 | ) |
|
1200 | 1203 | coreconfigitem('ui', 'mergemarkertemplate', |
|
1201 | 1204 | default=('{node|short} ' |
|
1202 | 1205 | '{ifeq(tags, "tip", "", ' |
|
1203 | 1206 | 'ifeq(tags, "", "", "{tags} "))}' |
|
1204 | 1207 | '{if(bookmarks, "{bookmarks} ")}' |
|
1205 | 1208 | '{ifeq(branch, "default", "", "{branch} ")}' |
|
1206 | 1209 | '- {author|user}: {desc|firstline}') |
|
1207 | 1210 | ) |
|
1208 | 1211 | coreconfigitem('ui', 'message-output', |
|
1209 | 1212 | default='stdio', |
|
1210 | 1213 | ) |
|
1211 | 1214 | coreconfigitem('ui', 'nontty', |
|
1212 | 1215 | default=False, |
|
1213 | 1216 | ) |
|
1214 | 1217 | coreconfigitem('ui', 'origbackuppath', |
|
1215 | 1218 | default=None, |
|
1216 | 1219 | ) |
|
1217 | 1220 | coreconfigitem('ui', 'paginate', |
|
1218 | 1221 | default=True, |
|
1219 | 1222 | ) |
|
1220 | 1223 | coreconfigitem('ui', 'patch', |
|
1221 | 1224 | default=None, |
|
1222 | 1225 | ) |
|
1223 | 1226 | coreconfigitem('ui', 'pre-merge-tool-output-template', |
|
1224 | 1227 | default=None, |
|
1225 | 1228 | ) |
|
1226 | 1229 | coreconfigitem('ui', 'portablefilenames', |
|
1227 | 1230 | default='warn', |
|
1228 | 1231 | ) |
|
1229 | 1232 | coreconfigitem('ui', 'promptecho', |
|
1230 | 1233 | default=False, |
|
1231 | 1234 | ) |
|
1232 | 1235 | coreconfigitem('ui', 'quiet', |
|
1233 | 1236 | default=False, |
|
1234 | 1237 | ) |
|
1235 | 1238 | coreconfigitem('ui', 'quietbookmarkmove', |
|
1236 | 1239 | default=False, |
|
1237 | 1240 | ) |
|
1238 | 1241 | coreconfigitem('ui', 'relative-paths', |
|
1239 | 1242 | default='legacy', |
|
1240 | 1243 | ) |
|
1241 | 1244 | coreconfigitem('ui', 'remotecmd', |
|
1242 | 1245 | default='hg', |
|
1243 | 1246 | ) |
|
1244 | 1247 | coreconfigitem('ui', 'report_untrusted', |
|
1245 | 1248 | default=True, |
|
1246 | 1249 | ) |
|
1247 | 1250 | coreconfigitem('ui', 'rollback', |
|
1248 | 1251 | default=True, |
|
1249 | 1252 | ) |
|
1250 | 1253 | coreconfigitem('ui', 'signal-safe-lock', |
|
1251 | 1254 | default=True, |
|
1252 | 1255 | ) |
|
1253 | 1256 | coreconfigitem('ui', 'slash', |
|
1254 | 1257 | default=False, |
|
1255 | 1258 | ) |
|
1256 | 1259 | coreconfigitem('ui', 'ssh', |
|
1257 | 1260 | default='ssh', |
|
1258 | 1261 | ) |
|
1259 | 1262 | coreconfigitem('ui', 'ssherrorhint', |
|
1260 | 1263 | default=None, |
|
1261 | 1264 | ) |
|
1262 | 1265 | coreconfigitem('ui', 'statuscopies', |
|
1263 | 1266 | default=False, |
|
1264 | 1267 | ) |
|
1265 | 1268 | coreconfigitem('ui', 'strict', |
|
1266 | 1269 | default=False, |
|
1267 | 1270 | ) |
|
1268 | 1271 | coreconfigitem('ui', 'style', |
|
1269 | 1272 | default='', |
|
1270 | 1273 | ) |
|
1271 | 1274 | coreconfigitem('ui', 'supportcontact', |
|
1272 | 1275 | default=None, |
|
1273 | 1276 | ) |
|
1274 | 1277 | coreconfigitem('ui', 'textwidth', |
|
1275 | 1278 | default=78, |
|
1276 | 1279 | ) |
|
1277 | 1280 | coreconfigitem('ui', 'timeout', |
|
1278 | 1281 | default='600', |
|
1279 | 1282 | ) |
|
1280 | 1283 | coreconfigitem('ui', 'timeout.warn', |
|
1281 | 1284 | default=0, |
|
1282 | 1285 | ) |
|
1283 | 1286 | coreconfigitem('ui', 'traceback', |
|
1284 | 1287 | default=False, |
|
1285 | 1288 | ) |
|
1286 | 1289 | coreconfigitem('ui', 'tweakdefaults', |
|
1287 | 1290 | default=False, |
|
1288 | 1291 | ) |
|
1289 | 1292 | coreconfigitem('ui', 'username', |
|
1290 | 1293 | alias=[('ui', 'user')] |
|
1291 | 1294 | ) |
|
1292 | 1295 | coreconfigitem('ui', 'verbose', |
|
1293 | 1296 | default=False, |
|
1294 | 1297 | ) |
|
1295 | 1298 | coreconfigitem('verify', 'skipflags', |
|
1296 | 1299 | default=None, |
|
1297 | 1300 | ) |
|
1298 | 1301 | coreconfigitem('web', 'allowbz2', |
|
1299 | 1302 | default=False, |
|
1300 | 1303 | ) |
|
1301 | 1304 | coreconfigitem('web', 'allowgz', |
|
1302 | 1305 | default=False, |
|
1303 | 1306 | ) |
|
1304 | 1307 | coreconfigitem('web', 'allow-pull', |
|
1305 | 1308 | alias=[('web', 'allowpull')], |
|
1306 | 1309 | default=True, |
|
1307 | 1310 | ) |
|
1308 | 1311 | coreconfigitem('web', 'allow-push', |
|
1309 | 1312 | alias=[('web', 'allow_push')], |
|
1310 | 1313 | default=list, |
|
1311 | 1314 | ) |
|
1312 | 1315 | coreconfigitem('web', 'allowzip', |
|
1313 | 1316 | default=False, |
|
1314 | 1317 | ) |
|
1315 | 1318 | coreconfigitem('web', 'archivesubrepos', |
|
1316 | 1319 | default=False, |
|
1317 | 1320 | ) |
|
1318 | 1321 | coreconfigitem('web', 'cache', |
|
1319 | 1322 | default=True, |
|
1320 | 1323 | ) |
|
1321 | 1324 | coreconfigitem('web', 'comparisoncontext', |
|
1322 | 1325 | default=5, |
|
1323 | 1326 | ) |
|
1324 | 1327 | coreconfigitem('web', 'contact', |
|
1325 | 1328 | default=None, |
|
1326 | 1329 | ) |
|
1327 | 1330 | coreconfigitem('web', 'deny_push', |
|
1328 | 1331 | default=list, |
|
1329 | 1332 | ) |
|
1330 | 1333 | coreconfigitem('web', 'guessmime', |
|
1331 | 1334 | default=False, |
|
1332 | 1335 | ) |
|
1333 | 1336 | coreconfigitem('web', 'hidden', |
|
1334 | 1337 | default=False, |
|
1335 | 1338 | ) |
|
1336 | 1339 | coreconfigitem('web', 'labels', |
|
1337 | 1340 | default=list, |
|
1338 | 1341 | ) |
|
1339 | 1342 | coreconfigitem('web', 'logoimg', |
|
1340 | 1343 | default='hglogo.png', |
|
1341 | 1344 | ) |
|
1342 | 1345 | coreconfigitem('web', 'logourl', |
|
1343 | 1346 | default='https://mercurial-scm.org/', |
|
1344 | 1347 | ) |
|
1345 | 1348 | coreconfigitem('web', 'accesslog', |
|
1346 | 1349 | default='-', |
|
1347 | 1350 | ) |
|
1348 | 1351 | coreconfigitem('web', 'address', |
|
1349 | 1352 | default='', |
|
1350 | 1353 | ) |
|
1351 | 1354 | coreconfigitem('web', 'allow-archive', |
|
1352 | 1355 | alias=[('web', 'allow_archive')], |
|
1353 | 1356 | default=list, |
|
1354 | 1357 | ) |
|
1355 | 1358 | coreconfigitem('web', 'allow_read', |
|
1356 | 1359 | default=list, |
|
1357 | 1360 | ) |
|
1358 | 1361 | coreconfigitem('web', 'baseurl', |
|
1359 | 1362 | default=None, |
|
1360 | 1363 | ) |
|
1361 | 1364 | coreconfigitem('web', 'cacerts', |
|
1362 | 1365 | default=None, |
|
1363 | 1366 | ) |
|
1364 | 1367 | coreconfigitem('web', 'certificate', |
|
1365 | 1368 | default=None, |
|
1366 | 1369 | ) |
|
1367 | 1370 | coreconfigitem('web', 'collapse', |
|
1368 | 1371 | default=False, |
|
1369 | 1372 | ) |
|
1370 | 1373 | coreconfigitem('web', 'csp', |
|
1371 | 1374 | default=None, |
|
1372 | 1375 | ) |
|
1373 | 1376 | coreconfigitem('web', 'deny_read', |
|
1374 | 1377 | default=list, |
|
1375 | 1378 | ) |
|
1376 | 1379 | coreconfigitem('web', 'descend', |
|
1377 | 1380 | default=True, |
|
1378 | 1381 | ) |
|
1379 | 1382 | coreconfigitem('web', 'description', |
|
1380 | 1383 | default="", |
|
1381 | 1384 | ) |
|
1382 | 1385 | coreconfigitem('web', 'encoding', |
|
1383 | 1386 | default=lambda: encoding.encoding, |
|
1384 | 1387 | ) |
|
1385 | 1388 | coreconfigitem('web', 'errorlog', |
|
1386 | 1389 | default='-', |
|
1387 | 1390 | ) |
|
1388 | 1391 | coreconfigitem('web', 'ipv6', |
|
1389 | 1392 | default=False, |
|
1390 | 1393 | ) |
|
1391 | 1394 | coreconfigitem('web', 'maxchanges', |
|
1392 | 1395 | default=10, |
|
1393 | 1396 | ) |
|
1394 | 1397 | coreconfigitem('web', 'maxfiles', |
|
1395 | 1398 | default=10, |
|
1396 | 1399 | ) |
|
1397 | 1400 | coreconfigitem('web', 'maxshortchanges', |
|
1398 | 1401 | default=60, |
|
1399 | 1402 | ) |
|
1400 | 1403 | coreconfigitem('web', 'motd', |
|
1401 | 1404 | default='', |
|
1402 | 1405 | ) |
|
1403 | 1406 | coreconfigitem('web', 'name', |
|
1404 | 1407 | default=dynamicdefault, |
|
1405 | 1408 | ) |
|
1406 | 1409 | coreconfigitem('web', 'port', |
|
1407 | 1410 | default=8000, |
|
1408 | 1411 | ) |
|
1409 | 1412 | coreconfigitem('web', 'prefix', |
|
1410 | 1413 | default='', |
|
1411 | 1414 | ) |
|
1412 | 1415 | coreconfigitem('web', 'push_ssl', |
|
1413 | 1416 | default=True, |
|
1414 | 1417 | ) |
|
1415 | 1418 | coreconfigitem('web', 'refreshinterval', |
|
1416 | 1419 | default=20, |
|
1417 | 1420 | ) |
|
1418 | 1421 | coreconfigitem('web', 'server-header', |
|
1419 | 1422 | default=None, |
|
1420 | 1423 | ) |
|
1421 | 1424 | coreconfigitem('web', 'static', |
|
1422 | 1425 | default=None, |
|
1423 | 1426 | ) |
|
1424 | 1427 | coreconfigitem('web', 'staticurl', |
|
1425 | 1428 | default=None, |
|
1426 | 1429 | ) |
|
1427 | 1430 | coreconfigitem('web', 'stripes', |
|
1428 | 1431 | default=1, |
|
1429 | 1432 | ) |
|
1430 | 1433 | coreconfigitem('web', 'style', |
|
1431 | 1434 | default='paper', |
|
1432 | 1435 | ) |
|
1433 | 1436 | coreconfigitem('web', 'templates', |
|
1434 | 1437 | default=None, |
|
1435 | 1438 | ) |
|
1436 | 1439 | coreconfigitem('web', 'view', |
|
1437 | 1440 | default='served', |
|
1438 | 1441 | ) |
|
1439 | 1442 | coreconfigitem('worker', 'backgroundclose', |
|
1440 | 1443 | default=dynamicdefault, |
|
1441 | 1444 | ) |
|
1442 | 1445 | # Windows defaults to a limit of 512 open files. A buffer of 128 |
|
1443 | 1446 | # should give us enough headway. |
|
1444 | 1447 | coreconfigitem('worker', 'backgroundclosemaxqueue', |
|
1445 | 1448 | default=384, |
|
1446 | 1449 | ) |
|
1447 | 1450 | coreconfigitem('worker', 'backgroundcloseminfilecount', |
|
1448 | 1451 | default=2048, |
|
1449 | 1452 | ) |
|
1450 | 1453 | coreconfigitem('worker', 'backgroundclosethreadcount', |
|
1451 | 1454 | default=4, |
|
1452 | 1455 | ) |
|
1453 | 1456 | coreconfigitem('worker', 'enabled', |
|
1454 | 1457 | default=True, |
|
1455 | 1458 | ) |
|
1456 | 1459 | coreconfigitem('worker', 'numcpus', |
|
1457 | 1460 | default=None, |
|
1458 | 1461 | ) |
|
1459 | 1462 | |
|
1460 | 1463 | # Rebase related configuration moved to core because other extension are doing |
|
1461 | 1464 | # strange things. For example, shelve import the extensions to reuse some bit |
|
1462 | 1465 | # without formally loading it. |
|
1463 | 1466 | coreconfigitem('commands', 'rebase.requiredest', |
|
1464 | 1467 | default=False, |
|
1465 | 1468 | ) |
|
1466 | 1469 | coreconfigitem('experimental', 'rebaseskipobsolete', |
|
1467 | 1470 | default=True, |
|
1468 | 1471 | ) |
|
1469 | 1472 | coreconfigitem('rebase', 'singletransaction', |
|
1470 | 1473 | default=False, |
|
1471 | 1474 | ) |
|
1472 | 1475 | coreconfigitem('rebase', 'experimental.inmemory', |
|
1473 | 1476 | default=False, |
|
1474 | 1477 | ) |
@@ -1,3126 +1,3136 | |||
|
1 | 1 | # localrepo.py - read/write repository class for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import errno |
|
11 | 11 | import hashlib |
|
12 | 12 | import os |
|
13 | 13 | import random |
|
14 | 14 | import sys |
|
15 | 15 | import time |
|
16 | 16 | import weakref |
|
17 | 17 | |
|
18 | 18 | from .i18n import _ |
|
19 | 19 | from .node import ( |
|
20 | 20 | bin, |
|
21 | 21 | hex, |
|
22 | 22 | nullid, |
|
23 | 23 | nullrev, |
|
24 | 24 | short, |
|
25 | 25 | ) |
|
26 | 26 | from . import ( |
|
27 | 27 | bookmarks, |
|
28 | 28 | branchmap, |
|
29 | 29 | bundle2, |
|
30 | 30 | changegroup, |
|
31 | 31 | changelog, |
|
32 | 32 | color, |
|
33 | 33 | context, |
|
34 | 34 | dirstate, |
|
35 | 35 | dirstateguard, |
|
36 | 36 | discovery, |
|
37 | 37 | encoding, |
|
38 | 38 | error, |
|
39 | 39 | exchange, |
|
40 | 40 | extensions, |
|
41 | 41 | filelog, |
|
42 | 42 | hook, |
|
43 | 43 | lock as lockmod, |
|
44 | 44 | manifest, |
|
45 | 45 | match as matchmod, |
|
46 | 46 | merge as mergemod, |
|
47 | 47 | mergeutil, |
|
48 | 48 | namespaces, |
|
49 | 49 | narrowspec, |
|
50 | 50 | obsolete, |
|
51 | 51 | pathutil, |
|
52 | 52 | phases, |
|
53 | 53 | pushkey, |
|
54 | 54 | pycompat, |
|
55 | 55 | repository, |
|
56 | 56 | repoview, |
|
57 | 57 | revset, |
|
58 | 58 | revsetlang, |
|
59 | 59 | scmutil, |
|
60 | 60 | sparse, |
|
61 | 61 | store as storemod, |
|
62 | 62 | subrepoutil, |
|
63 | 63 | tags as tagsmod, |
|
64 | 64 | transaction, |
|
65 | 65 | txnutil, |
|
66 | 66 | util, |
|
67 | 67 | vfs as vfsmod, |
|
68 | 68 | ) |
|
69 | 69 | from .utils import ( |
|
70 | 70 | interfaceutil, |
|
71 | 71 | procutil, |
|
72 | 72 | stringutil, |
|
73 | 73 | ) |
|
74 | 74 | |
|
75 | 75 | from .revlogutils import ( |
|
76 | 76 | constants as revlogconst, |
|
77 | 77 | ) |
|
78 | 78 | |
|
79 | 79 | release = lockmod.release |
|
80 | 80 | urlerr = util.urlerr |
|
81 | 81 | urlreq = util.urlreq |
|
82 | 82 | |
|
83 | 83 | # set of (path, vfs-location) tuples. vfs-location is: |
|
84 | 84 | # - 'plain for vfs relative paths |
|
85 | 85 | # - '' for svfs relative paths |
|
86 | 86 | _cachedfiles = set() |
|
87 | 87 | |
|
88 | 88 | class _basefilecache(scmutil.filecache): |
|
89 | 89 | """All filecache usage on repo are done for logic that should be unfiltered |
|
90 | 90 | """ |
|
91 | 91 | def __get__(self, repo, type=None): |
|
92 | 92 | if repo is None: |
|
93 | 93 | return self |
|
94 | 94 | # proxy to unfiltered __dict__ since filtered repo has no entry |
|
95 | 95 | unfi = repo.unfiltered() |
|
96 | 96 | try: |
|
97 | 97 | return unfi.__dict__[self.sname] |
|
98 | 98 | except KeyError: |
|
99 | 99 | pass |
|
100 | 100 | return super(_basefilecache, self).__get__(unfi, type) |
|
101 | 101 | |
|
102 | 102 | def set(self, repo, value): |
|
103 | 103 | return super(_basefilecache, self).set(repo.unfiltered(), value) |
|
104 | 104 | |
|
105 | 105 | class repofilecache(_basefilecache): |
|
106 | 106 | """filecache for files in .hg but outside of .hg/store""" |
|
107 | 107 | def __init__(self, *paths): |
|
108 | 108 | super(repofilecache, self).__init__(*paths) |
|
109 | 109 | for path in paths: |
|
110 | 110 | _cachedfiles.add((path, 'plain')) |
|
111 | 111 | |
|
112 | 112 | def join(self, obj, fname): |
|
113 | 113 | return obj.vfs.join(fname) |
|
114 | 114 | |
|
115 | 115 | class storecache(_basefilecache): |
|
116 | 116 | """filecache for files in the store""" |
|
117 | 117 | def __init__(self, *paths): |
|
118 | 118 | super(storecache, self).__init__(*paths) |
|
119 | 119 | for path in paths: |
|
120 | 120 | _cachedfiles.add((path, '')) |
|
121 | 121 | |
|
122 | 122 | def join(self, obj, fname): |
|
123 | 123 | return obj.sjoin(fname) |
|
124 | 124 | |
|
125 | 125 | def isfilecached(repo, name): |
|
126 | 126 | """check if a repo has already cached "name" filecache-ed property |
|
127 | 127 | |
|
128 | 128 | This returns (cachedobj-or-None, iscached) tuple. |
|
129 | 129 | """ |
|
130 | 130 | cacheentry = repo.unfiltered()._filecache.get(name, None) |
|
131 | 131 | if not cacheentry: |
|
132 | 132 | return None, False |
|
133 | 133 | return cacheentry.obj, True |
|
134 | 134 | |
|
135 | 135 | class unfilteredpropertycache(util.propertycache): |
|
136 | 136 | """propertycache that apply to unfiltered repo only""" |
|
137 | 137 | |
|
138 | 138 | def __get__(self, repo, type=None): |
|
139 | 139 | unfi = repo.unfiltered() |
|
140 | 140 | if unfi is repo: |
|
141 | 141 | return super(unfilteredpropertycache, self).__get__(unfi) |
|
142 | 142 | return getattr(unfi, self.name) |
|
143 | 143 | |
|
144 | 144 | class filteredpropertycache(util.propertycache): |
|
145 | 145 | """propertycache that must take filtering in account""" |
|
146 | 146 | |
|
147 | 147 | def cachevalue(self, obj, value): |
|
148 | 148 | object.__setattr__(obj, self.name, value) |
|
149 | 149 | |
|
150 | 150 | |
|
151 | 151 | def hasunfilteredcache(repo, name): |
|
152 | 152 | """check if a repo has an unfilteredpropertycache value for <name>""" |
|
153 | 153 | return name in vars(repo.unfiltered()) |
|
154 | 154 | |
|
155 | 155 | def unfilteredmethod(orig): |
|
156 | 156 | """decorate method that always need to be run on unfiltered version""" |
|
157 | 157 | def wrapper(repo, *args, **kwargs): |
|
158 | 158 | return orig(repo.unfiltered(), *args, **kwargs) |
|
159 | 159 | return wrapper |
|
160 | 160 | |
|
161 | 161 | moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', |
|
162 | 162 | 'unbundle'} |
|
163 | 163 | legacycaps = moderncaps.union({'changegroupsubset'}) |
|
164 | 164 | |
|
165 | 165 | @interfaceutil.implementer(repository.ipeercommandexecutor) |
|
166 | 166 | class localcommandexecutor(object): |
|
167 | 167 | def __init__(self, peer): |
|
168 | 168 | self._peer = peer |
|
169 | 169 | self._sent = False |
|
170 | 170 | self._closed = False |
|
171 | 171 | |
|
172 | 172 | def __enter__(self): |
|
173 | 173 | return self |
|
174 | 174 | |
|
175 | 175 | def __exit__(self, exctype, excvalue, exctb): |
|
176 | 176 | self.close() |
|
177 | 177 | |
|
178 | 178 | def callcommand(self, command, args): |
|
179 | 179 | if self._sent: |
|
180 | 180 | raise error.ProgrammingError('callcommand() cannot be used after ' |
|
181 | 181 | 'sendcommands()') |
|
182 | 182 | |
|
183 | 183 | if self._closed: |
|
184 | 184 | raise error.ProgrammingError('callcommand() cannot be used after ' |
|
185 | 185 | 'close()') |
|
186 | 186 | |
|
187 | 187 | # We don't need to support anything fancy. Just call the named |
|
188 | 188 | # method on the peer and return a resolved future. |
|
189 | 189 | fn = getattr(self._peer, pycompat.sysstr(command)) |
|
190 | 190 | |
|
191 | 191 | f = pycompat.futures.Future() |
|
192 | 192 | |
|
193 | 193 | try: |
|
194 | 194 | result = fn(**pycompat.strkwargs(args)) |
|
195 | 195 | except Exception: |
|
196 | 196 | pycompat.future_set_exception_info(f, sys.exc_info()[1:]) |
|
197 | 197 | else: |
|
198 | 198 | f.set_result(result) |
|
199 | 199 | |
|
200 | 200 | return f |
|
201 | 201 | |
|
202 | 202 | def sendcommands(self): |
|
203 | 203 | self._sent = True |
|
204 | 204 | |
|
205 | 205 | def close(self): |
|
206 | 206 | self._closed = True |
|
207 | 207 | |
|
208 | 208 | @interfaceutil.implementer(repository.ipeercommands) |
|
209 | 209 | class localpeer(repository.peer): |
|
210 | 210 | '''peer for a local repo; reflects only the most recent API''' |
|
211 | 211 | |
|
212 | 212 | def __init__(self, repo, caps=None): |
|
213 | 213 | super(localpeer, self).__init__() |
|
214 | 214 | |
|
215 | 215 | if caps is None: |
|
216 | 216 | caps = moderncaps.copy() |
|
217 | 217 | self._repo = repo.filtered('served') |
|
218 | 218 | self.ui = repo.ui |
|
219 | 219 | self._caps = repo._restrictcapabilities(caps) |
|
220 | 220 | |
|
221 | 221 | # Begin of _basepeer interface. |
|
222 | 222 | |
|
223 | 223 | def url(self): |
|
224 | 224 | return self._repo.url() |
|
225 | 225 | |
|
226 | 226 | def local(self): |
|
227 | 227 | return self._repo |
|
228 | 228 | |
|
229 | 229 | def peer(self): |
|
230 | 230 | return self |
|
231 | 231 | |
|
232 | 232 | def canpush(self): |
|
233 | 233 | return True |
|
234 | 234 | |
|
235 | 235 | def close(self): |
|
236 | 236 | self._repo.close() |
|
237 | 237 | |
|
238 | 238 | # End of _basepeer interface. |
|
239 | 239 | |
|
240 | 240 | # Begin of _basewirecommands interface. |
|
241 | 241 | |
|
242 | 242 | def branchmap(self): |
|
243 | 243 | return self._repo.branchmap() |
|
244 | 244 | |
|
245 | 245 | def capabilities(self): |
|
246 | 246 | return self._caps |
|
247 | 247 | |
|
248 | 248 | def clonebundles(self): |
|
249 | 249 | return self._repo.tryread('clonebundles.manifest') |
|
250 | 250 | |
|
251 | 251 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
252 | 252 | """Used to test argument passing over the wire""" |
|
253 | 253 | return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three), |
|
254 | 254 | pycompat.bytestr(four), |
|
255 | 255 | pycompat.bytestr(five)) |
|
256 | 256 | |
|
257 | 257 | def getbundle(self, source, heads=None, common=None, bundlecaps=None, |
|
258 | 258 | **kwargs): |
|
259 | 259 | chunks = exchange.getbundlechunks(self._repo, source, heads=heads, |
|
260 | 260 | common=common, bundlecaps=bundlecaps, |
|
261 | 261 | **kwargs)[1] |
|
262 | 262 | cb = util.chunkbuffer(chunks) |
|
263 | 263 | |
|
264 | 264 | if exchange.bundle2requested(bundlecaps): |
|
265 | 265 | # When requesting a bundle2, getbundle returns a stream to make the |
|
266 | 266 | # wire level function happier. We need to build a proper object |
|
267 | 267 | # from it in local peer. |
|
268 | 268 | return bundle2.getunbundler(self.ui, cb) |
|
269 | 269 | else: |
|
270 | 270 | return changegroup.getunbundler('01', cb, None) |
|
271 | 271 | |
|
272 | 272 | def heads(self): |
|
273 | 273 | return self._repo.heads() |
|
274 | 274 | |
|
275 | 275 | def known(self, nodes): |
|
276 | 276 | return self._repo.known(nodes) |
|
277 | 277 | |
|
278 | 278 | def listkeys(self, namespace): |
|
279 | 279 | return self._repo.listkeys(namespace) |
|
280 | 280 | |
|
281 | 281 | def lookup(self, key): |
|
282 | 282 | return self._repo.lookup(key) |
|
283 | 283 | |
|
284 | 284 | def pushkey(self, namespace, key, old, new): |
|
285 | 285 | return self._repo.pushkey(namespace, key, old, new) |
|
286 | 286 | |
|
287 | 287 | def stream_out(self): |
|
288 | 288 | raise error.Abort(_('cannot perform stream clone against local ' |
|
289 | 289 | 'peer')) |
|
290 | 290 | |
|
291 | 291 | def unbundle(self, bundle, heads, url): |
|
292 | 292 | """apply a bundle on a repo |
|
293 | 293 | |
|
294 | 294 | This function handles the repo locking itself.""" |
|
295 | 295 | try: |
|
296 | 296 | try: |
|
297 | 297 | bundle = exchange.readbundle(self.ui, bundle, None) |
|
298 | 298 | ret = exchange.unbundle(self._repo, bundle, heads, 'push', url) |
|
299 | 299 | if util.safehasattr(ret, 'getchunks'): |
|
300 | 300 | # This is a bundle20 object, turn it into an unbundler. |
|
301 | 301 | # This little dance should be dropped eventually when the |
|
302 | 302 | # API is finally improved. |
|
303 | 303 | stream = util.chunkbuffer(ret.getchunks()) |
|
304 | 304 | ret = bundle2.getunbundler(self.ui, stream) |
|
305 | 305 | return ret |
|
306 | 306 | except Exception as exc: |
|
307 | 307 | # If the exception contains output salvaged from a bundle2 |
|
308 | 308 | # reply, we need to make sure it is printed before continuing |
|
309 | 309 | # to fail. So we build a bundle2 with such output and consume |
|
310 | 310 | # it directly. |
|
311 | 311 | # |
|
312 | 312 | # This is not very elegant but allows a "simple" solution for |
|
313 | 313 | # issue4594 |
|
314 | 314 | output = getattr(exc, '_bundle2salvagedoutput', ()) |
|
315 | 315 | if output: |
|
316 | 316 | bundler = bundle2.bundle20(self._repo.ui) |
|
317 | 317 | for out in output: |
|
318 | 318 | bundler.addpart(out) |
|
319 | 319 | stream = util.chunkbuffer(bundler.getchunks()) |
|
320 | 320 | b = bundle2.getunbundler(self.ui, stream) |
|
321 | 321 | bundle2.processbundle(self._repo, b) |
|
322 | 322 | raise |
|
323 | 323 | except error.PushRaced as exc: |
|
324 | 324 | raise error.ResponseError(_('push failed:'), |
|
325 | 325 | stringutil.forcebytestr(exc)) |
|
326 | 326 | |
|
327 | 327 | # End of _basewirecommands interface. |
|
328 | 328 | |
|
329 | 329 | # Begin of peer interface. |
|
330 | 330 | |
|
331 | 331 | def commandexecutor(self): |
|
332 | 332 | return localcommandexecutor(self) |
|
333 | 333 | |
|
334 | 334 | # End of peer interface. |
|
335 | 335 | |
|
336 | 336 | @interfaceutil.implementer(repository.ipeerlegacycommands) |
|
337 | 337 | class locallegacypeer(localpeer): |
|
338 | 338 | '''peer extension which implements legacy methods too; used for tests with |
|
339 | 339 | restricted capabilities''' |
|
340 | 340 | |
|
341 | 341 | def __init__(self, repo): |
|
342 | 342 | super(locallegacypeer, self).__init__(repo, caps=legacycaps) |
|
343 | 343 | |
|
344 | 344 | # Begin of baselegacywirecommands interface. |
|
345 | 345 | |
|
346 | 346 | def between(self, pairs): |
|
347 | 347 | return self._repo.between(pairs) |
|
348 | 348 | |
|
349 | 349 | def branches(self, nodes): |
|
350 | 350 | return self._repo.branches(nodes) |
|
351 | 351 | |
|
352 | 352 | def changegroup(self, nodes, source): |
|
353 | 353 | outgoing = discovery.outgoing(self._repo, missingroots=nodes, |
|
354 | 354 | missingheads=self._repo.heads()) |
|
355 | 355 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
356 | 356 | |
|
357 | 357 | def changegroupsubset(self, bases, heads, source): |
|
358 | 358 | outgoing = discovery.outgoing(self._repo, missingroots=bases, |
|
359 | 359 | missingheads=heads) |
|
360 | 360 | return changegroup.makechangegroup(self._repo, outgoing, '01', source) |
|
361 | 361 | |
|
362 | 362 | # End of baselegacywirecommands interface. |
|
363 | 363 | |
|
364 | 364 | # Increment the sub-version when the revlog v2 format changes to lock out old |
|
365 | 365 | # clients. |
|
366 | 366 | REVLOGV2_REQUIREMENT = 'exp-revlogv2.1' |
|
367 | 367 | |
|
368 | 368 | # A repository with the sparserevlog feature will have delta chains that |
|
369 | 369 | # can spread over a larger span. Sparse reading cuts these large spans into |
|
370 | 370 | # pieces, so that each piece isn't too big. |
|
371 | 371 | # Without the sparserevlog capability, reading from the repository could use |
|
372 | 372 | # huge amounts of memory, because the whole span would be read at once, |
|
373 | 373 | # including all the intermediate revisions that aren't pertinent for the chain. |
|
374 | 374 | # This is why once a repository has enabled sparse-read, it becomes required. |
|
375 | 375 | SPARSEREVLOG_REQUIREMENT = 'sparserevlog' |
|
376 | 376 | |
|
377 | 377 | # Functions receiving (ui, features) that extensions can register to impact |
|
378 | 378 | # the ability to load repositories with custom requirements. Only |
|
379 | 379 | # functions defined in loaded extensions are called. |
|
380 | 380 | # |
|
381 | 381 | # The function receives a set of requirement strings that the repository |
|
382 | 382 | # is capable of opening. Functions will typically add elements to the |
|
383 | 383 | # set to reflect that the extension knows how to handle that requirements. |
|
384 | 384 | featuresetupfuncs = set() |
|
385 | 385 | |
|
386 | 386 | def makelocalrepository(baseui, path, intents=None): |
|
387 | 387 | """Create a local repository object. |
|
388 | 388 | |
|
389 | 389 | Given arguments needed to construct a local repository, this function |
|
390 | 390 | performs various early repository loading functionality (such as |
|
391 | 391 | reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that |
|
392 | 392 | the repository can be opened, derives a type suitable for representing |
|
393 | 393 | that repository, and returns an instance of it. |
|
394 | 394 | |
|
395 | 395 | The returned object conforms to the ``repository.completelocalrepository`` |
|
396 | 396 | interface. |
|
397 | 397 | |
|
398 | 398 | The repository type is derived by calling a series of factory functions |
|
399 | 399 | for each aspect/interface of the final repository. These are defined by |
|
400 | 400 | ``REPO_INTERFACES``. |
|
401 | 401 | |
|
402 | 402 | Each factory function is called to produce a type implementing a specific |
|
403 | 403 | interface. The cumulative list of returned types will be combined into a |
|
404 | 404 | new type and that type will be instantiated to represent the local |
|
405 | 405 | repository. |
|
406 | 406 | |
|
407 | 407 | The factory functions each receive various state that may be consulted |
|
408 | 408 | as part of deriving a type. |
|
409 | 409 | |
|
410 | 410 | Extensions should wrap these factory functions to customize repository type |
|
411 | 411 | creation. Note that an extension's wrapped function may be called even if |
|
412 | 412 | that extension is not loaded for the repo being constructed. Extensions |
|
413 | 413 | should check if their ``__name__`` appears in the |
|
414 | 414 | ``extensionmodulenames`` set passed to the factory function and no-op if |
|
415 | 415 | not. |
|
416 | 416 | """ |
|
417 | 417 | ui = baseui.copy() |
|
418 | 418 | # Prevent copying repo configuration. |
|
419 | 419 | ui.copy = baseui.copy |
|
420 | 420 | |
|
421 | 421 | # Working directory VFS rooted at repository root. |
|
422 | 422 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
423 | 423 | |
|
424 | 424 | # Main VFS for .hg/ directory. |
|
425 | 425 | hgpath = wdirvfs.join(b'.hg') |
|
426 | 426 | hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) |
|
427 | 427 | |
|
428 | 428 | # The .hg/ path should exist and should be a directory. All other |
|
429 | 429 | # cases are errors. |
|
430 | 430 | if not hgvfs.isdir(): |
|
431 | 431 | try: |
|
432 | 432 | hgvfs.stat() |
|
433 | 433 | except OSError as e: |
|
434 | 434 | if e.errno != errno.ENOENT: |
|
435 | 435 | raise |
|
436 | 436 | |
|
437 | 437 | raise error.RepoError(_(b'repository %s not found') % path) |
|
438 | 438 | |
|
439 | 439 | # .hg/requires file contains a newline-delimited list of |
|
440 | 440 | # features/capabilities the opener (us) must have in order to use |
|
441 | 441 | # the repository. This file was introduced in Mercurial 0.9.2, |
|
442 | 442 | # which means very old repositories may not have one. We assume |
|
443 | 443 | # a missing file translates to no requirements. |
|
444 | 444 | try: |
|
445 | 445 | requirements = set(hgvfs.read(b'requires').splitlines()) |
|
446 | 446 | except IOError as e: |
|
447 | 447 | if e.errno != errno.ENOENT: |
|
448 | 448 | raise |
|
449 | 449 | requirements = set() |
|
450 | 450 | |
|
451 | 451 | # The .hg/hgrc file may load extensions or contain config options |
|
452 | 452 | # that influence repository construction. Attempt to load it and |
|
453 | 453 | # process any new extensions that it may have pulled in. |
|
454 | 454 | if loadhgrc(ui, wdirvfs, hgvfs, requirements): |
|
455 | 455 | afterhgrcload(ui, wdirvfs, hgvfs, requirements) |
|
456 | 456 | extensions.loadall(ui) |
|
457 | 457 | extensions.populateui(ui) |
|
458 | 458 | |
|
459 | 459 | # Set of module names of extensions loaded for this repository. |
|
460 | 460 | extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)} |
|
461 | 461 | |
|
462 | 462 | supportedrequirements = gathersupportedrequirements(ui) |
|
463 | 463 | |
|
464 | 464 | # We first validate the requirements are known. |
|
465 | 465 | ensurerequirementsrecognized(requirements, supportedrequirements) |
|
466 | 466 | |
|
467 | 467 | # Then we validate that the known set is reasonable to use together. |
|
468 | 468 | ensurerequirementscompatible(ui, requirements) |
|
469 | 469 | |
|
470 | 470 | # TODO there are unhandled edge cases related to opening repositories with |
|
471 | 471 | # shared storage. If storage is shared, we should also test for requirements |
|
472 | 472 | # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in |
|
473 | 473 | # that repo, as that repo may load extensions needed to open it. This is a |
|
474 | 474 | # bit complicated because we don't want the other hgrc to overwrite settings |
|
475 | 475 | # in this hgrc. |
|
476 | 476 | # |
|
477 | 477 | # This bug is somewhat mitigated by the fact that we copy the .hg/requires |
|
478 | 478 | # file when sharing repos. But if a requirement is added after the share is |
|
479 | 479 | # performed, thereby introducing a new requirement for the opener, we may |
|
480 | 480 | # will not see that and could encounter a run-time error interacting with |
|
481 | 481 | # that shared store since it has an unknown-to-us requirement. |
|
482 | 482 | |
|
483 | 483 | # At this point, we know we should be capable of opening the repository. |
|
484 | 484 | # Now get on with doing that. |
|
485 | 485 | |
|
486 | 486 | features = set() |
|
487 | 487 | |
|
488 | 488 | # The "store" part of the repository holds versioned data. How it is |
|
489 | 489 | # accessed is determined by various requirements. The ``shared`` or |
|
490 | 490 | # ``relshared`` requirements indicate the store lives in the path contained |
|
491 | 491 | # in the ``.hg/sharedpath`` file. This is an absolute path for |
|
492 | 492 | # ``shared`` and relative to ``.hg/`` for ``relshared``. |
|
493 | 493 | if b'shared' in requirements or b'relshared' in requirements: |
|
494 | 494 | sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n') |
|
495 | 495 | if b'relshared' in requirements: |
|
496 | 496 | sharedpath = hgvfs.join(sharedpath) |
|
497 | 497 | |
|
498 | 498 | sharedvfs = vfsmod.vfs(sharedpath, realpath=True) |
|
499 | 499 | |
|
500 | 500 | if not sharedvfs.exists(): |
|
501 | 501 | raise error.RepoError(_(b'.hg/sharedpath points to nonexistent ' |
|
502 | 502 | b'directory %s') % sharedvfs.base) |
|
503 | 503 | |
|
504 | 504 | features.add(repository.REPO_FEATURE_SHARED_STORAGE) |
|
505 | 505 | |
|
506 | 506 | storebasepath = sharedvfs.base |
|
507 | 507 | cachepath = sharedvfs.join(b'cache') |
|
508 | 508 | else: |
|
509 | 509 | storebasepath = hgvfs.base |
|
510 | 510 | cachepath = hgvfs.join(b'cache') |
|
511 | 511 | wcachepath = hgvfs.join(b'wcache') |
|
512 | 512 | |
|
513 | 513 | |
|
514 | 514 | # The store has changed over time and the exact layout is dictated by |
|
515 | 515 | # requirements. The store interface abstracts differences across all |
|
516 | 516 | # of them. |
|
517 | 517 | store = makestore(requirements, storebasepath, |
|
518 | 518 | lambda base: vfsmod.vfs(base, cacheaudited=True)) |
|
519 | 519 | hgvfs.createmode = store.createmode |
|
520 | 520 | |
|
521 | 521 | storevfs = store.vfs |
|
522 | 522 | storevfs.options = resolvestorevfsoptions(ui, requirements, features) |
|
523 | 523 | |
|
524 | 524 | # The cache vfs is used to manage cache files. |
|
525 | 525 | cachevfs = vfsmod.vfs(cachepath, cacheaudited=True) |
|
526 | 526 | cachevfs.createmode = store.createmode |
|
527 | 527 | # The cache vfs is used to manage cache files related to the working copy |
|
528 | 528 | wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True) |
|
529 | 529 | wcachevfs.createmode = store.createmode |
|
530 | 530 | |
|
531 | 531 | # Now resolve the type for the repository object. We do this by repeatedly |
|
532 | 532 | # calling a factory function to produces types for specific aspects of the |
|
533 | 533 | # repo's operation. The aggregate returned types are used as base classes |
|
534 | 534 | # for a dynamically-derived type, which will represent our new repository. |
|
535 | 535 | |
|
536 | 536 | bases = [] |
|
537 | 537 | extrastate = {} |
|
538 | 538 | |
|
539 | 539 | for iface, fn in REPO_INTERFACES: |
|
540 | 540 | # We pass all potentially useful state to give extensions tons of |
|
541 | 541 | # flexibility. |
|
542 | 542 | typ = fn()(ui=ui, |
|
543 | 543 | intents=intents, |
|
544 | 544 | requirements=requirements, |
|
545 | 545 | features=features, |
|
546 | 546 | wdirvfs=wdirvfs, |
|
547 | 547 | hgvfs=hgvfs, |
|
548 | 548 | store=store, |
|
549 | 549 | storevfs=storevfs, |
|
550 | 550 | storeoptions=storevfs.options, |
|
551 | 551 | cachevfs=cachevfs, |
|
552 | 552 | wcachevfs=wcachevfs, |
|
553 | 553 | extensionmodulenames=extensionmodulenames, |
|
554 | 554 | extrastate=extrastate, |
|
555 | 555 | baseclasses=bases) |
|
556 | 556 | |
|
557 | 557 | if not isinstance(typ, type): |
|
558 | 558 | raise error.ProgrammingError('unable to construct type for %s' % |
|
559 | 559 | iface) |
|
560 | 560 | |
|
561 | 561 | bases.append(typ) |
|
562 | 562 | |
|
563 | 563 | # type() allows you to use characters in type names that wouldn't be |
|
564 | 564 | # recognized as Python symbols in source code. We abuse that to add |
|
565 | 565 | # rich information about our constructed repo. |
|
566 | 566 | name = pycompat.sysstr(b'derivedrepo:%s<%s>' % ( |
|
567 | 567 | wdirvfs.base, |
|
568 | 568 | b','.join(sorted(requirements)))) |
|
569 | 569 | |
|
570 | 570 | cls = type(name, tuple(bases), {}) |
|
571 | 571 | |
|
572 | 572 | return cls( |
|
573 | 573 | baseui=baseui, |
|
574 | 574 | ui=ui, |
|
575 | 575 | origroot=path, |
|
576 | 576 | wdirvfs=wdirvfs, |
|
577 | 577 | hgvfs=hgvfs, |
|
578 | 578 | requirements=requirements, |
|
579 | 579 | supportedrequirements=supportedrequirements, |
|
580 | 580 | sharedpath=storebasepath, |
|
581 | 581 | store=store, |
|
582 | 582 | cachevfs=cachevfs, |
|
583 | 583 | wcachevfs=wcachevfs, |
|
584 | 584 | features=features, |
|
585 | 585 | intents=intents) |
|
586 | 586 | |
|
587 | 587 | def loadhgrc(ui, wdirvfs, hgvfs, requirements): |
|
588 | 588 | """Load hgrc files/content into a ui instance. |
|
589 | 589 | |
|
590 | 590 | This is called during repository opening to load any additional |
|
591 | 591 | config files or settings relevant to the current repository. |
|
592 | 592 | |
|
593 | 593 | Returns a bool indicating whether any additional configs were loaded. |
|
594 | 594 | |
|
595 | 595 | Extensions should monkeypatch this function to modify how per-repo |
|
596 | 596 | configs are loaded. For example, an extension may wish to pull in |
|
597 | 597 | configs from alternate files or sources. |
|
598 | 598 | """ |
|
599 | 599 | try: |
|
600 | 600 | ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
|
601 | 601 | return True |
|
602 | 602 | except IOError: |
|
603 | 603 | return False |
|
604 | 604 | |
|
605 | 605 | def afterhgrcload(ui, wdirvfs, hgvfs, requirements): |
|
606 | 606 | """Perform additional actions after .hg/hgrc is loaded. |
|
607 | 607 | |
|
608 | 608 | This function is called during repository loading immediately after |
|
609 | 609 | the .hg/hgrc file is loaded and before per-repo extensions are loaded. |
|
610 | 610 | |
|
611 | 611 | The function can be used to validate configs, automatically add |
|
612 | 612 | options (including extensions) based on requirements, etc. |
|
613 | 613 | """ |
|
614 | 614 | |
|
615 | 615 | # Map of requirements to list of extensions to load automatically when |
|
616 | 616 | # requirement is present. |
|
617 | 617 | autoextensions = { |
|
618 | 618 | b'largefiles': [b'largefiles'], |
|
619 | 619 | b'lfs': [b'lfs'], |
|
620 | 620 | } |
|
621 | 621 | |
|
622 | 622 | for requirement, names in sorted(autoextensions.items()): |
|
623 | 623 | if requirement not in requirements: |
|
624 | 624 | continue |
|
625 | 625 | |
|
626 | 626 | for name in names: |
|
627 | 627 | if not ui.hasconfig(b'extensions', name): |
|
628 | 628 | ui.setconfig(b'extensions', name, b'', source='autoload') |
|
629 | 629 | |
|
630 | 630 | def gathersupportedrequirements(ui): |
|
631 | 631 | """Determine the complete set of recognized requirements.""" |
|
632 | 632 | # Start with all requirements supported by this file. |
|
633 | 633 | supported = set(localrepository._basesupported) |
|
634 | 634 | |
|
635 | 635 | # Execute ``featuresetupfuncs`` entries if they belong to an extension |
|
636 | 636 | # relevant to this ui instance. |
|
637 | 637 | modules = {m.__name__ for n, m in extensions.extensions(ui)} |
|
638 | 638 | |
|
639 | 639 | for fn in featuresetupfuncs: |
|
640 | 640 | if fn.__module__ in modules: |
|
641 | 641 | fn(ui, supported) |
|
642 | 642 | |
|
643 | 643 | # Add derived requirements from registered compression engines. |
|
644 | 644 | for name in util.compengines: |
|
645 | 645 | engine = util.compengines[name] |
|
646 | 646 | if engine.available() and engine.revlogheader(): |
|
647 | 647 | supported.add(b'exp-compression-%s' % name) |
|
648 | 648 | if engine.name() == 'zstd': |
|
649 | 649 | supported.add(b'revlog-compression-zstd') |
|
650 | 650 | |
|
651 | 651 | return supported |
|
652 | 652 | |
|
653 | 653 | def ensurerequirementsrecognized(requirements, supported): |
|
654 | 654 | """Validate that a set of local requirements is recognized. |
|
655 | 655 | |
|
656 | 656 | Receives a set of requirements. Raises an ``error.RepoError`` if there |
|
657 | 657 | exists any requirement in that set that currently loaded code doesn't |
|
658 | 658 | recognize. |
|
659 | 659 | |
|
660 | 660 | Returns a set of supported requirements. |
|
661 | 661 | """ |
|
662 | 662 | missing = set() |
|
663 | 663 | |
|
664 | 664 | for requirement in requirements: |
|
665 | 665 | if requirement in supported: |
|
666 | 666 | continue |
|
667 | 667 | |
|
668 | 668 | if not requirement or not requirement[0:1].isalnum(): |
|
669 | 669 | raise error.RequirementError(_(b'.hg/requires file is corrupt')) |
|
670 | 670 | |
|
671 | 671 | missing.add(requirement) |
|
672 | 672 | |
|
673 | 673 | if missing: |
|
674 | 674 | raise error.RequirementError( |
|
675 | 675 | _(b'repository requires features unknown to this Mercurial: %s') % |
|
676 | 676 | b' '.join(sorted(missing)), |
|
677 | 677 | hint=_(b'see https://mercurial-scm.org/wiki/MissingRequirement ' |
|
678 | 678 | b'for more information')) |
|
679 | 679 | |
|
680 | 680 | def ensurerequirementscompatible(ui, requirements): |
|
681 | 681 | """Validates that a set of recognized requirements is mutually compatible. |
|
682 | 682 | |
|
683 | 683 | Some requirements may not be compatible with others or require |
|
684 | 684 | config options that aren't enabled. This function is called during |
|
685 | 685 | repository opening to ensure that the set of requirements needed |
|
686 | 686 | to open a repository is sane and compatible with config options. |
|
687 | 687 | |
|
688 | 688 | Extensions can monkeypatch this function to perform additional |
|
689 | 689 | checking. |
|
690 | 690 | |
|
691 | 691 | ``error.RepoError`` should be raised on failure. |
|
692 | 692 | """ |
|
693 | 693 | if b'exp-sparse' in requirements and not sparse.enabled: |
|
694 | 694 | raise error.RepoError(_(b'repository is using sparse feature but ' |
|
695 | 695 | b'sparse is not enabled; enable the ' |
|
696 | 696 | b'"sparse" extensions to access')) |
|
697 | 697 | |
|
698 | 698 | def makestore(requirements, path, vfstype): |
|
699 | 699 | """Construct a storage object for a repository.""" |
|
700 | 700 | if b'store' in requirements: |
|
701 | 701 | if b'fncache' in requirements: |
|
702 | 702 | return storemod.fncachestore(path, vfstype, |
|
703 | 703 | b'dotencode' in requirements) |
|
704 | 704 | |
|
705 | 705 | return storemod.encodedstore(path, vfstype) |
|
706 | 706 | |
|
707 | 707 | return storemod.basicstore(path, vfstype) |
|
708 | 708 | |
|
709 | 709 | def resolvestorevfsoptions(ui, requirements, features): |
|
710 | 710 | """Resolve the options to pass to the store vfs opener. |
|
711 | 711 | |
|
712 | 712 | The returned dict is used to influence behavior of the storage layer. |
|
713 | 713 | """ |
|
714 | 714 | options = {} |
|
715 | 715 | |
|
716 | 716 | if b'treemanifest' in requirements: |
|
717 | 717 | options[b'treemanifest'] = True |
|
718 | 718 | |
|
719 | 719 | # experimental config: format.manifestcachesize |
|
720 | 720 | manifestcachesize = ui.configint(b'format', b'manifestcachesize') |
|
721 | 721 | if manifestcachesize is not None: |
|
722 | 722 | options[b'manifestcachesize'] = manifestcachesize |
|
723 | 723 | |
|
724 | 724 | # In the absence of another requirement superseding a revlog-related |
|
725 | 725 | # requirement, we have to assume the repo is using revlog version 0. |
|
726 | 726 | # This revlog format is super old and we don't bother trying to parse |
|
727 | 727 | # opener options for it because those options wouldn't do anything |
|
728 | 728 | # meaningful on such old repos. |
|
729 | 729 | if b'revlogv1' in requirements or REVLOGV2_REQUIREMENT in requirements: |
|
730 | 730 | options.update(resolverevlogstorevfsoptions(ui, requirements, features)) |
|
731 | 731 | |
|
732 | 732 | return options |
|
733 | 733 | |
|
734 | 734 | def resolverevlogstorevfsoptions(ui, requirements, features): |
|
735 | 735 | """Resolve opener options specific to revlogs.""" |
|
736 | 736 | |
|
737 | 737 | options = {} |
|
738 | 738 | options[b'flagprocessors'] = {} |
|
739 | 739 | |
|
740 | 740 | if b'revlogv1' in requirements: |
|
741 | 741 | options[b'revlogv1'] = True |
|
742 | 742 | if REVLOGV2_REQUIREMENT in requirements: |
|
743 | 743 | options[b'revlogv2'] = True |
|
744 | 744 | |
|
745 | 745 | if b'generaldelta' in requirements: |
|
746 | 746 | options[b'generaldelta'] = True |
|
747 | 747 | |
|
748 | 748 | # experimental config: format.chunkcachesize |
|
749 | 749 | chunkcachesize = ui.configint(b'format', b'chunkcachesize') |
|
750 | 750 | if chunkcachesize is not None: |
|
751 | 751 | options[b'chunkcachesize'] = chunkcachesize |
|
752 | 752 | |
|
753 | 753 | deltabothparents = ui.configbool(b'storage', |
|
754 | 754 | b'revlog.optimize-delta-parent-choice') |
|
755 | 755 | options[b'deltabothparents'] = deltabothparents |
|
756 | 756 | |
|
757 | 757 | lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta') |
|
758 | 758 | lazydeltabase = False |
|
759 | 759 | if lazydelta: |
|
760 | 760 | lazydeltabase = ui.configbool(b'storage', |
|
761 | 761 | b'revlog.reuse-external-delta-parent') |
|
762 | 762 | if lazydeltabase is None: |
|
763 | 763 | lazydeltabase = not scmutil.gddeltaconfig(ui) |
|
764 | 764 | options[b'lazydelta'] = lazydelta |
|
765 | 765 | options[b'lazydeltabase'] = lazydeltabase |
|
766 | 766 | |
|
767 | 767 | chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan') |
|
768 | 768 | if 0 <= chainspan: |
|
769 | 769 | options[b'maxdeltachainspan'] = chainspan |
|
770 | 770 | |
|
771 | 771 | mmapindexthreshold = ui.configbytes(b'experimental', |
|
772 | 772 | b'mmapindexthreshold') |
|
773 | 773 | if mmapindexthreshold is not None: |
|
774 | 774 | options[b'mmapindexthreshold'] = mmapindexthreshold |
|
775 | 775 | |
|
776 | 776 | withsparseread = ui.configbool(b'experimental', b'sparse-read') |
|
777 | 777 | srdensitythres = float(ui.config(b'experimental', |
|
778 | 778 | b'sparse-read.density-threshold')) |
|
779 | 779 | srmingapsize = ui.configbytes(b'experimental', |
|
780 | 780 | b'sparse-read.min-gap-size') |
|
781 | 781 | options[b'with-sparse-read'] = withsparseread |
|
782 | 782 | options[b'sparse-read-density-threshold'] = srdensitythres |
|
783 | 783 | options[b'sparse-read-min-gap-size'] = srmingapsize |
|
784 | 784 | |
|
785 | 785 | sparserevlog = SPARSEREVLOG_REQUIREMENT in requirements |
|
786 | 786 | options[b'sparse-revlog'] = sparserevlog |
|
787 | 787 | if sparserevlog: |
|
788 | 788 | options[b'generaldelta'] = True |
|
789 | 789 | |
|
790 | 790 | maxchainlen = None |
|
791 | 791 | if sparserevlog: |
|
792 | 792 | maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH |
|
793 | 793 | # experimental config: format.maxchainlen |
|
794 | 794 | maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen) |
|
795 | 795 | if maxchainlen is not None: |
|
796 | 796 | options[b'maxchainlen'] = maxchainlen |
|
797 | 797 | |
|
798 | 798 | for r in requirements: |
|
799 | 799 | # we allow multiple compression engine requirement to co-exist because |
|
800 | 800 | # strickly speaking, revlog seems to support mixed compression style. |
|
801 | 801 | # |
|
802 | 802 | # The compression used for new entries will be "the last one" |
|
803 | 803 | prefix = r.startswith |
|
804 | 804 | if prefix('revlog-compression-') or prefix('exp-compression-'): |
|
805 | 805 | options[b'compengine'] = r.split('-', 2)[2] |
|
806 | 806 | |
|
807 | 807 | options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level') |
|
808 | 808 | if options[b'zlib.level'] is not None: |
|
809 | 809 | if not (0 <= options[b'zlib.level'] <= 9): |
|
810 | 810 | msg = _('invalid value for `storage.revlog.zlib.level` config: %d') |
|
811 | 811 | raise error.Abort(msg % options[b'zlib.level']) |
|
812 | 812 | options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level') |
|
813 | 813 | if options[b'zstd.level'] is not None: |
|
814 | 814 | if not (0 <= options[b'zstd.level'] <= 22): |
|
815 | 815 | msg = _('invalid value for `storage.revlog.zstd.level` config: %d') |
|
816 | 816 | raise error.Abort(msg % options[b'zstd.level']) |
|
817 | 817 | |
|
818 | 818 | if repository.NARROW_REQUIREMENT in requirements: |
|
819 | 819 | options[b'enableellipsis'] = True |
|
820 | 820 | |
|
821 | 821 | return options |
|
822 | 822 | |
|
823 | 823 | def makemain(**kwargs): |
|
824 | 824 | """Produce a type conforming to ``ilocalrepositorymain``.""" |
|
825 | 825 | return localrepository |
|
826 | 826 | |
|
827 | 827 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
828 | 828 | class revlogfilestorage(object): |
|
829 | 829 | """File storage when using revlogs.""" |
|
830 | 830 | |
|
831 | 831 | def file(self, path): |
|
832 | 832 | if path[0] == b'/': |
|
833 | 833 | path = path[1:] |
|
834 | 834 | |
|
835 | 835 | return filelog.filelog(self.svfs, path) |
|
836 | 836 | |
|
837 | 837 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) |
|
838 | 838 | class revlognarrowfilestorage(object): |
|
839 | 839 | """File storage when using revlogs and narrow files.""" |
|
840 | 840 | |
|
841 | 841 | def file(self, path): |
|
842 | 842 | if path[0] == b'/': |
|
843 | 843 | path = path[1:] |
|
844 | 844 | |
|
845 | 845 | return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch) |
|
846 | 846 | |
|
847 | 847 | def makefilestorage(requirements, features, **kwargs): |
|
848 | 848 | """Produce a type conforming to ``ilocalrepositoryfilestorage``.""" |
|
849 | 849 | features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE) |
|
850 | 850 | features.add(repository.REPO_FEATURE_STREAM_CLONE) |
|
851 | 851 | |
|
852 | 852 | if repository.NARROW_REQUIREMENT in requirements: |
|
853 | 853 | return revlognarrowfilestorage |
|
854 | 854 | else: |
|
855 | 855 | return revlogfilestorage |
|
856 | 856 | |
|
857 | 857 | # List of repository interfaces and factory functions for them. Each |
|
858 | 858 | # will be called in order during ``makelocalrepository()`` to iteratively |
|
859 | 859 | # derive the final type for a local repository instance. We capture the |
|
860 | 860 | # function as a lambda so we don't hold a reference and the module-level |
|
861 | 861 | # functions can be wrapped. |
|
862 | 862 | REPO_INTERFACES = [ |
|
863 | 863 | (repository.ilocalrepositorymain, lambda: makemain), |
|
864 | 864 | (repository.ilocalrepositoryfilestorage, lambda: makefilestorage), |
|
865 | 865 | ] |
|
866 | 866 | |
|
867 | 867 | @interfaceutil.implementer(repository.ilocalrepositorymain) |
|
868 | 868 | class localrepository(object): |
|
869 | 869 | """Main class for representing local repositories. |
|
870 | 870 | |
|
871 | 871 | All local repositories are instances of this class. |
|
872 | 872 | |
|
873 | 873 | Constructed on its own, instances of this class are not usable as |
|
874 | 874 | repository objects. To obtain a usable repository object, call |
|
875 | 875 | ``hg.repository()``, ``localrepo.instance()``, or |
|
876 | 876 | ``localrepo.makelocalrepository()``. The latter is the lowest-level. |
|
877 | 877 | ``instance()`` adds support for creating new repositories. |
|
878 | 878 | ``hg.repository()`` adds more extension integration, including calling |
|
879 | 879 | ``reposetup()``. Generally speaking, ``hg.repository()`` should be |
|
880 | 880 | used. |
|
881 | 881 | """ |
|
882 | 882 | |
|
883 | 883 | # obsolete experimental requirements: |
|
884 | 884 | # - manifestv2: An experimental new manifest format that allowed |
|
885 | 885 | # for stem compression of long paths. Experiment ended up not |
|
886 | 886 | # being successful (repository sizes went up due to worse delta |
|
887 | 887 | # chains), and the code was deleted in 4.6. |
|
888 | 888 | supportedformats = { |
|
889 | 889 | 'revlogv1', |
|
890 | 890 | 'generaldelta', |
|
891 | 891 | 'treemanifest', |
|
892 | 892 | REVLOGV2_REQUIREMENT, |
|
893 | 893 | SPARSEREVLOG_REQUIREMENT, |
|
894 | 894 | } |
|
895 | 895 | _basesupported = supportedformats | { |
|
896 | 896 | 'store', |
|
897 | 897 | 'fncache', |
|
898 | 898 | 'shared', |
|
899 | 899 | 'relshared', |
|
900 | 900 | 'dotencode', |
|
901 | 901 | 'exp-sparse', |
|
902 | 902 | 'internal-phase' |
|
903 | 903 | } |
|
904 | 904 | |
|
905 | 905 | # list of prefix for file which can be written without 'wlock' |
|
906 | 906 | # Extensions should extend this list when needed |
|
907 | 907 | _wlockfreeprefix = { |
|
908 | 908 | # We migh consider requiring 'wlock' for the next |
|
909 | 909 | # two, but pretty much all the existing code assume |
|
910 | 910 | # wlock is not needed so we keep them excluded for |
|
911 | 911 | # now. |
|
912 | 912 | 'hgrc', |
|
913 | 913 | 'requires', |
|
914 | 914 | # XXX cache is a complicatged business someone |
|
915 | 915 | # should investigate this in depth at some point |
|
916 | 916 | 'cache/', |
|
917 | 917 | # XXX shouldn't be dirstate covered by the wlock? |
|
918 | 918 | 'dirstate', |
|
919 | 919 | # XXX bisect was still a bit too messy at the time |
|
920 | 920 | # this changeset was introduced. Someone should fix |
|
921 | 921 | # the remainig bit and drop this line |
|
922 | 922 | 'bisect.state', |
|
923 | 923 | } |
|
924 | 924 | |
|
925 | 925 | def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, requirements, |
|
926 | 926 | supportedrequirements, sharedpath, store, cachevfs, wcachevfs, |
|
927 | 927 | features, intents=None): |
|
928 | 928 | """Create a new local repository instance. |
|
929 | 929 | |
|
930 | 930 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, |
|
931 | 931 | or ``localrepo.makelocalrepository()`` for obtaining a new repository |
|
932 | 932 | object. |
|
933 | 933 | |
|
934 | 934 | Arguments: |
|
935 | 935 | |
|
936 | 936 | baseui |
|
937 | 937 | ``ui.ui`` instance that ``ui`` argument was based off of. |
|
938 | 938 | |
|
939 | 939 | ui |
|
940 | 940 | ``ui.ui`` instance for use by the repository. |
|
941 | 941 | |
|
942 | 942 | origroot |
|
943 | 943 | ``bytes`` path to working directory root of this repository. |
|
944 | 944 | |
|
945 | 945 | wdirvfs |
|
946 | 946 | ``vfs.vfs`` rooted at the working directory. |
|
947 | 947 | |
|
948 | 948 | hgvfs |
|
949 | 949 | ``vfs.vfs`` rooted at .hg/ |
|
950 | 950 | |
|
951 | 951 | requirements |
|
952 | 952 | ``set`` of bytestrings representing repository opening requirements. |
|
953 | 953 | |
|
954 | 954 | supportedrequirements |
|
955 | 955 | ``set`` of bytestrings representing repository requirements that we |
|
956 | 956 | know how to open. May be a supetset of ``requirements``. |
|
957 | 957 | |
|
958 | 958 | sharedpath |
|
959 | 959 | ``bytes`` Defining path to storage base directory. Points to a |
|
960 | 960 | ``.hg/`` directory somewhere. |
|
961 | 961 | |
|
962 | 962 | store |
|
963 | 963 | ``store.basicstore`` (or derived) instance providing access to |
|
964 | 964 | versioned storage. |
|
965 | 965 | |
|
966 | 966 | cachevfs |
|
967 | 967 | ``vfs.vfs`` used for cache files. |
|
968 | 968 | |
|
969 | 969 | wcachevfs |
|
970 | 970 | ``vfs.vfs`` used for cache files related to the working copy. |
|
971 | 971 | |
|
972 | 972 | features |
|
973 | 973 | ``set`` of bytestrings defining features/capabilities of this |
|
974 | 974 | instance. |
|
975 | 975 | |
|
976 | 976 | intents |
|
977 | 977 | ``set`` of system strings indicating what this repo will be used |
|
978 | 978 | for. |
|
979 | 979 | """ |
|
980 | 980 | self.baseui = baseui |
|
981 | 981 | self.ui = ui |
|
982 | 982 | self.origroot = origroot |
|
983 | 983 | # vfs rooted at working directory. |
|
984 | 984 | self.wvfs = wdirvfs |
|
985 | 985 | self.root = wdirvfs.base |
|
986 | 986 | # vfs rooted at .hg/. Used to access most non-store paths. |
|
987 | 987 | self.vfs = hgvfs |
|
988 | 988 | self.path = hgvfs.base |
|
989 | 989 | self.requirements = requirements |
|
990 | 990 | self.supported = supportedrequirements |
|
991 | 991 | self.sharedpath = sharedpath |
|
992 | 992 | self.store = store |
|
993 | 993 | self.cachevfs = cachevfs |
|
994 | 994 | self.wcachevfs = wcachevfs |
|
995 | 995 | self.features = features |
|
996 | 996 | |
|
997 | 997 | self.filtername = None |
|
998 | 998 | |
|
999 | 999 | if (self.ui.configbool('devel', 'all-warnings') or |
|
1000 | 1000 | self.ui.configbool('devel', 'check-locks')): |
|
1001 | 1001 | self.vfs.audit = self._getvfsward(self.vfs.audit) |
|
1002 | 1002 | # A list of callback to shape the phase if no data were found. |
|
1003 | 1003 | # Callback are in the form: func(repo, roots) --> processed root. |
|
1004 | 1004 | # This list it to be filled by extension during repo setup |
|
1005 | 1005 | self._phasedefaults = [] |
|
1006 | 1006 | |
|
1007 | 1007 | color.setup(self.ui) |
|
1008 | 1008 | |
|
1009 | 1009 | self.spath = self.store.path |
|
1010 | 1010 | self.svfs = self.store.vfs |
|
1011 | 1011 | self.sjoin = self.store.join |
|
1012 | 1012 | if (self.ui.configbool('devel', 'all-warnings') or |
|
1013 | 1013 | self.ui.configbool('devel', 'check-locks')): |
|
1014 | 1014 | if util.safehasattr(self.svfs, 'vfs'): # this is filtervfs |
|
1015 | 1015 | self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit) |
|
1016 | 1016 | else: # standard vfs |
|
1017 | 1017 | self.svfs.audit = self._getsvfsward(self.svfs.audit) |
|
1018 | 1018 | |
|
1019 | 1019 | self._dirstatevalidatewarned = False |
|
1020 | 1020 | |
|
1021 | 1021 | self._branchcaches = branchmap.BranchMapCache() |
|
1022 | 1022 | self._revbranchcache = None |
|
1023 | 1023 | self._filterpats = {} |
|
1024 | 1024 | self._datafilters = {} |
|
1025 | 1025 | self._transref = self._lockref = self._wlockref = None |
|
1026 | 1026 | |
|
1027 | 1027 | # A cache for various files under .hg/ that tracks file changes, |
|
1028 | 1028 | # (used by the filecache decorator) |
|
1029 | 1029 | # |
|
1030 | 1030 | # Maps a property name to its util.filecacheentry |
|
1031 | 1031 | self._filecache = {} |
|
1032 | 1032 | |
|
1033 | 1033 | # hold sets of revision to be filtered |
|
1034 | 1034 | # should be cleared when something might have changed the filter value: |
|
1035 | 1035 | # - new changesets, |
|
1036 | 1036 | # - phase change, |
|
1037 | 1037 | # - new obsolescence marker, |
|
1038 | 1038 | # - working directory parent change, |
|
1039 | 1039 | # - bookmark changes |
|
1040 | 1040 | self.filteredrevcache = {} |
|
1041 | 1041 | |
|
1042 | 1042 | # post-dirstate-status hooks |
|
1043 | 1043 | self._postdsstatus = [] |
|
1044 | 1044 | |
|
1045 | 1045 | # generic mapping between names and nodes |
|
1046 | 1046 | self.names = namespaces.namespaces() |
|
1047 | 1047 | |
|
1048 | 1048 | # Key to signature value. |
|
1049 | 1049 | self._sparsesignaturecache = {} |
|
1050 | 1050 | # Signature to cached matcher instance. |
|
1051 | 1051 | self._sparsematchercache = {} |
|
1052 | 1052 | |
|
1053 | 1053 | def _getvfsward(self, origfunc): |
|
1054 | 1054 | """build a ward for self.vfs""" |
|
1055 | 1055 | rref = weakref.ref(self) |
|
1056 | 1056 | def checkvfs(path, mode=None): |
|
1057 | 1057 | ret = origfunc(path, mode=mode) |
|
1058 | 1058 | repo = rref() |
|
1059 | 1059 | if (repo is None |
|
1060 | 1060 | or not util.safehasattr(repo, '_wlockref') |
|
1061 | 1061 | or not util.safehasattr(repo, '_lockref')): |
|
1062 | 1062 | return |
|
1063 | 1063 | if mode in (None, 'r', 'rb'): |
|
1064 | 1064 | return |
|
1065 | 1065 | if path.startswith(repo.path): |
|
1066 | 1066 | # truncate name relative to the repository (.hg) |
|
1067 | 1067 | path = path[len(repo.path) + 1:] |
|
1068 | 1068 | if path.startswith('cache/'): |
|
1069 | 1069 | msg = 'accessing cache with vfs instead of cachevfs: "%s"' |
|
1070 | 1070 | repo.ui.develwarn(msg % path, stacklevel=3, config="cache-vfs") |
|
1071 | 1071 | if path.startswith('journal.') or path.startswith('undo.'): |
|
1072 | 1072 | # journal is covered by 'lock' |
|
1073 | 1073 | if repo._currentlock(repo._lockref) is None: |
|
1074 | 1074 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
1075 | 1075 | stacklevel=3, config='check-locks') |
|
1076 | 1076 | elif repo._currentlock(repo._wlockref) is None: |
|
1077 | 1077 | # rest of vfs files are covered by 'wlock' |
|
1078 | 1078 | # |
|
1079 | 1079 | # exclude special files |
|
1080 | 1080 | for prefix in self._wlockfreeprefix: |
|
1081 | 1081 | if path.startswith(prefix): |
|
1082 | 1082 | return |
|
1083 | 1083 | repo.ui.develwarn('write with no wlock: "%s"' % path, |
|
1084 | 1084 | stacklevel=3, config='check-locks') |
|
1085 | 1085 | return ret |
|
1086 | 1086 | return checkvfs |
|
1087 | 1087 | |
|
1088 | 1088 | def _getsvfsward(self, origfunc): |
|
1089 | 1089 | """build a ward for self.svfs""" |
|
1090 | 1090 | rref = weakref.ref(self) |
|
1091 | 1091 | def checksvfs(path, mode=None): |
|
1092 | 1092 | ret = origfunc(path, mode=mode) |
|
1093 | 1093 | repo = rref() |
|
1094 | 1094 | if repo is None or not util.safehasattr(repo, '_lockref'): |
|
1095 | 1095 | return |
|
1096 | 1096 | if mode in (None, 'r', 'rb'): |
|
1097 | 1097 | return |
|
1098 | 1098 | if path.startswith(repo.sharedpath): |
|
1099 | 1099 | # truncate name relative to the repository (.hg) |
|
1100 | 1100 | path = path[len(repo.sharedpath) + 1:] |
|
1101 | 1101 | if repo._currentlock(repo._lockref) is None: |
|
1102 | 1102 | repo.ui.develwarn('write with no lock: "%s"' % path, |
|
1103 | 1103 | stacklevel=4) |
|
1104 | 1104 | return ret |
|
1105 | 1105 | return checksvfs |
|
1106 | 1106 | |
|
1107 | 1107 | def close(self): |
|
1108 | 1108 | self._writecaches() |
|
1109 | 1109 | |
|
1110 | 1110 | def _writecaches(self): |
|
1111 | 1111 | if self._revbranchcache: |
|
1112 | 1112 | self._revbranchcache.write() |
|
1113 | 1113 | |
|
1114 | 1114 | def _restrictcapabilities(self, caps): |
|
1115 | 1115 | if self.ui.configbool('experimental', 'bundle2-advertise'): |
|
1116 | 1116 | caps = set(caps) |
|
1117 | 1117 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self, |
|
1118 | 1118 | role='client')) |
|
1119 | 1119 | caps.add('bundle2=' + urlreq.quote(capsblob)) |
|
1120 | 1120 | return caps |
|
1121 | 1121 | |
|
1122 | 1122 | def _writerequirements(self): |
|
1123 | 1123 | scmutil.writerequires(self.vfs, self.requirements) |
|
1124 | 1124 | |
|
1125 | 1125 | # Don't cache auditor/nofsauditor, or you'll end up with reference cycle: |
|
1126 | 1126 | # self -> auditor -> self._checknested -> self |
|
1127 | 1127 | |
|
1128 | 1128 | @property |
|
1129 | 1129 | def auditor(self): |
|
1130 | 1130 | # This is only used by context.workingctx.match in order to |
|
1131 | 1131 | # detect files in subrepos. |
|
1132 | 1132 | return pathutil.pathauditor(self.root, callback=self._checknested) |
|
1133 | 1133 | |
|
1134 | 1134 | @property |
|
1135 | 1135 | def nofsauditor(self): |
|
1136 | 1136 | # This is only used by context.basectx.match in order to detect |
|
1137 | 1137 | # files in subrepos. |
|
1138 | 1138 | return pathutil.pathauditor(self.root, callback=self._checknested, |
|
1139 | 1139 | realfs=False, cached=True) |
|
1140 | 1140 | |
|
1141 | 1141 | def _checknested(self, path): |
|
1142 | 1142 | """Determine if path is a legal nested repository.""" |
|
1143 | 1143 | if not path.startswith(self.root): |
|
1144 | 1144 | return False |
|
1145 | 1145 | subpath = path[len(self.root) + 1:] |
|
1146 | 1146 | normsubpath = util.pconvert(subpath) |
|
1147 | 1147 | |
|
1148 | 1148 | # XXX: Checking against the current working copy is wrong in |
|
1149 | 1149 | # the sense that it can reject things like |
|
1150 | 1150 | # |
|
1151 | 1151 | # $ hg cat -r 10 sub/x.txt |
|
1152 | 1152 | # |
|
1153 | 1153 | # if sub/ is no longer a subrepository in the working copy |
|
1154 | 1154 | # parent revision. |
|
1155 | 1155 | # |
|
1156 | 1156 | # However, it can of course also allow things that would have |
|
1157 | 1157 | # been rejected before, such as the above cat command if sub/ |
|
1158 | 1158 | # is a subrepository now, but was a normal directory before. |
|
1159 | 1159 | # The old path auditor would have rejected by mistake since it |
|
1160 | 1160 | # panics when it sees sub/.hg/. |
|
1161 | 1161 | # |
|
1162 | 1162 | # All in all, checking against the working copy seems sensible |
|
1163 | 1163 | # since we want to prevent access to nested repositories on |
|
1164 | 1164 | # the filesystem *now*. |
|
1165 | 1165 | ctx = self[None] |
|
1166 | 1166 | parts = util.splitpath(subpath) |
|
1167 | 1167 | while parts: |
|
1168 | 1168 | prefix = '/'.join(parts) |
|
1169 | 1169 | if prefix in ctx.substate: |
|
1170 | 1170 | if prefix == normsubpath: |
|
1171 | 1171 | return True |
|
1172 | 1172 | else: |
|
1173 | 1173 | sub = ctx.sub(prefix) |
|
1174 | 1174 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
1175 | 1175 | else: |
|
1176 | 1176 | parts.pop() |
|
1177 | 1177 | return False |
|
1178 | 1178 | |
|
1179 | 1179 | def peer(self): |
|
1180 | 1180 | return localpeer(self) # not cached to avoid reference cycle |
|
1181 | 1181 | |
|
1182 | 1182 | def unfiltered(self): |
|
1183 | 1183 | """Return unfiltered version of the repository |
|
1184 | 1184 | |
|
1185 | 1185 | Intended to be overwritten by filtered repo.""" |
|
1186 | 1186 | return self |
|
1187 | 1187 | |
|
1188 | 1188 | def filtered(self, name, visibilityexceptions=None): |
|
1189 | 1189 | """Return a filtered version of a repository |
|
1190 | 1190 | |
|
1191 | 1191 | The `name` parameter is the identifier of the requested view. This |
|
1192 | 1192 | will return a repoview object set "exactly" to the specified view. |
|
1193 | 1193 | |
|
1194 | 1194 | This function does not apply recursive filtering to a repository. For |
|
1195 | 1195 | example calling `repo.filtered("served")` will return a repoview using |
|
1196 | 1196 | the "served" view, regardless of the initial view used by `repo`. |
|
1197 | 1197 | |
|
1198 | 1198 | In other word, there is always only one level of `repoview` "filtering". |
|
1199 | 1199 | """ |
|
1200 | 1200 | cls = repoview.newtype(self.unfiltered().__class__) |
|
1201 | 1201 | return cls(self, name, visibilityexceptions) |
|
1202 | 1202 | |
|
1203 | 1203 | @repofilecache('bookmarks', 'bookmarks.current') |
|
1204 | 1204 | def _bookmarks(self): |
|
1205 | 1205 | return bookmarks.bmstore(self) |
|
1206 | 1206 | |
|
1207 | 1207 | @property |
|
1208 | 1208 | def _activebookmark(self): |
|
1209 | 1209 | return self._bookmarks.active |
|
1210 | 1210 | |
|
1211 | 1211 | # _phasesets depend on changelog. what we need is to call |
|
1212 | 1212 | # _phasecache.invalidate() if '00changelog.i' was changed, but it |
|
1213 | 1213 | # can't be easily expressed in filecache mechanism. |
|
1214 | 1214 | @storecache('phaseroots', '00changelog.i') |
|
1215 | 1215 | def _phasecache(self): |
|
1216 | 1216 | return phases.phasecache(self, self._phasedefaults) |
|
1217 | 1217 | |
|
1218 | 1218 | @storecache('obsstore') |
|
1219 | 1219 | def obsstore(self): |
|
1220 | 1220 | return obsolete.makestore(self.ui, self) |
|
1221 | 1221 | |
|
1222 | 1222 | @storecache('00changelog.i') |
|
1223 | 1223 | def changelog(self): |
|
1224 | 1224 | return changelog.changelog(self.svfs, |
|
1225 | 1225 | trypending=txnutil.mayhavepending(self.root)) |
|
1226 | 1226 | |
|
1227 | 1227 | @storecache('00manifest.i') |
|
1228 | 1228 | def manifestlog(self): |
|
1229 | 1229 | rootstore = manifest.manifestrevlog(self.svfs) |
|
1230 | 1230 | return manifest.manifestlog(self.svfs, self, rootstore, |
|
1231 | 1231 | self._storenarrowmatch) |
|
1232 | 1232 | |
|
1233 | 1233 | @repofilecache('dirstate') |
|
1234 | 1234 | def dirstate(self): |
|
1235 | 1235 | return self._makedirstate() |
|
1236 | 1236 | |
|
1237 | 1237 | def _makedirstate(self): |
|
1238 | 1238 | """Extension point for wrapping the dirstate per-repo.""" |
|
1239 | 1239 | sparsematchfn = lambda: sparse.matcher(self) |
|
1240 | 1240 | |
|
1241 | 1241 | return dirstate.dirstate(self.vfs, self.ui, self.root, |
|
1242 | 1242 | self._dirstatevalidate, sparsematchfn) |
|
1243 | 1243 | |
|
1244 | 1244 | def _dirstatevalidate(self, node): |
|
1245 | 1245 | try: |
|
1246 | 1246 | self.changelog.rev(node) |
|
1247 | 1247 | return node |
|
1248 | 1248 | except error.LookupError: |
|
1249 | 1249 | if not self._dirstatevalidatewarned: |
|
1250 | 1250 | self._dirstatevalidatewarned = True |
|
1251 | 1251 | self.ui.warn(_("warning: ignoring unknown" |
|
1252 | 1252 | " working parent %s!\n") % short(node)) |
|
1253 | 1253 | return nullid |
|
1254 | 1254 | |
|
1255 | 1255 | @storecache(narrowspec.FILENAME) |
|
1256 | 1256 | def narrowpats(self): |
|
1257 | 1257 | """matcher patterns for this repository's narrowspec |
|
1258 | 1258 | |
|
1259 | 1259 | A tuple of (includes, excludes). |
|
1260 | 1260 | """ |
|
1261 | 1261 | return narrowspec.load(self) |
|
1262 | 1262 | |
|
1263 | 1263 | @storecache(narrowspec.FILENAME) |
|
1264 | 1264 | def _storenarrowmatch(self): |
|
1265 | 1265 | if repository.NARROW_REQUIREMENT not in self.requirements: |
|
1266 | 1266 | return matchmod.always() |
|
1267 | 1267 | include, exclude = self.narrowpats |
|
1268 | 1268 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1269 | 1269 | |
|
1270 | 1270 | @storecache(narrowspec.FILENAME) |
|
1271 | 1271 | def _narrowmatch(self): |
|
1272 | 1272 | if repository.NARROW_REQUIREMENT not in self.requirements: |
|
1273 | 1273 | return matchmod.always() |
|
1274 | 1274 | narrowspec.checkworkingcopynarrowspec(self) |
|
1275 | 1275 | include, exclude = self.narrowpats |
|
1276 | 1276 | return narrowspec.match(self.root, include=include, exclude=exclude) |
|
1277 | 1277 | |
|
1278 | 1278 | def narrowmatch(self, match=None, includeexact=False): |
|
1279 | 1279 | """matcher corresponding the the repo's narrowspec |
|
1280 | 1280 | |
|
1281 | 1281 | If `match` is given, then that will be intersected with the narrow |
|
1282 | 1282 | matcher. |
|
1283 | 1283 | |
|
1284 | 1284 | If `includeexact` is True, then any exact matches from `match` will |
|
1285 | 1285 | be included even if they're outside the narrowspec. |
|
1286 | 1286 | """ |
|
1287 | 1287 | if match: |
|
1288 | 1288 | if includeexact and not self._narrowmatch.always(): |
|
1289 | 1289 | # do not exclude explicitly-specified paths so that they can |
|
1290 | 1290 | # be warned later on |
|
1291 | 1291 | em = matchmod.exact(match.files()) |
|
1292 | 1292 | nm = matchmod.unionmatcher([self._narrowmatch, em]) |
|
1293 | 1293 | return matchmod.intersectmatchers(match, nm) |
|
1294 | 1294 | return matchmod.intersectmatchers(match, self._narrowmatch) |
|
1295 | 1295 | return self._narrowmatch |
|
1296 | 1296 | |
|
1297 | 1297 | def setnarrowpats(self, newincludes, newexcludes): |
|
1298 | 1298 | narrowspec.save(self, newincludes, newexcludes) |
|
1299 | 1299 | self.invalidate(clearfilecache=True) |
|
1300 | 1300 | |
|
1301 | 1301 | def __getitem__(self, changeid): |
|
1302 | 1302 | if changeid is None: |
|
1303 | 1303 | return context.workingctx(self) |
|
1304 | 1304 | if isinstance(changeid, context.basectx): |
|
1305 | 1305 | return changeid |
|
1306 | 1306 | if isinstance(changeid, slice): |
|
1307 | 1307 | # wdirrev isn't contiguous so the slice shouldn't include it |
|
1308 | 1308 | return [self[i] |
|
1309 | 1309 | for i in pycompat.xrange(*changeid.indices(len(self))) |
|
1310 | 1310 | if i not in self.changelog.filteredrevs] |
|
1311 | 1311 | try: |
|
1312 | 1312 | if isinstance(changeid, int): |
|
1313 | 1313 | node = self.changelog.node(changeid) |
|
1314 | 1314 | rev = changeid |
|
1315 | 1315 | elif changeid == 'null': |
|
1316 | 1316 | node = nullid |
|
1317 | 1317 | rev = nullrev |
|
1318 | 1318 | elif changeid == 'tip': |
|
1319 | 1319 | node = self.changelog.tip() |
|
1320 | 1320 | rev = self.changelog.rev(node) |
|
1321 | 1321 | elif changeid == '.': |
|
1322 | 1322 | # this is a hack to delay/avoid loading obsmarkers |
|
1323 | 1323 | # when we know that '.' won't be hidden |
|
1324 | 1324 | node = self.dirstate.p1() |
|
1325 | 1325 | rev = self.unfiltered().changelog.rev(node) |
|
1326 | 1326 | elif len(changeid) == 20: |
|
1327 | 1327 | try: |
|
1328 | 1328 | node = changeid |
|
1329 | 1329 | rev = self.changelog.rev(changeid) |
|
1330 | 1330 | except error.FilteredLookupError: |
|
1331 | 1331 | changeid = hex(changeid) # for the error message |
|
1332 | 1332 | raise |
|
1333 | 1333 | except LookupError: |
|
1334 | 1334 | # check if it might have come from damaged dirstate |
|
1335 | 1335 | # |
|
1336 | 1336 | # XXX we could avoid the unfiltered if we had a recognizable |
|
1337 | 1337 | # exception for filtered changeset access |
|
1338 | 1338 | if (self.local() |
|
1339 | 1339 | and changeid in self.unfiltered().dirstate.parents()): |
|
1340 | 1340 | msg = _("working directory has unknown parent '%s'!") |
|
1341 | 1341 | raise error.Abort(msg % short(changeid)) |
|
1342 | 1342 | changeid = hex(changeid) # for the error message |
|
1343 | 1343 | raise |
|
1344 | 1344 | |
|
1345 | 1345 | elif len(changeid) == 40: |
|
1346 | 1346 | node = bin(changeid) |
|
1347 | 1347 | rev = self.changelog.rev(node) |
|
1348 | 1348 | else: |
|
1349 | 1349 | raise error.ProgrammingError( |
|
1350 | 1350 | "unsupported changeid '%s' of type %s" % |
|
1351 | 1351 | (changeid, type(changeid))) |
|
1352 | 1352 | |
|
1353 | 1353 | return context.changectx(self, rev, node) |
|
1354 | 1354 | |
|
1355 | 1355 | except (error.FilteredIndexError, error.FilteredLookupError): |
|
1356 | 1356 | raise error.FilteredRepoLookupError(_("filtered revision '%s'") |
|
1357 | 1357 | % pycompat.bytestr(changeid)) |
|
1358 | 1358 | except (IndexError, LookupError): |
|
1359 | 1359 | raise error.RepoLookupError( |
|
1360 | 1360 | _("unknown revision '%s'") % pycompat.bytestr(changeid)) |
|
1361 | 1361 | except error.WdirUnsupported: |
|
1362 | 1362 | return context.workingctx(self) |
|
1363 | 1363 | |
|
1364 | 1364 | def __contains__(self, changeid): |
|
1365 | 1365 | """True if the given changeid exists |
|
1366 | 1366 | |
|
1367 | 1367 | error.AmbiguousPrefixLookupError is raised if an ambiguous node |
|
1368 | 1368 | specified. |
|
1369 | 1369 | """ |
|
1370 | 1370 | try: |
|
1371 | 1371 | self[changeid] |
|
1372 | 1372 | return True |
|
1373 | 1373 | except error.RepoLookupError: |
|
1374 | 1374 | return False |
|
1375 | 1375 | |
|
1376 | 1376 | def __nonzero__(self): |
|
1377 | 1377 | return True |
|
1378 | 1378 | |
|
1379 | 1379 | __bool__ = __nonzero__ |
|
1380 | 1380 | |
|
1381 | 1381 | def __len__(self): |
|
1382 | 1382 | # no need to pay the cost of repoview.changelog |
|
1383 | 1383 | unfi = self.unfiltered() |
|
1384 | 1384 | return len(unfi.changelog) |
|
1385 | 1385 | |
|
1386 | 1386 | def __iter__(self): |
|
1387 | 1387 | return iter(self.changelog) |
|
1388 | 1388 | |
|
1389 | 1389 | def revs(self, expr, *args): |
|
1390 | 1390 | '''Find revisions matching a revset. |
|
1391 | 1391 | |
|
1392 | 1392 | The revset is specified as a string ``expr`` that may contain |
|
1393 | 1393 | %-formatting to escape certain types. See ``revsetlang.formatspec``. |
|
1394 | 1394 | |
|
1395 | 1395 | Revset aliases from the configuration are not expanded. To expand |
|
1396 | 1396 | user aliases, consider calling ``scmutil.revrange()`` or |
|
1397 | 1397 | ``repo.anyrevs([expr], user=True)``. |
|
1398 | 1398 | |
|
1399 | 1399 | Returns a revset.abstractsmartset, which is a list-like interface |
|
1400 | 1400 | that contains integer revisions. |
|
1401 | 1401 | ''' |
|
1402 | 1402 | tree = revsetlang.spectree(expr, *args) |
|
1403 | 1403 | return revset.makematcher(tree)(self) |
|
1404 | 1404 | |
|
1405 | 1405 | def set(self, expr, *args): |
|
1406 | 1406 | '''Find revisions matching a revset and emit changectx instances. |
|
1407 | 1407 | |
|
1408 | 1408 | This is a convenience wrapper around ``revs()`` that iterates the |
|
1409 | 1409 | result and is a generator of changectx instances. |
|
1410 | 1410 | |
|
1411 | 1411 | Revset aliases from the configuration are not expanded. To expand |
|
1412 | 1412 | user aliases, consider calling ``scmutil.revrange()``. |
|
1413 | 1413 | ''' |
|
1414 | 1414 | for r in self.revs(expr, *args): |
|
1415 | 1415 | yield self[r] |
|
1416 | 1416 | |
|
1417 | 1417 | def anyrevs(self, specs, user=False, localalias=None): |
|
1418 | 1418 | '''Find revisions matching one of the given revsets. |
|
1419 | 1419 | |
|
1420 | 1420 | Revset aliases from the configuration are not expanded by default. To |
|
1421 | 1421 | expand user aliases, specify ``user=True``. To provide some local |
|
1422 | 1422 | definitions overriding user aliases, set ``localalias`` to |
|
1423 | 1423 | ``{name: definitionstring}``. |
|
1424 | 1424 | ''' |
|
1425 | 1425 | if user: |
|
1426 | 1426 | m = revset.matchany(self.ui, specs, |
|
1427 | 1427 | lookup=revset.lookupfn(self), |
|
1428 | 1428 | localalias=localalias) |
|
1429 | 1429 | else: |
|
1430 | 1430 | m = revset.matchany(None, specs, localalias=localalias) |
|
1431 | 1431 | return m(self) |
|
1432 | 1432 | |
|
1433 | 1433 | def url(self): |
|
1434 | 1434 | return 'file:' + self.root |
|
1435 | 1435 | |
|
1436 | 1436 | def hook(self, name, throw=False, **args): |
|
1437 | 1437 | """Call a hook, passing this repo instance. |
|
1438 | 1438 | |
|
1439 | 1439 | This a convenience method to aid invoking hooks. Extensions likely |
|
1440 | 1440 | won't call this unless they have registered a custom hook or are |
|
1441 | 1441 | replacing code that is expected to call a hook. |
|
1442 | 1442 | """ |
|
1443 | 1443 | return hook.hook(self.ui, self, name, throw, **args) |
|
1444 | 1444 | |
|
1445 | 1445 | @filteredpropertycache |
|
1446 | 1446 | def _tagscache(self): |
|
1447 | 1447 | '''Returns a tagscache object that contains various tags related |
|
1448 | 1448 | caches.''' |
|
1449 | 1449 | |
|
1450 | 1450 | # This simplifies its cache management by having one decorated |
|
1451 | 1451 | # function (this one) and the rest simply fetch things from it. |
|
1452 | 1452 | class tagscache(object): |
|
1453 | 1453 | def __init__(self): |
|
1454 | 1454 | # These two define the set of tags for this repository. tags |
|
1455 | 1455 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
1456 | 1456 | # 'local'. (Global tags are defined by .hgtags across all |
|
1457 | 1457 | # heads, and local tags are defined in .hg/localtags.) |
|
1458 | 1458 | # They constitute the in-memory cache of tags. |
|
1459 | 1459 | self.tags = self.tagtypes = None |
|
1460 | 1460 | |
|
1461 | 1461 | self.nodetagscache = self.tagslist = None |
|
1462 | 1462 | |
|
1463 | 1463 | cache = tagscache() |
|
1464 | 1464 | cache.tags, cache.tagtypes = self._findtags() |
|
1465 | 1465 | |
|
1466 | 1466 | return cache |
|
1467 | 1467 | |
|
1468 | 1468 | def tags(self): |
|
1469 | 1469 | '''return a mapping of tag to node''' |
|
1470 | 1470 | t = {} |
|
1471 | 1471 | if self.changelog.filteredrevs: |
|
1472 | 1472 | tags, tt = self._findtags() |
|
1473 | 1473 | else: |
|
1474 | 1474 | tags = self._tagscache.tags |
|
1475 | 1475 | rev = self.changelog.rev |
|
1476 | 1476 | for k, v in tags.iteritems(): |
|
1477 | 1477 | try: |
|
1478 | 1478 | # ignore tags to unknown nodes |
|
1479 | 1479 | rev(v) |
|
1480 | 1480 | t[k] = v |
|
1481 | 1481 | except (error.LookupError, ValueError): |
|
1482 | 1482 | pass |
|
1483 | 1483 | return t |
|
1484 | 1484 | |
|
1485 | 1485 | def _findtags(self): |
|
1486 | 1486 | '''Do the hard work of finding tags. Return a pair of dicts |
|
1487 | 1487 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
1488 | 1488 | maps tag name to a string like \'global\' or \'local\'. |
|
1489 | 1489 | Subclasses or extensions are free to add their own tags, but |
|
1490 | 1490 | should be aware that the returned dicts will be retained for the |
|
1491 | 1491 | duration of the localrepo object.''' |
|
1492 | 1492 | |
|
1493 | 1493 | # XXX what tagtype should subclasses/extensions use? Currently |
|
1494 | 1494 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
1495 | 1495 | # Should each extension invent its own tag type? Should there |
|
1496 | 1496 | # be one tagtype for all such "virtual" tags? Or is the status |
|
1497 | 1497 | # quo fine? |
|
1498 | 1498 | |
|
1499 | 1499 | |
|
1500 | 1500 | # map tag name to (node, hist) |
|
1501 | 1501 | alltags = tagsmod.findglobaltags(self.ui, self) |
|
1502 | 1502 | # map tag name to tag type |
|
1503 | 1503 | tagtypes = dict((tag, 'global') for tag in alltags) |
|
1504 | 1504 | |
|
1505 | 1505 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
1506 | 1506 | |
|
1507 | 1507 | # Build the return dicts. Have to re-encode tag names because |
|
1508 | 1508 | # the tags module always uses UTF-8 (in order not to lose info |
|
1509 | 1509 | # writing to the cache), but the rest of Mercurial wants them in |
|
1510 | 1510 | # local encoding. |
|
1511 | 1511 | tags = {} |
|
1512 | 1512 | for (name, (node, hist)) in alltags.iteritems(): |
|
1513 | 1513 | if node != nullid: |
|
1514 | 1514 | tags[encoding.tolocal(name)] = node |
|
1515 | 1515 | tags['tip'] = self.changelog.tip() |
|
1516 | 1516 | tagtypes = dict([(encoding.tolocal(name), value) |
|
1517 | 1517 | for (name, value) in tagtypes.iteritems()]) |
|
1518 | 1518 | return (tags, tagtypes) |
|
1519 | 1519 | |
|
1520 | 1520 | def tagtype(self, tagname): |
|
1521 | 1521 | ''' |
|
1522 | 1522 | return the type of the given tag. result can be: |
|
1523 | 1523 | |
|
1524 | 1524 | 'local' : a local tag |
|
1525 | 1525 | 'global' : a global tag |
|
1526 | 1526 | None : tag does not exist |
|
1527 | 1527 | ''' |
|
1528 | 1528 | |
|
1529 | 1529 | return self._tagscache.tagtypes.get(tagname) |
|
1530 | 1530 | |
|
1531 | 1531 | def tagslist(self): |
|
1532 | 1532 | '''return a list of tags ordered by revision''' |
|
1533 | 1533 | if not self._tagscache.tagslist: |
|
1534 | 1534 | l = [] |
|
1535 | 1535 | for t, n in self.tags().iteritems(): |
|
1536 | 1536 | l.append((self.changelog.rev(n), t, n)) |
|
1537 | 1537 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
1538 | 1538 | |
|
1539 | 1539 | return self._tagscache.tagslist |
|
1540 | 1540 | |
|
1541 | 1541 | def nodetags(self, node): |
|
1542 | 1542 | '''return the tags associated with a node''' |
|
1543 | 1543 | if not self._tagscache.nodetagscache: |
|
1544 | 1544 | nodetagscache = {} |
|
1545 | 1545 | for t, n in self._tagscache.tags.iteritems(): |
|
1546 | 1546 | nodetagscache.setdefault(n, []).append(t) |
|
1547 | 1547 | for tags in nodetagscache.itervalues(): |
|
1548 | 1548 | tags.sort() |
|
1549 | 1549 | self._tagscache.nodetagscache = nodetagscache |
|
1550 | 1550 | return self._tagscache.nodetagscache.get(node, []) |
|
1551 | 1551 | |
|
1552 | 1552 | def nodebookmarks(self, node): |
|
1553 | 1553 | """return the list of bookmarks pointing to the specified node""" |
|
1554 | 1554 | return self._bookmarks.names(node) |
|
1555 | 1555 | |
|
1556 | 1556 | def branchmap(self): |
|
1557 | 1557 | '''returns a dictionary {branch: [branchheads]} with branchheads |
|
1558 | 1558 | ordered by increasing revision number''' |
|
1559 | 1559 | return self._branchcaches[self] |
|
1560 | 1560 | |
|
1561 | 1561 | @unfilteredmethod |
|
1562 | 1562 | def revbranchcache(self): |
|
1563 | 1563 | if not self._revbranchcache: |
|
1564 | 1564 | self._revbranchcache = branchmap.revbranchcache(self.unfiltered()) |
|
1565 | 1565 | return self._revbranchcache |
|
1566 | 1566 | |
|
1567 | 1567 | def branchtip(self, branch, ignoremissing=False): |
|
1568 | 1568 | '''return the tip node for a given branch |
|
1569 | 1569 | |
|
1570 | 1570 | If ignoremissing is True, then this method will not raise an error. |
|
1571 | 1571 | This is helpful for callers that only expect None for a missing branch |
|
1572 | 1572 | (e.g. namespace). |
|
1573 | 1573 | |
|
1574 | 1574 | ''' |
|
1575 | 1575 | try: |
|
1576 | 1576 | return self.branchmap().branchtip(branch) |
|
1577 | 1577 | except KeyError: |
|
1578 | 1578 | if not ignoremissing: |
|
1579 | 1579 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
1580 | 1580 | else: |
|
1581 | 1581 | pass |
|
1582 | 1582 | |
|
1583 | 1583 | def lookup(self, key): |
|
1584 | 1584 | node = scmutil.revsymbol(self, key).node() |
|
1585 | 1585 | if node is None: |
|
1586 | 1586 | raise error.RepoLookupError(_("unknown revision '%s'") % key) |
|
1587 | 1587 | return node |
|
1588 | 1588 | |
|
1589 | 1589 | def lookupbranch(self, key): |
|
1590 | 1590 | if self.branchmap().hasbranch(key): |
|
1591 | 1591 | return key |
|
1592 | 1592 | |
|
1593 | 1593 | return scmutil.revsymbol(self, key).branch() |
|
1594 | 1594 | |
|
1595 | 1595 | def known(self, nodes): |
|
1596 | 1596 | cl = self.changelog |
|
1597 | 1597 | nm = cl.nodemap |
|
1598 | 1598 | filtered = cl.filteredrevs |
|
1599 | 1599 | result = [] |
|
1600 | 1600 | for n in nodes: |
|
1601 | 1601 | r = nm.get(n) |
|
1602 | 1602 | resp = not (r is None or r in filtered) |
|
1603 | 1603 | result.append(resp) |
|
1604 | 1604 | return result |
|
1605 | 1605 | |
|
1606 | 1606 | def local(self): |
|
1607 | 1607 | return self |
|
1608 | 1608 | |
|
1609 | 1609 | def publishing(self): |
|
1610 | 1610 | # it's safe (and desirable) to trust the publish flag unconditionally |
|
1611 | 1611 | # so that we don't finalize changes shared between users via ssh or nfs |
|
1612 | 1612 | return self.ui.configbool('phases', 'publish', untrusted=True) |
|
1613 | 1613 | |
|
1614 | 1614 | def cancopy(self): |
|
1615 | 1615 | # so statichttprepo's override of local() works |
|
1616 | 1616 | if not self.local(): |
|
1617 | 1617 | return False |
|
1618 | 1618 | if not self.publishing(): |
|
1619 | 1619 | return True |
|
1620 | 1620 | # if publishing we can't copy if there is filtered content |
|
1621 | 1621 | return not self.filtered('visible').changelog.filteredrevs |
|
1622 | 1622 | |
|
1623 | 1623 | def shared(self): |
|
1624 | 1624 | '''the type of shared repository (None if not shared)''' |
|
1625 | 1625 | if self.sharedpath != self.path: |
|
1626 | 1626 | return 'store' |
|
1627 | 1627 | return None |
|
1628 | 1628 | |
|
1629 | 1629 | def wjoin(self, f, *insidef): |
|
1630 | 1630 | return self.vfs.reljoin(self.root, f, *insidef) |
|
1631 | 1631 | |
|
1632 | 1632 | def setparents(self, p1, p2=nullid): |
|
1633 | 1633 | with self.dirstate.parentchange(): |
|
1634 | 1634 | copies = self.dirstate.setparents(p1, p2) |
|
1635 | 1635 | pctx = self[p1] |
|
1636 | 1636 | if copies: |
|
1637 | 1637 | # Adjust copy records, the dirstate cannot do it, it |
|
1638 | 1638 | # requires access to parents manifests. Preserve them |
|
1639 | 1639 | # only for entries added to first parent. |
|
1640 | 1640 | for f in copies: |
|
1641 | 1641 | if f not in pctx and copies[f] in pctx: |
|
1642 | 1642 | self.dirstate.copy(copies[f], f) |
|
1643 | 1643 | if p2 == nullid: |
|
1644 | 1644 | for f, s in sorted(self.dirstate.copies().items()): |
|
1645 | 1645 | if f not in pctx and s not in pctx: |
|
1646 | 1646 | self.dirstate.copy(None, f) |
|
1647 | 1647 | |
|
1648 | 1648 | def filectx(self, path, changeid=None, fileid=None, changectx=None): |
|
1649 | 1649 | """changeid must be a changeset revision, if specified. |
|
1650 | 1650 | fileid can be a file revision or node.""" |
|
1651 | 1651 | return context.filectx(self, path, changeid, fileid, |
|
1652 | 1652 | changectx=changectx) |
|
1653 | 1653 | |
|
1654 | 1654 | def getcwd(self): |
|
1655 | 1655 | return self.dirstate.getcwd() |
|
1656 | 1656 | |
|
1657 | 1657 | def pathto(self, f, cwd=None): |
|
1658 | 1658 | return self.dirstate.pathto(f, cwd) |
|
1659 | 1659 | |
|
1660 | 1660 | def _loadfilter(self, filter): |
|
1661 | 1661 | if filter not in self._filterpats: |
|
1662 | 1662 | l = [] |
|
1663 | 1663 | for pat, cmd in self.ui.configitems(filter): |
|
1664 | 1664 | if cmd == '!': |
|
1665 | 1665 | continue |
|
1666 | 1666 | mf = matchmod.match(self.root, '', [pat]) |
|
1667 | 1667 | fn = None |
|
1668 | 1668 | params = cmd |
|
1669 | 1669 | for name, filterfn in self._datafilters.iteritems(): |
|
1670 | 1670 | if cmd.startswith(name): |
|
1671 | 1671 | fn = filterfn |
|
1672 | 1672 | params = cmd[len(name):].lstrip() |
|
1673 | 1673 | break |
|
1674 | 1674 | if not fn: |
|
1675 | 1675 | fn = lambda s, c, **kwargs: procutil.filter(s, c) |
|
1676 | 1676 | # Wrap old filters not supporting keyword arguments |
|
1677 | 1677 | if not pycompat.getargspec(fn)[2]: |
|
1678 | 1678 | oldfn = fn |
|
1679 | 1679 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
1680 | 1680 | l.append((mf, fn, params)) |
|
1681 | 1681 | self._filterpats[filter] = l |
|
1682 | 1682 | return self._filterpats[filter] |
|
1683 | 1683 | |
|
1684 | 1684 | def _filter(self, filterpats, filename, data): |
|
1685 | 1685 | for mf, fn, cmd in filterpats: |
|
1686 | 1686 | if mf(filename): |
|
1687 | 1687 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
1688 | 1688 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
1689 | 1689 | break |
|
1690 | 1690 | |
|
1691 | 1691 | return data |
|
1692 | 1692 | |
|
1693 | 1693 | @unfilteredpropertycache |
|
1694 | 1694 | def _encodefilterpats(self): |
|
1695 | 1695 | return self._loadfilter('encode') |
|
1696 | 1696 | |
|
1697 | 1697 | @unfilteredpropertycache |
|
1698 | 1698 | def _decodefilterpats(self): |
|
1699 | 1699 | return self._loadfilter('decode') |
|
1700 | 1700 | |
|
1701 | 1701 | def adddatafilter(self, name, filter): |
|
1702 | 1702 | self._datafilters[name] = filter |
|
1703 | 1703 | |
|
1704 | 1704 | def wread(self, filename): |
|
1705 | 1705 | if self.wvfs.islink(filename): |
|
1706 | 1706 | data = self.wvfs.readlink(filename) |
|
1707 | 1707 | else: |
|
1708 | 1708 | data = self.wvfs.read(filename) |
|
1709 | 1709 | return self._filter(self._encodefilterpats, filename, data) |
|
1710 | 1710 | |
|
1711 | 1711 | def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs): |
|
1712 | 1712 | """write ``data`` into ``filename`` in the working directory |
|
1713 | 1713 | |
|
1714 | 1714 | This returns length of written (maybe decoded) data. |
|
1715 | 1715 | """ |
|
1716 | 1716 | data = self._filter(self._decodefilterpats, filename, data) |
|
1717 | 1717 | if 'l' in flags: |
|
1718 | 1718 | self.wvfs.symlink(data, filename) |
|
1719 | 1719 | else: |
|
1720 | 1720 | self.wvfs.write(filename, data, backgroundclose=backgroundclose, |
|
1721 | 1721 | **kwargs) |
|
1722 | 1722 | if 'x' in flags: |
|
1723 | 1723 | self.wvfs.setflags(filename, False, True) |
|
1724 | 1724 | else: |
|
1725 | 1725 | self.wvfs.setflags(filename, False, False) |
|
1726 | 1726 | return len(data) |
|
1727 | 1727 | |
|
1728 | 1728 | def wwritedata(self, filename, data): |
|
1729 | 1729 | return self._filter(self._decodefilterpats, filename, data) |
|
1730 | 1730 | |
|
1731 | 1731 | def currenttransaction(self): |
|
1732 | 1732 | """return the current transaction or None if non exists""" |
|
1733 | 1733 | if self._transref: |
|
1734 | 1734 | tr = self._transref() |
|
1735 | 1735 | else: |
|
1736 | 1736 | tr = None |
|
1737 | 1737 | |
|
1738 | 1738 | if tr and tr.running(): |
|
1739 | 1739 | return tr |
|
1740 | 1740 | return None |
|
1741 | 1741 | |
|
1742 | 1742 | def transaction(self, desc, report=None): |
|
1743 | 1743 | if (self.ui.configbool('devel', 'all-warnings') |
|
1744 | 1744 | or self.ui.configbool('devel', 'check-locks')): |
|
1745 | 1745 | if self._currentlock(self._lockref) is None: |
|
1746 | 1746 | raise error.ProgrammingError('transaction requires locking') |
|
1747 | 1747 | tr = self.currenttransaction() |
|
1748 | 1748 | if tr is not None: |
|
1749 | 1749 | return tr.nest(name=desc) |
|
1750 | 1750 | |
|
1751 | 1751 | # abort here if the journal already exists |
|
1752 | 1752 | if self.svfs.exists("journal"): |
|
1753 | 1753 | raise error.RepoError( |
|
1754 | 1754 | _("abandoned transaction found"), |
|
1755 | 1755 | hint=_("run 'hg recover' to clean up transaction")) |
|
1756 | 1756 | |
|
1757 | 1757 | idbase = "%.40f#%f" % (random.random(), time.time()) |
|
1758 | 1758 | ha = hex(hashlib.sha1(idbase).digest()) |
|
1759 | 1759 | txnid = 'TXN:' + ha |
|
1760 | 1760 | self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid) |
|
1761 | 1761 | |
|
1762 | 1762 | self._writejournal(desc) |
|
1763 | 1763 | renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] |
|
1764 | 1764 | if report: |
|
1765 | 1765 | rp = report |
|
1766 | 1766 | else: |
|
1767 | 1767 | rp = self.ui.warn |
|
1768 | 1768 | vfsmap = {'plain': self.vfs, 'store': self.svfs} # root of .hg/ |
|
1769 | 1769 | # we must avoid cyclic reference between repo and transaction. |
|
1770 | 1770 | reporef = weakref.ref(self) |
|
1771 | 1771 | # Code to track tag movement |
|
1772 | 1772 | # |
|
1773 | 1773 | # Since tags are all handled as file content, it is actually quite hard |
|
1774 | 1774 | # to track these movement from a code perspective. So we fallback to a |
|
1775 | 1775 | # tracking at the repository level. One could envision to track changes |
|
1776 | 1776 | # to the '.hgtags' file through changegroup apply but that fails to |
|
1777 | 1777 | # cope with case where transaction expose new heads without changegroup |
|
1778 | 1778 | # being involved (eg: phase movement). |
|
1779 | 1779 | # |
|
1780 | 1780 | # For now, We gate the feature behind a flag since this likely comes |
|
1781 | 1781 | # with performance impacts. The current code run more often than needed |
|
1782 | 1782 | # and do not use caches as much as it could. The current focus is on |
|
1783 | 1783 | # the behavior of the feature so we disable it by default. The flag |
|
1784 | 1784 | # will be removed when we are happy with the performance impact. |
|
1785 | 1785 | # |
|
1786 | 1786 | # Once this feature is no longer experimental move the following |
|
1787 | 1787 | # documentation to the appropriate help section: |
|
1788 | 1788 | # |
|
1789 | 1789 | # The ``HG_TAG_MOVED`` variable will be set if the transaction touched |
|
1790 | 1790 | # tags (new or changed or deleted tags). In addition the details of |
|
1791 | 1791 | # these changes are made available in a file at: |
|
1792 | 1792 | # ``REPOROOT/.hg/changes/tags.changes``. |
|
1793 | 1793 | # Make sure you check for HG_TAG_MOVED before reading that file as it |
|
1794 | 1794 | # might exist from a previous transaction even if no tag were touched |
|
1795 | 1795 | # in this one. Changes are recorded in a line base format:: |
|
1796 | 1796 | # |
|
1797 | 1797 | # <action> <hex-node> <tag-name>\n |
|
1798 | 1798 | # |
|
1799 | 1799 | # Actions are defined as follow: |
|
1800 | 1800 | # "-R": tag is removed, |
|
1801 | 1801 | # "+A": tag is added, |
|
1802 | 1802 | # "-M": tag is moved (old value), |
|
1803 | 1803 | # "+M": tag is moved (new value), |
|
1804 | 1804 | tracktags = lambda x: None |
|
1805 | 1805 | # experimental config: experimental.hook-track-tags |
|
1806 | 1806 | shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags') |
|
1807 | 1807 | if desc != 'strip' and shouldtracktags: |
|
1808 | 1808 | oldheads = self.changelog.headrevs() |
|
1809 | 1809 | def tracktags(tr2): |
|
1810 | 1810 | repo = reporef() |
|
1811 | 1811 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) |
|
1812 | 1812 | newheads = repo.changelog.headrevs() |
|
1813 | 1813 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) |
|
1814 | 1814 | # notes: we compare lists here. |
|
1815 | 1815 | # As we do it only once buiding set would not be cheaper |
|
1816 | 1816 | changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes) |
|
1817 | 1817 | if changes: |
|
1818 | 1818 | tr2.hookargs['tag_moved'] = '1' |
|
1819 | 1819 | with repo.vfs('changes/tags.changes', 'w', |
|
1820 | 1820 | atomictemp=True) as changesfile: |
|
1821 | 1821 | # note: we do not register the file to the transaction |
|
1822 | 1822 | # because we needs it to still exist on the transaction |
|
1823 | 1823 | # is close (for txnclose hooks) |
|
1824 | 1824 | tagsmod.writediff(changesfile, changes) |
|
1825 | 1825 | def validate(tr2): |
|
1826 | 1826 | """will run pre-closing hooks""" |
|
1827 | 1827 | # XXX the transaction API is a bit lacking here so we take a hacky |
|
1828 | 1828 | # path for now |
|
1829 | 1829 | # |
|
1830 | 1830 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' |
|
1831 | 1831 | # dict is copied before these run. In addition we needs the data |
|
1832 | 1832 | # available to in memory hooks too. |
|
1833 | 1833 | # |
|
1834 | 1834 | # Moreover, we also need to make sure this runs before txnclose |
|
1835 | 1835 | # hooks and there is no "pending" mechanism that would execute |
|
1836 | 1836 | # logic only if hooks are about to run. |
|
1837 | 1837 | # |
|
1838 | 1838 | # Fixing this limitation of the transaction is also needed to track |
|
1839 | 1839 | # other families of changes (bookmarks, phases, obsolescence). |
|
1840 | 1840 | # |
|
1841 | 1841 | # This will have to be fixed before we remove the experimental |
|
1842 | 1842 | # gating. |
|
1843 | 1843 | tracktags(tr2) |
|
1844 | 1844 | repo = reporef() |
|
1845 | 1845 | if repo.ui.configbool('experimental', 'single-head-per-branch'): |
|
1846 | 1846 | scmutil.enforcesinglehead(repo, tr2, desc) |
|
1847 | 1847 | if hook.hashook(repo.ui, 'pretxnclose-bookmark'): |
|
1848 | 1848 | for name, (old, new) in sorted(tr.changes['bookmarks'].items()): |
|
1849 | 1849 | args = tr.hookargs.copy() |
|
1850 | 1850 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1851 | 1851 | repo.hook('pretxnclose-bookmark', throw=True, |
|
1852 | 1852 | **pycompat.strkwargs(args)) |
|
1853 | 1853 | if hook.hashook(repo.ui, 'pretxnclose-phase'): |
|
1854 | 1854 | cl = repo.unfiltered().changelog |
|
1855 | 1855 | for rev, (old, new) in tr.changes['phases'].items(): |
|
1856 | 1856 | args = tr.hookargs.copy() |
|
1857 | 1857 | node = hex(cl.node(rev)) |
|
1858 | 1858 | args.update(phases.preparehookargs(node, old, new)) |
|
1859 | 1859 | repo.hook('pretxnclose-phase', throw=True, |
|
1860 | 1860 | **pycompat.strkwargs(args)) |
|
1861 | 1861 | |
|
1862 | 1862 | repo.hook('pretxnclose', throw=True, |
|
1863 | 1863 | **pycompat.strkwargs(tr.hookargs)) |
|
1864 | 1864 | def releasefn(tr, success): |
|
1865 | 1865 | repo = reporef() |
|
1866 | 1866 | if success: |
|
1867 | 1867 | # this should be explicitly invoked here, because |
|
1868 | 1868 | # in-memory changes aren't written out at closing |
|
1869 | 1869 | # transaction, if tr.addfilegenerator (via |
|
1870 | 1870 | # dirstate.write or so) isn't invoked while |
|
1871 | 1871 | # transaction running |
|
1872 | 1872 | repo.dirstate.write(None) |
|
1873 | 1873 | else: |
|
1874 | 1874 | # discard all changes (including ones already written |
|
1875 | 1875 | # out) in this transaction |
|
1876 | 1876 | narrowspec.restorebackup(self, 'journal.narrowspec') |
|
1877 | 1877 | narrowspec.restorewcbackup(self, 'journal.narrowspec.dirstate') |
|
1878 | 1878 | repo.dirstate.restorebackup(None, 'journal.dirstate') |
|
1879 | 1879 | |
|
1880 | 1880 | repo.invalidate(clearfilecache=True) |
|
1881 | 1881 | |
|
1882 | 1882 | tr = transaction.transaction(rp, self.svfs, vfsmap, |
|
1883 | 1883 | "journal", |
|
1884 | 1884 | "undo", |
|
1885 | 1885 | aftertrans(renames), |
|
1886 | 1886 | self.store.createmode, |
|
1887 | 1887 | validator=validate, |
|
1888 | 1888 | releasefn=releasefn, |
|
1889 | 1889 | checkambigfiles=_cachedfiles, |
|
1890 | 1890 | name=desc) |
|
1891 | 1891 | tr.changes['origrepolen'] = len(self) |
|
1892 | 1892 | tr.changes['obsmarkers'] = set() |
|
1893 | 1893 | tr.changes['phases'] = {} |
|
1894 | 1894 | tr.changes['bookmarks'] = {} |
|
1895 | 1895 | |
|
1896 | 1896 | tr.hookargs['txnid'] = txnid |
|
1897 | 1897 | tr.hookargs['txnname'] = desc |
|
1898 | 1898 | # note: writing the fncache only during finalize mean that the file is |
|
1899 | 1899 | # outdated when running hooks. As fncache is used for streaming clone, |
|
1900 | 1900 | # this is not expected to break anything that happen during the hooks. |
|
1901 | 1901 | tr.addfinalize('flush-fncache', self.store.write) |
|
1902 | 1902 | def txnclosehook(tr2): |
|
1903 | 1903 | """To be run if transaction is successful, will schedule a hook run |
|
1904 | 1904 | """ |
|
1905 | 1905 | # Don't reference tr2 in hook() so we don't hold a reference. |
|
1906 | 1906 | # This reduces memory consumption when there are multiple |
|
1907 | 1907 | # transactions per lock. This can likely go away if issue5045 |
|
1908 | 1908 | # fixes the function accumulation. |
|
1909 | 1909 | hookargs = tr2.hookargs |
|
1910 | 1910 | |
|
1911 | 1911 | def hookfunc(): |
|
1912 | 1912 | repo = reporef() |
|
1913 | 1913 | if hook.hashook(repo.ui, 'txnclose-bookmark'): |
|
1914 | 1914 | bmchanges = sorted(tr.changes['bookmarks'].items()) |
|
1915 | 1915 | for name, (old, new) in bmchanges: |
|
1916 | 1916 | args = tr.hookargs.copy() |
|
1917 | 1917 | args.update(bookmarks.preparehookargs(name, old, new)) |
|
1918 | 1918 | repo.hook('txnclose-bookmark', throw=False, |
|
1919 | 1919 | **pycompat.strkwargs(args)) |
|
1920 | 1920 | |
|
1921 | 1921 | if hook.hashook(repo.ui, 'txnclose-phase'): |
|
1922 | 1922 | cl = repo.unfiltered().changelog |
|
1923 | 1923 | phasemv = sorted(tr.changes['phases'].items()) |
|
1924 | 1924 | for rev, (old, new) in phasemv: |
|
1925 | 1925 | args = tr.hookargs.copy() |
|
1926 | 1926 | node = hex(cl.node(rev)) |
|
1927 | 1927 | args.update(phases.preparehookargs(node, old, new)) |
|
1928 | 1928 | repo.hook('txnclose-phase', throw=False, |
|
1929 | 1929 | **pycompat.strkwargs(args)) |
|
1930 | 1930 | |
|
1931 | 1931 | repo.hook('txnclose', throw=False, |
|
1932 | 1932 | **pycompat.strkwargs(hookargs)) |
|
1933 | 1933 | reporef()._afterlock(hookfunc) |
|
1934 | 1934 | tr.addfinalize('txnclose-hook', txnclosehook) |
|
1935 | 1935 | # Include a leading "-" to make it happen before the transaction summary |
|
1936 | 1936 | # reports registered via scmutil.registersummarycallback() whose names |
|
1937 | 1937 | # are 00-txnreport etc. That way, the caches will be warm when the |
|
1938 | 1938 | # callbacks run. |
|
1939 | 1939 | tr.addpostclose('-warm-cache', self._buildcacheupdater(tr)) |
|
1940 | 1940 | def txnaborthook(tr2): |
|
1941 | 1941 | """To be run if transaction is aborted |
|
1942 | 1942 | """ |
|
1943 | 1943 | reporef().hook('txnabort', throw=False, |
|
1944 | 1944 | **pycompat.strkwargs(tr2.hookargs)) |
|
1945 | 1945 | tr.addabort('txnabort-hook', txnaborthook) |
|
1946 | 1946 | # avoid eager cache invalidation. in-memory data should be identical |
|
1947 | 1947 | # to stored data if transaction has no error. |
|
1948 | 1948 | tr.addpostclose('refresh-filecachestats', self._refreshfilecachestats) |
|
1949 | 1949 | self._transref = weakref.ref(tr) |
|
1950 | 1950 | scmutil.registersummarycallback(self, tr, desc) |
|
1951 | 1951 | return tr |
|
1952 | 1952 | |
|
1953 | 1953 | def _journalfiles(self): |
|
1954 | 1954 | return ((self.svfs, 'journal'), |
|
1955 | 1955 | (self.svfs, 'journal.narrowspec'), |
|
1956 | 1956 | (self.vfs, 'journal.narrowspec.dirstate'), |
|
1957 | 1957 | (self.vfs, 'journal.dirstate'), |
|
1958 | 1958 | (self.vfs, 'journal.branch'), |
|
1959 | 1959 | (self.vfs, 'journal.desc'), |
|
1960 | 1960 | (self.vfs, 'journal.bookmarks'), |
|
1961 | 1961 | (self.svfs, 'journal.phaseroots')) |
|
1962 | 1962 | |
|
1963 | 1963 | def undofiles(self): |
|
1964 | 1964 | return [(vfs, undoname(x)) for vfs, x in self._journalfiles()] |
|
1965 | 1965 | |
|
1966 | 1966 | @unfilteredmethod |
|
1967 | 1967 | def _writejournal(self, desc): |
|
1968 | 1968 | self.dirstate.savebackup(None, 'journal.dirstate') |
|
1969 | 1969 | narrowspec.savewcbackup(self, 'journal.narrowspec.dirstate') |
|
1970 | 1970 | narrowspec.savebackup(self, 'journal.narrowspec') |
|
1971 | 1971 | self.vfs.write("journal.branch", |
|
1972 | 1972 | encoding.fromlocal(self.dirstate.branch())) |
|
1973 | 1973 | self.vfs.write("journal.desc", |
|
1974 | 1974 | "%d\n%s\n" % (len(self), desc)) |
|
1975 | 1975 | self.vfs.write("journal.bookmarks", |
|
1976 | 1976 | self.vfs.tryread("bookmarks")) |
|
1977 | 1977 | self.svfs.write("journal.phaseroots", |
|
1978 | 1978 | self.svfs.tryread("phaseroots")) |
|
1979 | 1979 | |
|
1980 | 1980 | def recover(self): |
|
1981 | 1981 | with self.lock(): |
|
1982 | 1982 | if self.svfs.exists("journal"): |
|
1983 | 1983 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
1984 | 1984 | vfsmap = {'': self.svfs, |
|
1985 | 1985 | 'plain': self.vfs,} |
|
1986 | 1986 | transaction.rollback(self.svfs, vfsmap, "journal", |
|
1987 | 1987 | self.ui.warn, |
|
1988 | 1988 | checkambigfiles=_cachedfiles) |
|
1989 | 1989 | self.invalidate() |
|
1990 | 1990 | return True |
|
1991 | 1991 | else: |
|
1992 | 1992 | self.ui.warn(_("no interrupted transaction available\n")) |
|
1993 | 1993 | return False |
|
1994 | 1994 | |
|
1995 | 1995 | def rollback(self, dryrun=False, force=False): |
|
1996 | 1996 | wlock = lock = dsguard = None |
|
1997 | 1997 | try: |
|
1998 | 1998 | wlock = self.wlock() |
|
1999 | 1999 | lock = self.lock() |
|
2000 | 2000 | if self.svfs.exists("undo"): |
|
2001 | 2001 | dsguard = dirstateguard.dirstateguard(self, 'rollback') |
|
2002 | 2002 | |
|
2003 | 2003 | return self._rollback(dryrun, force, dsguard) |
|
2004 | 2004 | else: |
|
2005 | 2005 | self.ui.warn(_("no rollback information available\n")) |
|
2006 | 2006 | return 1 |
|
2007 | 2007 | finally: |
|
2008 | 2008 | release(dsguard, lock, wlock) |
|
2009 | 2009 | |
|
2010 | 2010 | @unfilteredmethod # Until we get smarter cache management |
|
2011 | 2011 | def _rollback(self, dryrun, force, dsguard): |
|
2012 | 2012 | ui = self.ui |
|
2013 | 2013 | try: |
|
2014 | 2014 | args = self.vfs.read('undo.desc').splitlines() |
|
2015 | 2015 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
2016 | 2016 | if len(args) >= 3: |
|
2017 | 2017 | detail = args[2] |
|
2018 | 2018 | oldtip = oldlen - 1 |
|
2019 | 2019 | |
|
2020 | 2020 | if detail and ui.verbose: |
|
2021 | 2021 | msg = (_('repository tip rolled back to revision %d' |
|
2022 | 2022 | ' (undo %s: %s)\n') |
|
2023 | 2023 | % (oldtip, desc, detail)) |
|
2024 | 2024 | else: |
|
2025 | 2025 | msg = (_('repository tip rolled back to revision %d' |
|
2026 | 2026 | ' (undo %s)\n') |
|
2027 | 2027 | % (oldtip, desc)) |
|
2028 | 2028 | except IOError: |
|
2029 | 2029 | msg = _('rolling back unknown transaction\n') |
|
2030 | 2030 | desc = None |
|
2031 | 2031 | |
|
2032 | 2032 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
2033 | 2033 | raise error.Abort( |
|
2034 | 2034 | _('rollback of last commit while not checked out ' |
|
2035 | 2035 | 'may lose data'), hint=_('use -f to force')) |
|
2036 | 2036 | |
|
2037 | 2037 | ui.status(msg) |
|
2038 | 2038 | if dryrun: |
|
2039 | 2039 | return 0 |
|
2040 | 2040 | |
|
2041 | 2041 | parents = self.dirstate.parents() |
|
2042 | 2042 | self.destroying() |
|
2043 | 2043 | vfsmap = {'plain': self.vfs, '': self.svfs} |
|
2044 | 2044 | transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn, |
|
2045 | 2045 | checkambigfiles=_cachedfiles) |
|
2046 | 2046 | if self.vfs.exists('undo.bookmarks'): |
|
2047 | 2047 | self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) |
|
2048 | 2048 | if self.svfs.exists('undo.phaseroots'): |
|
2049 | 2049 | self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True) |
|
2050 | 2050 | self.invalidate() |
|
2051 | 2051 | |
|
2052 | 2052 | parentgone = any(p not in self.changelog.nodemap for p in parents) |
|
2053 | 2053 | if parentgone: |
|
2054 | 2054 | # prevent dirstateguard from overwriting already restored one |
|
2055 | 2055 | dsguard.close() |
|
2056 | 2056 | |
|
2057 | 2057 | narrowspec.restorebackup(self, 'undo.narrowspec') |
|
2058 | 2058 | narrowspec.restorewcbackup(self, 'undo.narrowspec.dirstate') |
|
2059 | 2059 | self.dirstate.restorebackup(None, 'undo.dirstate') |
|
2060 | 2060 | try: |
|
2061 | 2061 | branch = self.vfs.read('undo.branch') |
|
2062 | 2062 | self.dirstate.setbranch(encoding.tolocal(branch)) |
|
2063 | 2063 | except IOError: |
|
2064 | 2064 | ui.warn(_('named branch could not be reset: ' |
|
2065 | 2065 | 'current branch is still \'%s\'\n') |
|
2066 | 2066 | % self.dirstate.branch()) |
|
2067 | 2067 | |
|
2068 | 2068 | parents = tuple([p.rev() for p in self[None].parents()]) |
|
2069 | 2069 | if len(parents) > 1: |
|
2070 | 2070 | ui.status(_('working directory now based on ' |
|
2071 | 2071 | 'revisions %d and %d\n') % parents) |
|
2072 | 2072 | else: |
|
2073 | 2073 | ui.status(_('working directory now based on ' |
|
2074 | 2074 | 'revision %d\n') % parents) |
|
2075 | 2075 | mergemod.mergestate.clean(self, self['.'].node()) |
|
2076 | 2076 | |
|
2077 | 2077 | # TODO: if we know which new heads may result from this rollback, pass |
|
2078 | 2078 | # them to destroy(), which will prevent the branchhead cache from being |
|
2079 | 2079 | # invalidated. |
|
2080 | 2080 | self.destroyed() |
|
2081 | 2081 | return 0 |
|
2082 | 2082 | |
|
2083 | 2083 | def _buildcacheupdater(self, newtransaction): |
|
2084 | 2084 | """called during transaction to build the callback updating cache |
|
2085 | 2085 | |
|
2086 | 2086 | Lives on the repository to help extension who might want to augment |
|
2087 | 2087 | this logic. For this purpose, the created transaction is passed to the |
|
2088 | 2088 | method. |
|
2089 | 2089 | """ |
|
2090 | 2090 | # we must avoid cyclic reference between repo and transaction. |
|
2091 | 2091 | reporef = weakref.ref(self) |
|
2092 | 2092 | def updater(tr): |
|
2093 | 2093 | repo = reporef() |
|
2094 | 2094 | repo.updatecaches(tr) |
|
2095 | 2095 | return updater |
|
2096 | 2096 | |
|
2097 | 2097 | @unfilteredmethod |
|
2098 | 2098 | def updatecaches(self, tr=None, full=False): |
|
2099 | 2099 | """warm appropriate caches |
|
2100 | 2100 | |
|
2101 | 2101 | If this function is called after a transaction closed. The transaction |
|
2102 | 2102 | will be available in the 'tr' argument. This can be used to selectively |
|
2103 | 2103 | update caches relevant to the changes in that transaction. |
|
2104 | 2104 | |
|
2105 | 2105 | If 'full' is set, make sure all caches the function knows about have |
|
2106 | 2106 | up-to-date data. Even the ones usually loaded more lazily. |
|
2107 | 2107 | """ |
|
2108 | 2108 | if tr is not None and tr.hookargs.get('source') == 'strip': |
|
2109 | 2109 | # During strip, many caches are invalid but |
|
2110 | 2110 | # later call to `destroyed` will refresh them. |
|
2111 | 2111 | return |
|
2112 | 2112 | |
|
2113 | 2113 | if tr is None or tr.changes['origrepolen'] < len(self): |
|
2114 | 2114 | # accessing the 'ser ved' branchmap should refresh all the others, |
|
2115 | 2115 | self.ui.debug('updating the branch cache\n') |
|
2116 | 2116 | self.filtered('served').branchmap() |
|
2117 | 2117 | self.filtered('served.hidden').branchmap() |
|
2118 | 2118 | |
|
2119 | 2119 | if full: |
|
2120 | 2120 | unfi = self.unfiltered() |
|
2121 | 2121 | rbc = unfi.revbranchcache() |
|
2122 | 2122 | for r in unfi.changelog: |
|
2123 | 2123 | rbc.branchinfo(r) |
|
2124 | 2124 | rbc.write() |
|
2125 | 2125 | |
|
2126 | 2126 | # ensure the working copy parents are in the manifestfulltextcache |
|
2127 | 2127 | for ctx in self['.'].parents(): |
|
2128 | 2128 | ctx.manifest() # accessing the manifest is enough |
|
2129 | 2129 | |
|
2130 | 2130 | # accessing tags warm the cache |
|
2131 | 2131 | self.tags() |
|
2132 | 2132 | self.filtered('served').tags() |
|
2133 | 2133 | |
|
2134 | 2134 | def invalidatecaches(self): |
|
2135 | 2135 | |
|
2136 | 2136 | if r'_tagscache' in vars(self): |
|
2137 | 2137 | # can't use delattr on proxy |
|
2138 | 2138 | del self.__dict__[r'_tagscache'] |
|
2139 | 2139 | |
|
2140 | 2140 | self._branchcaches.clear() |
|
2141 | 2141 | self.invalidatevolatilesets() |
|
2142 | 2142 | self._sparsesignaturecache.clear() |
|
2143 | 2143 | |
|
2144 | 2144 | def invalidatevolatilesets(self): |
|
2145 | 2145 | self.filteredrevcache.clear() |
|
2146 | 2146 | obsolete.clearobscaches(self) |
|
2147 | 2147 | |
|
2148 | 2148 | def invalidatedirstate(self): |
|
2149 | 2149 | '''Invalidates the dirstate, causing the next call to dirstate |
|
2150 | 2150 | to check if it was modified since the last time it was read, |
|
2151 | 2151 | rereading it if it has. |
|
2152 | 2152 | |
|
2153 | 2153 | This is different to dirstate.invalidate() that it doesn't always |
|
2154 | 2154 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
2155 | 2155 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
2156 | 2156 | known good state).''' |
|
2157 | 2157 | if hasunfilteredcache(self, r'dirstate'): |
|
2158 | 2158 | for k in self.dirstate._filecache: |
|
2159 | 2159 | try: |
|
2160 | 2160 | delattr(self.dirstate, k) |
|
2161 | 2161 | except AttributeError: |
|
2162 | 2162 | pass |
|
2163 | 2163 | delattr(self.unfiltered(), r'dirstate') |
|
2164 | 2164 | |
|
2165 | 2165 | def invalidate(self, clearfilecache=False): |
|
2166 | 2166 | '''Invalidates both store and non-store parts other than dirstate |
|
2167 | 2167 | |
|
2168 | 2168 | If a transaction is running, invalidation of store is omitted, |
|
2169 | 2169 | because discarding in-memory changes might cause inconsistency |
|
2170 | 2170 | (e.g. incomplete fncache causes unintentional failure, but |
|
2171 | 2171 | redundant one doesn't). |
|
2172 | 2172 | ''' |
|
2173 | 2173 | unfiltered = self.unfiltered() # all file caches are stored unfiltered |
|
2174 | 2174 | for k in list(self._filecache.keys()): |
|
2175 | 2175 | # dirstate is invalidated separately in invalidatedirstate() |
|
2176 | 2176 | if k == 'dirstate': |
|
2177 | 2177 | continue |
|
2178 | 2178 | if (k == 'changelog' and |
|
2179 | 2179 | self.currenttransaction() and |
|
2180 | 2180 | self.changelog._delayed): |
|
2181 | 2181 | # The changelog object may store unwritten revisions. We don't |
|
2182 | 2182 | # want to lose them. |
|
2183 | 2183 | # TODO: Solve the problem instead of working around it. |
|
2184 | 2184 | continue |
|
2185 | 2185 | |
|
2186 | 2186 | if clearfilecache: |
|
2187 | 2187 | del self._filecache[k] |
|
2188 | 2188 | try: |
|
2189 | 2189 | delattr(unfiltered, k) |
|
2190 | 2190 | except AttributeError: |
|
2191 | 2191 | pass |
|
2192 | 2192 | self.invalidatecaches() |
|
2193 | 2193 | if not self.currenttransaction(): |
|
2194 | 2194 | # TODO: Changing contents of store outside transaction |
|
2195 | 2195 | # causes inconsistency. We should make in-memory store |
|
2196 | 2196 | # changes detectable, and abort if changed. |
|
2197 | 2197 | self.store.invalidatecaches() |
|
2198 | 2198 | |
|
2199 | 2199 | def invalidateall(self): |
|
2200 | 2200 | '''Fully invalidates both store and non-store parts, causing the |
|
2201 | 2201 | subsequent operation to reread any outside changes.''' |
|
2202 | 2202 | # extension should hook this to invalidate its caches |
|
2203 | 2203 | self.invalidate() |
|
2204 | 2204 | self.invalidatedirstate() |
|
2205 | 2205 | |
|
2206 | 2206 | @unfilteredmethod |
|
2207 | 2207 | def _refreshfilecachestats(self, tr): |
|
2208 | 2208 | """Reload stats of cached files so that they are flagged as valid""" |
|
2209 | 2209 | for k, ce in self._filecache.items(): |
|
2210 | 2210 | k = pycompat.sysstr(k) |
|
2211 | 2211 | if k == r'dirstate' or k not in self.__dict__: |
|
2212 | 2212 | continue |
|
2213 | 2213 | ce.refresh() |
|
2214 | 2214 | |
|
2215 | 2215 | def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc, |
|
2216 | 2216 | inheritchecker=None, parentenvvar=None): |
|
2217 | 2217 | parentlock = None |
|
2218 | 2218 | # the contents of parentenvvar are used by the underlying lock to |
|
2219 | 2219 | # determine whether it can be inherited |
|
2220 | 2220 | if parentenvvar is not None: |
|
2221 | 2221 | parentlock = encoding.environ.get(parentenvvar) |
|
2222 | 2222 | |
|
2223 | 2223 | timeout = 0 |
|
2224 | 2224 | warntimeout = 0 |
|
2225 | 2225 | if wait: |
|
2226 | 2226 | timeout = self.ui.configint("ui", "timeout") |
|
2227 | 2227 | warntimeout = self.ui.configint("ui", "timeout.warn") |
|
2228 | 2228 | # internal config: ui.signal-safe-lock |
|
2229 | 2229 | signalsafe = self.ui.configbool('ui', 'signal-safe-lock') |
|
2230 | 2230 | |
|
2231 | 2231 | l = lockmod.trylock(self.ui, vfs, lockname, timeout, warntimeout, |
|
2232 | 2232 | releasefn=releasefn, |
|
2233 | 2233 | acquirefn=acquirefn, desc=desc, |
|
2234 | 2234 | inheritchecker=inheritchecker, |
|
2235 | 2235 | parentlock=parentlock, |
|
2236 | 2236 | signalsafe=signalsafe) |
|
2237 | 2237 | return l |
|
2238 | 2238 | |
|
2239 | 2239 | def _afterlock(self, callback): |
|
2240 | 2240 | """add a callback to be run when the repository is fully unlocked |
|
2241 | 2241 | |
|
2242 | 2242 | The callback will be executed when the outermost lock is released |
|
2243 | 2243 | (with wlock being higher level than 'lock').""" |
|
2244 | 2244 | for ref in (self._wlockref, self._lockref): |
|
2245 | 2245 | l = ref and ref() |
|
2246 | 2246 | if l and l.held: |
|
2247 | 2247 | l.postrelease.append(callback) |
|
2248 | 2248 | break |
|
2249 | 2249 | else: # no lock have been found. |
|
2250 | 2250 | callback() |
|
2251 | 2251 | |
|
2252 | 2252 | def lock(self, wait=True): |
|
2253 | 2253 | '''Lock the repository store (.hg/store) and return a weak reference |
|
2254 | 2254 | to the lock. Use this before modifying the store (e.g. committing or |
|
2255 | 2255 | stripping). If you are opening a transaction, get a lock as well.) |
|
2256 | 2256 | |
|
2257 | 2257 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
2258 | 2258 | 'wlock' first to avoid a dead-lock hazard.''' |
|
2259 | 2259 | l = self._currentlock(self._lockref) |
|
2260 | 2260 | if l is not None: |
|
2261 | 2261 | l.lock() |
|
2262 | 2262 | return l |
|
2263 | 2263 | |
|
2264 | 2264 | l = self._lock(vfs=self.svfs, |
|
2265 | 2265 | lockname="lock", |
|
2266 | 2266 | wait=wait, |
|
2267 | 2267 | releasefn=None, |
|
2268 | 2268 | acquirefn=self.invalidate, |
|
2269 | 2269 | desc=_('repository %s') % self.origroot) |
|
2270 | 2270 | self._lockref = weakref.ref(l) |
|
2271 | 2271 | return l |
|
2272 | 2272 | |
|
2273 | 2273 | def _wlockchecktransaction(self): |
|
2274 | 2274 | if self.currenttransaction() is not None: |
|
2275 | 2275 | raise error.LockInheritanceContractViolation( |
|
2276 | 2276 | 'wlock cannot be inherited in the middle of a transaction') |
|
2277 | 2277 | |
|
2278 | 2278 | def wlock(self, wait=True): |
|
2279 | 2279 | '''Lock the non-store parts of the repository (everything under |
|
2280 | 2280 | .hg except .hg/store) and return a weak reference to the lock. |
|
2281 | 2281 | |
|
2282 | 2282 | Use this before modifying files in .hg. |
|
2283 | 2283 | |
|
2284 | 2284 | If both 'lock' and 'wlock' must be acquired, ensure you always acquires |
|
2285 | 2285 | 'wlock' first to avoid a dead-lock hazard.''' |
|
2286 | 2286 | l = self._wlockref and self._wlockref() |
|
2287 | 2287 | if l is not None and l.held: |
|
2288 | 2288 | l.lock() |
|
2289 | 2289 | return l |
|
2290 | 2290 | |
|
2291 | 2291 | # We do not need to check for non-waiting lock acquisition. Such |
|
2292 | 2292 | # acquisition would not cause dead-lock as they would just fail. |
|
2293 | 2293 | if wait and (self.ui.configbool('devel', 'all-warnings') |
|
2294 | 2294 | or self.ui.configbool('devel', 'check-locks')): |
|
2295 | 2295 | if self._currentlock(self._lockref) is not None: |
|
2296 | 2296 | self.ui.develwarn('"wlock" acquired after "lock"') |
|
2297 | 2297 | |
|
2298 | 2298 | def unlock(): |
|
2299 | 2299 | if self.dirstate.pendingparentchange(): |
|
2300 | 2300 | self.dirstate.invalidate() |
|
2301 | 2301 | else: |
|
2302 | 2302 | self.dirstate.write(None) |
|
2303 | 2303 | |
|
2304 | 2304 | self._filecache['dirstate'].refresh() |
|
2305 | 2305 | |
|
2306 | 2306 | l = self._lock(self.vfs, "wlock", wait, unlock, |
|
2307 | 2307 | self.invalidatedirstate, _('working directory of %s') % |
|
2308 | 2308 | self.origroot, |
|
2309 | 2309 | inheritchecker=self._wlockchecktransaction, |
|
2310 | 2310 | parentenvvar='HG_WLOCK_LOCKER') |
|
2311 | 2311 | self._wlockref = weakref.ref(l) |
|
2312 | 2312 | return l |
|
2313 | 2313 | |
|
2314 | 2314 | def _currentlock(self, lockref): |
|
2315 | 2315 | """Returns the lock if it's held, or None if it's not.""" |
|
2316 | 2316 | if lockref is None: |
|
2317 | 2317 | return None |
|
2318 | 2318 | l = lockref() |
|
2319 | 2319 | if l is None or not l.held: |
|
2320 | 2320 | return None |
|
2321 | 2321 | return l |
|
2322 | 2322 | |
|
2323 | 2323 | def currentwlock(self): |
|
2324 | 2324 | """Returns the wlock if it's held, or None if it's not.""" |
|
2325 | 2325 | return self._currentlock(self._wlockref) |
|
2326 | 2326 | |
|
2327 |
def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist |
|
|
2327 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist, | |
|
2328 | includecopymeta): | |
|
2328 | 2329 | """ |
|
2329 | 2330 | commit an individual file as part of a larger transaction |
|
2330 | 2331 | """ |
|
2331 | 2332 | |
|
2332 | 2333 | fname = fctx.path() |
|
2333 | 2334 | fparent1 = manifest1.get(fname, nullid) |
|
2334 | 2335 | fparent2 = manifest2.get(fname, nullid) |
|
2335 | 2336 | if isinstance(fctx, context.filectx): |
|
2336 | 2337 | node = fctx.filenode() |
|
2337 | 2338 | if node in [fparent1, fparent2]: |
|
2338 | 2339 | self.ui.debug('reusing %s filelog entry\n' % fname) |
|
2339 | 2340 | if manifest1.flags(fname) != fctx.flags(): |
|
2340 | 2341 | changelist.append(fname) |
|
2341 | 2342 | return node |
|
2342 | 2343 | |
|
2343 | 2344 | flog = self.file(fname) |
|
2344 | 2345 | meta = {} |
|
2345 | 2346 | cfname = fctx.copysource() |
|
2346 | 2347 | if cfname and cfname != fname: |
|
2347 | 2348 | # Mark the new revision of this file as a copy of another |
|
2348 | 2349 | # file. This copy data will effectively act as a parent |
|
2349 | 2350 | # of this new revision. If this is a merge, the first |
|
2350 | 2351 | # parent will be the nullid (meaning "look up the copy data") |
|
2351 | 2352 | # and the second one will be the other parent. For example: |
|
2352 | 2353 | # |
|
2353 | 2354 | # 0 --- 1 --- 3 rev1 changes file foo |
|
2354 | 2355 | # \ / rev2 renames foo to bar and changes it |
|
2355 | 2356 | # \- 2 -/ rev3 should have bar with all changes and |
|
2356 | 2357 | # should record that bar descends from |
|
2357 | 2358 | # bar in rev2 and foo in rev1 |
|
2358 | 2359 | # |
|
2359 | 2360 | # this allows this merge to succeed: |
|
2360 | 2361 | # |
|
2361 | 2362 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
2362 | 2363 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
2363 | 2364 | # \- 2 --- 4 as the merge base |
|
2364 | 2365 | # |
|
2365 | 2366 | |
|
2366 | 2367 | cnode = manifest1.get(cfname) |
|
2367 | 2368 | newfparent = fparent2 |
|
2368 | 2369 | |
|
2369 | 2370 | if manifest2: # branch merge |
|
2370 | 2371 | if fparent2 == nullid or cnode is None: # copied on remote side |
|
2371 | 2372 | if cfname in manifest2: |
|
2372 | 2373 | cnode = manifest2[cfname] |
|
2373 | 2374 | newfparent = fparent1 |
|
2374 | 2375 | |
|
2375 | 2376 | # Here, we used to search backwards through history to try to find |
|
2376 | 2377 | # where the file copy came from if the source of a copy was not in |
|
2377 | 2378 | # the parent directory. However, this doesn't actually make sense to |
|
2378 | 2379 | # do (what does a copy from something not in your working copy even |
|
2379 | 2380 | # mean?) and it causes bugs (eg, issue4476). Instead, we will warn |
|
2380 | 2381 | # the user that copy information was dropped, so if they didn't |
|
2381 | 2382 | # expect this outcome it can be fixed, but this is the correct |
|
2382 | 2383 | # behavior in this circumstance. |
|
2383 | 2384 | |
|
2384 | 2385 | if cnode: |
|
2385 | 2386 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(cnode))) |
|
2386 | meta["copy"] = cfname | |
|
2387 |
meta["copy |
|
|
2387 | if includecopymeta: | |
|
2388 | meta["copy"] = cfname | |
|
2389 | meta["copyrev"] = hex(cnode) | |
|
2388 | 2390 | fparent1, fparent2 = nullid, newfparent |
|
2389 | 2391 | else: |
|
2390 | 2392 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
2391 | 2393 | "copied from '%s'!\n") % (fname, cfname)) |
|
2392 | 2394 | |
|
2393 | 2395 | elif fparent1 == nullid: |
|
2394 | 2396 | fparent1, fparent2 = fparent2, nullid |
|
2395 | 2397 | elif fparent2 != nullid: |
|
2396 | 2398 | # is one parent an ancestor of the other? |
|
2397 | 2399 | fparentancestors = flog.commonancestorsheads(fparent1, fparent2) |
|
2398 | 2400 | if fparent1 in fparentancestors: |
|
2399 | 2401 | fparent1, fparent2 = fparent2, nullid |
|
2400 | 2402 | elif fparent2 in fparentancestors: |
|
2401 | 2403 | fparent2 = nullid |
|
2402 | 2404 | |
|
2403 | 2405 | # is the file changed? |
|
2404 | 2406 | text = fctx.data() |
|
2405 | 2407 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
2406 | 2408 | changelist.append(fname) |
|
2407 | 2409 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
2408 | 2410 | # are just the flags changed during merge? |
|
2409 | 2411 | elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
|
2410 | 2412 | changelist.append(fname) |
|
2411 | 2413 | |
|
2412 | 2414 | return fparent1 |
|
2413 | 2415 | |
|
2414 | 2416 | def checkcommitpatterns(self, wctx, vdirs, match, status, fail): |
|
2415 | 2417 | """check for commit arguments that aren't committable""" |
|
2416 | 2418 | if match.isexact() or match.prefix(): |
|
2417 | 2419 | matched = set(status.modified + status.added + status.removed) |
|
2418 | 2420 | |
|
2419 | 2421 | for f in match.files(): |
|
2420 | 2422 | f = self.dirstate.normalize(f) |
|
2421 | 2423 | if f == '.' or f in matched or f in wctx.substate: |
|
2422 | 2424 | continue |
|
2423 | 2425 | if f in status.deleted: |
|
2424 | 2426 | fail(f, _('file not found!')) |
|
2425 | 2427 | if f in vdirs: # visited directory |
|
2426 | 2428 | d = f + '/' |
|
2427 | 2429 | for mf in matched: |
|
2428 | 2430 | if mf.startswith(d): |
|
2429 | 2431 | break |
|
2430 | 2432 | else: |
|
2431 | 2433 | fail(f, _("no match under directory!")) |
|
2432 | 2434 | elif f not in self.dirstate: |
|
2433 | 2435 | fail(f, _("file not tracked!")) |
|
2434 | 2436 | |
|
2435 | 2437 | @unfilteredmethod |
|
2436 | 2438 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
2437 | 2439 | editor=False, extra=None): |
|
2438 | 2440 | """Add a new revision to current repository. |
|
2439 | 2441 | |
|
2440 | 2442 | Revision information is gathered from the working directory, |
|
2441 | 2443 | match can be used to filter the committed files. If editor is |
|
2442 | 2444 | supplied, it is called to get a commit message. |
|
2443 | 2445 | """ |
|
2444 | 2446 | if extra is None: |
|
2445 | 2447 | extra = {} |
|
2446 | 2448 | |
|
2447 | 2449 | def fail(f, msg): |
|
2448 | 2450 | raise error.Abort('%s: %s' % (f, msg)) |
|
2449 | 2451 | |
|
2450 | 2452 | if not match: |
|
2451 | 2453 | match = matchmod.always() |
|
2452 | 2454 | |
|
2453 | 2455 | if not force: |
|
2454 | 2456 | vdirs = [] |
|
2455 | 2457 | match.explicitdir = vdirs.append |
|
2456 | 2458 | match.bad = fail |
|
2457 | 2459 | |
|
2458 | 2460 | # lock() for recent changelog (see issue4368) |
|
2459 | 2461 | with self.wlock(), self.lock(): |
|
2460 | 2462 | wctx = self[None] |
|
2461 | 2463 | merge = len(wctx.parents()) > 1 |
|
2462 | 2464 | |
|
2463 | 2465 | if not force and merge and not match.always(): |
|
2464 | 2466 | raise error.Abort(_('cannot partially commit a merge ' |
|
2465 | 2467 | '(do not specify files or patterns)')) |
|
2466 | 2468 | |
|
2467 | 2469 | status = self.status(match=match, clean=force) |
|
2468 | 2470 | if force: |
|
2469 | 2471 | status.modified.extend(status.clean) # mq may commit clean files |
|
2470 | 2472 | |
|
2471 | 2473 | # check subrepos |
|
2472 | 2474 | subs, commitsubs, newstate = subrepoutil.precommit( |
|
2473 | 2475 | self.ui, wctx, status, match, force=force) |
|
2474 | 2476 | |
|
2475 | 2477 | # make sure all explicit patterns are matched |
|
2476 | 2478 | if not force: |
|
2477 | 2479 | self.checkcommitpatterns(wctx, vdirs, match, status, fail) |
|
2478 | 2480 | |
|
2479 | 2481 | cctx = context.workingcommitctx(self, status, |
|
2480 | 2482 | text, user, date, extra) |
|
2481 | 2483 | |
|
2482 | 2484 | # internal config: ui.allowemptycommit |
|
2483 | 2485 | allowemptycommit = (wctx.branch() != wctx.p1().branch() |
|
2484 | 2486 | or extra.get('close') or merge or cctx.files() |
|
2485 | 2487 | or self.ui.configbool('ui', 'allowemptycommit')) |
|
2486 | 2488 | if not allowemptycommit: |
|
2487 | 2489 | return None |
|
2488 | 2490 | |
|
2489 | 2491 | if merge and cctx.deleted(): |
|
2490 | 2492 | raise error.Abort(_("cannot commit merge with missing files")) |
|
2491 | 2493 | |
|
2492 | 2494 | ms = mergemod.mergestate.read(self) |
|
2493 | 2495 | mergeutil.checkunresolved(ms) |
|
2494 | 2496 | |
|
2495 | 2497 | if editor: |
|
2496 | 2498 | cctx._text = editor(self, cctx, subs) |
|
2497 | 2499 | edited = (text != cctx._text) |
|
2498 | 2500 | |
|
2499 | 2501 | # Save commit message in case this transaction gets rolled back |
|
2500 | 2502 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
2501 | 2503 | # the assumption that the user will use the same editor again. |
|
2502 | 2504 | msgfn = self.savecommitmessage(cctx._text) |
|
2503 | 2505 | |
|
2504 | 2506 | # commit subs and write new state |
|
2505 | 2507 | if subs: |
|
2506 | 2508 | uipathfn = scmutil.getuipathfn(self) |
|
2507 | 2509 | for s in sorted(commitsubs): |
|
2508 | 2510 | sub = wctx.sub(s) |
|
2509 | 2511 | self.ui.status(_('committing subrepository %s\n') % |
|
2510 | 2512 | uipathfn(subrepoutil.subrelpath(sub))) |
|
2511 | 2513 | sr = sub.commit(cctx._text, user, date) |
|
2512 | 2514 | newstate[s] = (newstate[s][0], sr) |
|
2513 | 2515 | subrepoutil.writestate(self, newstate) |
|
2514 | 2516 | |
|
2515 | 2517 | p1, p2 = self.dirstate.parents() |
|
2516 | 2518 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
2517 | 2519 | try: |
|
2518 | 2520 | self.hook("precommit", throw=True, parent1=hookp1, |
|
2519 | 2521 | parent2=hookp2) |
|
2520 | 2522 | with self.transaction('commit'): |
|
2521 | 2523 | ret = self.commitctx(cctx, True) |
|
2522 | 2524 | # update bookmarks, dirstate and mergestate |
|
2523 | 2525 | bookmarks.update(self, [p1, p2], ret) |
|
2524 | 2526 | cctx.markcommitted(ret) |
|
2525 | 2527 | ms.reset() |
|
2526 | 2528 | except: # re-raises |
|
2527 | 2529 | if edited: |
|
2528 | 2530 | self.ui.write( |
|
2529 | 2531 | _('note: commit message saved in %s\n') % msgfn) |
|
2530 | 2532 | raise |
|
2531 | 2533 | |
|
2532 | 2534 | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): |
|
2533 | 2535 | # hack for command that use a temporary commit (eg: histedit) |
|
2534 | 2536 | # temporary commit got stripped before hook release |
|
2535 | 2537 | if self.changelog.hasnode(ret): |
|
2536 | 2538 | self.hook("commit", node=node, parent1=parent1, |
|
2537 | 2539 | parent2=parent2) |
|
2538 | 2540 | self._afterlock(commithook) |
|
2539 | 2541 | return ret |
|
2540 | 2542 | |
|
2541 | 2543 | @unfilteredmethod |
|
2542 | 2544 | def commitctx(self, ctx, error=False): |
|
2543 | 2545 | """Add a new revision to current repository. |
|
2544 | 2546 | Revision information is passed via the context argument. |
|
2545 | 2547 | |
|
2546 | 2548 | ctx.files() should list all files involved in this commit, i.e. |
|
2547 | 2549 | modified/added/removed files. On merge, it may be wider than the |
|
2548 | 2550 | ctx.files() to be committed, since any file nodes derived directly |
|
2549 | 2551 | from p1 or p2 are excluded from the committed ctx.files(). |
|
2550 | 2552 | """ |
|
2551 | 2553 | |
|
2552 | 2554 | p1, p2 = ctx.p1(), ctx.p2() |
|
2553 | 2555 | user = ctx.user() |
|
2554 | 2556 | |
|
2557 | writecopiesto = self.ui.config('experimental', 'copies.write-to') | |
|
2558 | writefilecopymeta = writecopiesto != 'changeset-only' | |
|
2559 | p1copies, p2copies = None, None | |
|
2560 | if writecopiesto in ('changeset-only', 'compatibility'): | |
|
2561 | p1copies = ctx.p1copies() | |
|
2562 | p2copies = ctx.p2copies() | |
|
2555 | 2563 | with self.lock(), self.transaction("commit") as tr: |
|
2556 | 2564 | trp = weakref.proxy(tr) |
|
2557 | 2565 | |
|
2558 | 2566 | if ctx.manifestnode(): |
|
2559 | 2567 | # reuse an existing manifest revision |
|
2560 | 2568 | self.ui.debug('reusing known manifest\n') |
|
2561 | 2569 | mn = ctx.manifestnode() |
|
2562 | 2570 | files = ctx.files() |
|
2563 | 2571 | elif ctx.files(): |
|
2564 | 2572 | m1ctx = p1.manifestctx() |
|
2565 | 2573 | m2ctx = p2.manifestctx() |
|
2566 | 2574 | mctx = m1ctx.copy() |
|
2567 | 2575 | |
|
2568 | 2576 | m = mctx.read() |
|
2569 | 2577 | m1 = m1ctx.read() |
|
2570 | 2578 | m2 = m2ctx.read() |
|
2571 | 2579 | |
|
2572 | 2580 | # check in files |
|
2573 | 2581 | added = [] |
|
2574 | 2582 | changed = [] |
|
2575 | 2583 | removed = list(ctx.removed()) |
|
2576 | 2584 | linkrev = len(self) |
|
2577 | 2585 | self.ui.note(_("committing files:\n")) |
|
2578 | 2586 | uipathfn = scmutil.getuipathfn(self) |
|
2579 | 2587 | for f in sorted(ctx.modified() + ctx.added()): |
|
2580 | 2588 | self.ui.note(uipathfn(f) + "\n") |
|
2581 | 2589 | try: |
|
2582 | 2590 | fctx = ctx[f] |
|
2583 | 2591 | if fctx is None: |
|
2584 | 2592 | removed.append(f) |
|
2585 | 2593 | else: |
|
2586 | 2594 | added.append(f) |
|
2587 | 2595 | m[f] = self._filecommit(fctx, m1, m2, linkrev, |
|
2588 |
trp, changed |
|
|
2596 | trp, changed, | |
|
2597 | writefilecopymeta) | |
|
2589 | 2598 | m.setflag(f, fctx.flags()) |
|
2590 | 2599 | except OSError: |
|
2591 | 2600 | self.ui.warn(_("trouble committing %s!\n") % |
|
2592 | 2601 | uipathfn(f)) |
|
2593 | 2602 | raise |
|
2594 | 2603 | except IOError as inst: |
|
2595 | 2604 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
2596 | 2605 | if error or errcode and errcode != errno.ENOENT: |
|
2597 | 2606 | self.ui.warn(_("trouble committing %s!\n") % |
|
2598 | 2607 | uipathfn(f)) |
|
2599 | 2608 | raise |
|
2600 | 2609 | |
|
2601 | 2610 | # update manifest |
|
2602 | 2611 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
2603 | 2612 | drop = [f for f in removed if f in m] |
|
2604 | 2613 | for f in drop: |
|
2605 | 2614 | del m[f] |
|
2606 | 2615 | files = changed + removed |
|
2607 | 2616 | md = None |
|
2608 | 2617 | if not files: |
|
2609 | 2618 | # if no "files" actually changed in terms of the changelog, |
|
2610 | 2619 | # try hard to detect unmodified manifest entry so that the |
|
2611 | 2620 | # exact same commit can be reproduced later on convert. |
|
2612 | 2621 | md = m1.diff(m, scmutil.matchfiles(self, ctx.files())) |
|
2613 | 2622 | if not files and md: |
|
2614 | 2623 | self.ui.debug('not reusing manifest (no file change in ' |
|
2615 | 2624 | 'changelog, but manifest differs)\n') |
|
2616 | 2625 | if files or md: |
|
2617 | 2626 | self.ui.note(_("committing manifest\n")) |
|
2618 | 2627 | # we're using narrowmatch here since it's already applied at |
|
2619 | 2628 | # other stages (such as dirstate.walk), so we're already |
|
2620 | 2629 | # ignoring things outside of narrowspec in most cases. The |
|
2621 | 2630 | # one case where we might have files outside the narrowspec |
|
2622 | 2631 | # at this point is merges, and we already error out in the |
|
2623 | 2632 | # case where the merge has files outside of the narrowspec, |
|
2624 | 2633 | # so this is safe. |
|
2625 | 2634 | mn = mctx.write(trp, linkrev, |
|
2626 | 2635 | p1.manifestnode(), p2.manifestnode(), |
|
2627 | 2636 | added, drop, match=self.narrowmatch()) |
|
2628 | 2637 | else: |
|
2629 | 2638 | self.ui.debug('reusing manifest form p1 (listed files ' |
|
2630 | 2639 | 'actually unchanged)\n') |
|
2631 | 2640 | mn = p1.manifestnode() |
|
2632 | 2641 | else: |
|
2633 | 2642 | self.ui.debug('reusing manifest from p1 (no file change)\n') |
|
2634 | 2643 | mn = p1.manifestnode() |
|
2635 | 2644 | files = [] |
|
2636 | 2645 | |
|
2637 | 2646 | # update changelog |
|
2638 | 2647 | self.ui.note(_("committing changelog\n")) |
|
2639 | 2648 | self.changelog.delayupdate(tr) |
|
2640 | 2649 | n = self.changelog.add(mn, files, ctx.description(), |
|
2641 | 2650 | trp, p1.node(), p2.node(), |
|
2642 |
user, ctx.date(), ctx.extra().copy() |
|
|
2651 | user, ctx.date(), ctx.extra().copy(), | |
|
2652 | p1copies, p2copies) | |
|
2643 | 2653 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
2644 | 2654 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
2645 | 2655 | parent2=xp2) |
|
2646 | 2656 | # set the new commit is proper phase |
|
2647 | 2657 | targetphase = subrepoutil.newcommitphase(self.ui, ctx) |
|
2648 | 2658 | if targetphase: |
|
2649 | 2659 | # retract boundary do not alter parent changeset. |
|
2650 | 2660 | # if a parent have higher the resulting phase will |
|
2651 | 2661 | # be compliant anyway |
|
2652 | 2662 | # |
|
2653 | 2663 | # if minimal phase was 0 we don't need to retract anything |
|
2654 | 2664 | phases.registernew(self, tr, targetphase, [n]) |
|
2655 | 2665 | return n |
|
2656 | 2666 | |
|
2657 | 2667 | @unfilteredmethod |
|
2658 | 2668 | def destroying(self): |
|
2659 | 2669 | '''Inform the repository that nodes are about to be destroyed. |
|
2660 | 2670 | Intended for use by strip and rollback, so there's a common |
|
2661 | 2671 | place for anything that has to be done before destroying history. |
|
2662 | 2672 | |
|
2663 | 2673 | This is mostly useful for saving state that is in memory and waiting |
|
2664 | 2674 | to be flushed when the current lock is released. Because a call to |
|
2665 | 2675 | destroyed is imminent, the repo will be invalidated causing those |
|
2666 | 2676 | changes to stay in memory (waiting for the next unlock), or vanish |
|
2667 | 2677 | completely. |
|
2668 | 2678 | ''' |
|
2669 | 2679 | # When using the same lock to commit and strip, the phasecache is left |
|
2670 | 2680 | # dirty after committing. Then when we strip, the repo is invalidated, |
|
2671 | 2681 | # causing those changes to disappear. |
|
2672 | 2682 | if '_phasecache' in vars(self): |
|
2673 | 2683 | self._phasecache.write() |
|
2674 | 2684 | |
|
2675 | 2685 | @unfilteredmethod |
|
2676 | 2686 | def destroyed(self): |
|
2677 | 2687 | '''Inform the repository that nodes have been destroyed. |
|
2678 | 2688 | Intended for use by strip and rollback, so there's a common |
|
2679 | 2689 | place for anything that has to be done after destroying history. |
|
2680 | 2690 | ''' |
|
2681 | 2691 | # When one tries to: |
|
2682 | 2692 | # 1) destroy nodes thus calling this method (e.g. strip) |
|
2683 | 2693 | # 2) use phasecache somewhere (e.g. commit) |
|
2684 | 2694 | # |
|
2685 | 2695 | # then 2) will fail because the phasecache contains nodes that were |
|
2686 | 2696 | # removed. We can either remove phasecache from the filecache, |
|
2687 | 2697 | # causing it to reload next time it is accessed, or simply filter |
|
2688 | 2698 | # the removed nodes now and write the updated cache. |
|
2689 | 2699 | self._phasecache.filterunknown(self) |
|
2690 | 2700 | self._phasecache.write() |
|
2691 | 2701 | |
|
2692 | 2702 | # refresh all repository caches |
|
2693 | 2703 | self.updatecaches() |
|
2694 | 2704 | |
|
2695 | 2705 | # Ensure the persistent tag cache is updated. Doing it now |
|
2696 | 2706 | # means that the tag cache only has to worry about destroyed |
|
2697 | 2707 | # heads immediately after a strip/rollback. That in turn |
|
2698 | 2708 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
2699 | 2709 | # and node) always means no nodes have been added or destroyed. |
|
2700 | 2710 | |
|
2701 | 2711 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
2702 | 2712 | # head, refresh the tag cache, then immediately add a new head. |
|
2703 | 2713 | # But I think doing it this way is necessary for the "instant |
|
2704 | 2714 | # tag cache retrieval" case to work. |
|
2705 | 2715 | self.invalidate() |
|
2706 | 2716 | |
|
2707 | 2717 | def status(self, node1='.', node2=None, match=None, |
|
2708 | 2718 | ignored=False, clean=False, unknown=False, |
|
2709 | 2719 | listsubrepos=False): |
|
2710 | 2720 | '''a convenience method that calls node1.status(node2)''' |
|
2711 | 2721 | return self[node1].status(node2, match, ignored, clean, unknown, |
|
2712 | 2722 | listsubrepos) |
|
2713 | 2723 | |
|
2714 | 2724 | def addpostdsstatus(self, ps): |
|
2715 | 2725 | """Add a callback to run within the wlock, at the point at which status |
|
2716 | 2726 | fixups happen. |
|
2717 | 2727 | |
|
2718 | 2728 | On status completion, callback(wctx, status) will be called with the |
|
2719 | 2729 | wlock held, unless the dirstate has changed from underneath or the wlock |
|
2720 | 2730 | couldn't be grabbed. |
|
2721 | 2731 | |
|
2722 | 2732 | Callbacks should not capture and use a cached copy of the dirstate -- |
|
2723 | 2733 | it might change in the meanwhile. Instead, they should access the |
|
2724 | 2734 | dirstate via wctx.repo().dirstate. |
|
2725 | 2735 | |
|
2726 | 2736 | This list is emptied out after each status run -- extensions should |
|
2727 | 2737 | make sure it adds to this list each time dirstate.status is called. |
|
2728 | 2738 | Extensions should also make sure they don't call this for statuses |
|
2729 | 2739 | that don't involve the dirstate. |
|
2730 | 2740 | """ |
|
2731 | 2741 | |
|
2732 | 2742 | # The list is located here for uniqueness reasons -- it is actually |
|
2733 | 2743 | # managed by the workingctx, but that isn't unique per-repo. |
|
2734 | 2744 | self._postdsstatus.append(ps) |
|
2735 | 2745 | |
|
2736 | 2746 | def postdsstatus(self): |
|
2737 | 2747 | """Used by workingctx to get the list of post-dirstate-status hooks.""" |
|
2738 | 2748 | return self._postdsstatus |
|
2739 | 2749 | |
|
2740 | 2750 | def clearpostdsstatus(self): |
|
2741 | 2751 | """Used by workingctx to clear post-dirstate-status hooks.""" |
|
2742 | 2752 | del self._postdsstatus[:] |
|
2743 | 2753 | |
|
2744 | 2754 | def heads(self, start=None): |
|
2745 | 2755 | if start is None: |
|
2746 | 2756 | cl = self.changelog |
|
2747 | 2757 | headrevs = reversed(cl.headrevs()) |
|
2748 | 2758 | return [cl.node(rev) for rev in headrevs] |
|
2749 | 2759 | |
|
2750 | 2760 | heads = self.changelog.heads(start) |
|
2751 | 2761 | # sort the output in rev descending order |
|
2752 | 2762 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
2753 | 2763 | |
|
2754 | 2764 | def branchheads(self, branch=None, start=None, closed=False): |
|
2755 | 2765 | '''return a (possibly filtered) list of heads for the given branch |
|
2756 | 2766 | |
|
2757 | 2767 | Heads are returned in topological order, from newest to oldest. |
|
2758 | 2768 | If branch is None, use the dirstate branch. |
|
2759 | 2769 | If start is not None, return only heads reachable from start. |
|
2760 | 2770 | If closed is True, return heads that are marked as closed as well. |
|
2761 | 2771 | ''' |
|
2762 | 2772 | if branch is None: |
|
2763 | 2773 | branch = self[None].branch() |
|
2764 | 2774 | branches = self.branchmap() |
|
2765 | 2775 | if not branches.hasbranch(branch): |
|
2766 | 2776 | return [] |
|
2767 | 2777 | # the cache returns heads ordered lowest to highest |
|
2768 | 2778 | bheads = list(reversed(branches.branchheads(branch, closed=closed))) |
|
2769 | 2779 | if start is not None: |
|
2770 | 2780 | # filter out the heads that cannot be reached from startrev |
|
2771 | 2781 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
2772 | 2782 | bheads = [h for h in bheads if h in fbheads] |
|
2773 | 2783 | return bheads |
|
2774 | 2784 | |
|
2775 | 2785 | def branches(self, nodes): |
|
2776 | 2786 | if not nodes: |
|
2777 | 2787 | nodes = [self.changelog.tip()] |
|
2778 | 2788 | b = [] |
|
2779 | 2789 | for n in nodes: |
|
2780 | 2790 | t = n |
|
2781 | 2791 | while True: |
|
2782 | 2792 | p = self.changelog.parents(n) |
|
2783 | 2793 | if p[1] != nullid or p[0] == nullid: |
|
2784 | 2794 | b.append((t, n, p[0], p[1])) |
|
2785 | 2795 | break |
|
2786 | 2796 | n = p[0] |
|
2787 | 2797 | return b |
|
2788 | 2798 | |
|
2789 | 2799 | def between(self, pairs): |
|
2790 | 2800 | r = [] |
|
2791 | 2801 | |
|
2792 | 2802 | for top, bottom in pairs: |
|
2793 | 2803 | n, l, i = top, [], 0 |
|
2794 | 2804 | f = 1 |
|
2795 | 2805 | |
|
2796 | 2806 | while n != bottom and n != nullid: |
|
2797 | 2807 | p = self.changelog.parents(n)[0] |
|
2798 | 2808 | if i == f: |
|
2799 | 2809 | l.append(n) |
|
2800 | 2810 | f = f * 2 |
|
2801 | 2811 | n = p |
|
2802 | 2812 | i += 1 |
|
2803 | 2813 | |
|
2804 | 2814 | r.append(l) |
|
2805 | 2815 | |
|
2806 | 2816 | return r |
|
2807 | 2817 | |
|
2808 | 2818 | def checkpush(self, pushop): |
|
2809 | 2819 | """Extensions can override this function if additional checks have |
|
2810 | 2820 | to be performed before pushing, or call it if they override push |
|
2811 | 2821 | command. |
|
2812 | 2822 | """ |
|
2813 | 2823 | |
|
2814 | 2824 | @unfilteredpropertycache |
|
2815 | 2825 | def prepushoutgoinghooks(self): |
|
2816 | 2826 | """Return util.hooks consists of a pushop with repo, remote, outgoing |
|
2817 | 2827 | methods, which are called before pushing changesets. |
|
2818 | 2828 | """ |
|
2819 | 2829 | return util.hooks() |
|
2820 | 2830 | |
|
2821 | 2831 | def pushkey(self, namespace, key, old, new): |
|
2822 | 2832 | try: |
|
2823 | 2833 | tr = self.currenttransaction() |
|
2824 | 2834 | hookargs = {} |
|
2825 | 2835 | if tr is not None: |
|
2826 | 2836 | hookargs.update(tr.hookargs) |
|
2827 | 2837 | hookargs = pycompat.strkwargs(hookargs) |
|
2828 | 2838 | hookargs[r'namespace'] = namespace |
|
2829 | 2839 | hookargs[r'key'] = key |
|
2830 | 2840 | hookargs[r'old'] = old |
|
2831 | 2841 | hookargs[r'new'] = new |
|
2832 | 2842 | self.hook('prepushkey', throw=True, **hookargs) |
|
2833 | 2843 | except error.HookAbort as exc: |
|
2834 | 2844 | self.ui.write_err(_("pushkey-abort: %s\n") % exc) |
|
2835 | 2845 | if exc.hint: |
|
2836 | 2846 | self.ui.write_err(_("(%s)\n") % exc.hint) |
|
2837 | 2847 | return False |
|
2838 | 2848 | self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key)) |
|
2839 | 2849 | ret = pushkey.push(self, namespace, key, old, new) |
|
2840 | 2850 | def runhook(): |
|
2841 | 2851 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
2842 | 2852 | ret=ret) |
|
2843 | 2853 | self._afterlock(runhook) |
|
2844 | 2854 | return ret |
|
2845 | 2855 | |
|
2846 | 2856 | def listkeys(self, namespace): |
|
2847 | 2857 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
2848 | 2858 | self.ui.debug('listing keys for "%s"\n' % namespace) |
|
2849 | 2859 | values = pushkey.list(self, namespace) |
|
2850 | 2860 | self.hook('listkeys', namespace=namespace, values=values) |
|
2851 | 2861 | return values |
|
2852 | 2862 | |
|
2853 | 2863 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
2854 | 2864 | '''used to test argument passing over the wire''' |
|
2855 | 2865 | return "%s %s %s %s %s" % (one, two, pycompat.bytestr(three), |
|
2856 | 2866 | pycompat.bytestr(four), |
|
2857 | 2867 | pycompat.bytestr(five)) |
|
2858 | 2868 | |
|
2859 | 2869 | def savecommitmessage(self, text): |
|
2860 | 2870 | fp = self.vfs('last-message.txt', 'wb') |
|
2861 | 2871 | try: |
|
2862 | 2872 | fp.write(text) |
|
2863 | 2873 | finally: |
|
2864 | 2874 | fp.close() |
|
2865 | 2875 | return self.pathto(fp.name[len(self.root) + 1:]) |
|
2866 | 2876 | |
|
2867 | 2877 | # used to avoid circular references so destructors work |
|
2868 | 2878 | def aftertrans(files): |
|
2869 | 2879 | renamefiles = [tuple(t) for t in files] |
|
2870 | 2880 | def a(): |
|
2871 | 2881 | for vfs, src, dest in renamefiles: |
|
2872 | 2882 | # if src and dest refer to a same file, vfs.rename is a no-op, |
|
2873 | 2883 | # leaving both src and dest on disk. delete dest to make sure |
|
2874 | 2884 | # the rename couldn't be such a no-op. |
|
2875 | 2885 | vfs.tryunlink(dest) |
|
2876 | 2886 | try: |
|
2877 | 2887 | vfs.rename(src, dest) |
|
2878 | 2888 | except OSError: # journal file does not yet exist |
|
2879 | 2889 | pass |
|
2880 | 2890 | return a |
|
2881 | 2891 | |
|
2882 | 2892 | def undoname(fn): |
|
2883 | 2893 | base, name = os.path.split(fn) |
|
2884 | 2894 | assert name.startswith('journal') |
|
2885 | 2895 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
2886 | 2896 | |
|
2887 | 2897 | def instance(ui, path, create, intents=None, createopts=None): |
|
2888 | 2898 | localpath = util.urllocalpath(path) |
|
2889 | 2899 | if create: |
|
2890 | 2900 | createrepository(ui, localpath, createopts=createopts) |
|
2891 | 2901 | |
|
2892 | 2902 | return makelocalrepository(ui, localpath, intents=intents) |
|
2893 | 2903 | |
|
2894 | 2904 | def islocal(path): |
|
2895 | 2905 | return True |
|
2896 | 2906 | |
|
2897 | 2907 | def defaultcreateopts(ui, createopts=None): |
|
2898 | 2908 | """Populate the default creation options for a repository. |
|
2899 | 2909 | |
|
2900 | 2910 | A dictionary of explicitly requested creation options can be passed |
|
2901 | 2911 | in. Missing keys will be populated. |
|
2902 | 2912 | """ |
|
2903 | 2913 | createopts = dict(createopts or {}) |
|
2904 | 2914 | |
|
2905 | 2915 | if 'backend' not in createopts: |
|
2906 | 2916 | # experimental config: storage.new-repo-backend |
|
2907 | 2917 | createopts['backend'] = ui.config('storage', 'new-repo-backend') |
|
2908 | 2918 | |
|
2909 | 2919 | return createopts |
|
2910 | 2920 | |
|
2911 | 2921 | def newreporequirements(ui, createopts): |
|
2912 | 2922 | """Determine the set of requirements for a new local repository. |
|
2913 | 2923 | |
|
2914 | 2924 | Extensions can wrap this function to specify custom requirements for |
|
2915 | 2925 | new repositories. |
|
2916 | 2926 | """ |
|
2917 | 2927 | # If the repo is being created from a shared repository, we copy |
|
2918 | 2928 | # its requirements. |
|
2919 | 2929 | if 'sharedrepo' in createopts: |
|
2920 | 2930 | requirements = set(createopts['sharedrepo'].requirements) |
|
2921 | 2931 | if createopts.get('sharedrelative'): |
|
2922 | 2932 | requirements.add('relshared') |
|
2923 | 2933 | else: |
|
2924 | 2934 | requirements.add('shared') |
|
2925 | 2935 | |
|
2926 | 2936 | return requirements |
|
2927 | 2937 | |
|
2928 | 2938 | if 'backend' not in createopts: |
|
2929 | 2939 | raise error.ProgrammingError('backend key not present in createopts; ' |
|
2930 | 2940 | 'was defaultcreateopts() called?') |
|
2931 | 2941 | |
|
2932 | 2942 | if createopts['backend'] != 'revlogv1': |
|
2933 | 2943 | raise error.Abort(_('unable to determine repository requirements for ' |
|
2934 | 2944 | 'storage backend: %s') % createopts['backend']) |
|
2935 | 2945 | |
|
2936 | 2946 | requirements = {'revlogv1'} |
|
2937 | 2947 | if ui.configbool('format', 'usestore'): |
|
2938 | 2948 | requirements.add('store') |
|
2939 | 2949 | if ui.configbool('format', 'usefncache'): |
|
2940 | 2950 | requirements.add('fncache') |
|
2941 | 2951 | if ui.configbool('format', 'dotencode'): |
|
2942 | 2952 | requirements.add('dotencode') |
|
2943 | 2953 | |
|
2944 | 2954 | compengine = ui.config('format', 'revlog-compression') |
|
2945 | 2955 | if compengine not in util.compengines: |
|
2946 | 2956 | raise error.Abort(_('compression engine %s defined by ' |
|
2947 | 2957 | 'format.revlog-compression not available') % |
|
2948 | 2958 | compengine, |
|
2949 | 2959 | hint=_('run "hg debuginstall" to list available ' |
|
2950 | 2960 | 'compression engines')) |
|
2951 | 2961 | |
|
2952 | 2962 | # zlib is the historical default and doesn't need an explicit requirement. |
|
2953 | 2963 | elif compengine == 'zstd': |
|
2954 | 2964 | requirements.add('revlog-compression-zstd') |
|
2955 | 2965 | elif compengine != 'zlib': |
|
2956 | 2966 | requirements.add('exp-compression-%s' % compengine) |
|
2957 | 2967 | |
|
2958 | 2968 | if scmutil.gdinitconfig(ui): |
|
2959 | 2969 | requirements.add('generaldelta') |
|
2960 | 2970 | if ui.configbool('format', 'sparse-revlog'): |
|
2961 | 2971 | requirements.add(SPARSEREVLOG_REQUIREMENT) |
|
2962 | 2972 | if ui.configbool('experimental', 'treemanifest'): |
|
2963 | 2973 | requirements.add('treemanifest') |
|
2964 | 2974 | |
|
2965 | 2975 | revlogv2 = ui.config('experimental', 'revlogv2') |
|
2966 | 2976 | if revlogv2 == 'enable-unstable-format-and-corrupt-my-data': |
|
2967 | 2977 | requirements.remove('revlogv1') |
|
2968 | 2978 | # generaldelta is implied by revlogv2. |
|
2969 | 2979 | requirements.discard('generaldelta') |
|
2970 | 2980 | requirements.add(REVLOGV2_REQUIREMENT) |
|
2971 | 2981 | # experimental config: format.internal-phase |
|
2972 | 2982 | if ui.configbool('format', 'internal-phase'): |
|
2973 | 2983 | requirements.add('internal-phase') |
|
2974 | 2984 | |
|
2975 | 2985 | if createopts.get('narrowfiles'): |
|
2976 | 2986 | requirements.add(repository.NARROW_REQUIREMENT) |
|
2977 | 2987 | |
|
2978 | 2988 | if createopts.get('lfs'): |
|
2979 | 2989 | requirements.add('lfs') |
|
2980 | 2990 | |
|
2981 | 2991 | return requirements |
|
2982 | 2992 | |
|
2983 | 2993 | def filterknowncreateopts(ui, createopts): |
|
2984 | 2994 | """Filters a dict of repo creation options against options that are known. |
|
2985 | 2995 | |
|
2986 | 2996 | Receives a dict of repo creation options and returns a dict of those |
|
2987 | 2997 | options that we don't know how to handle. |
|
2988 | 2998 | |
|
2989 | 2999 | This function is called as part of repository creation. If the |
|
2990 | 3000 | returned dict contains any items, repository creation will not |
|
2991 | 3001 | be allowed, as it means there was a request to create a repository |
|
2992 | 3002 | with options not recognized by loaded code. |
|
2993 | 3003 | |
|
2994 | 3004 | Extensions can wrap this function to filter out creation options |
|
2995 | 3005 | they know how to handle. |
|
2996 | 3006 | """ |
|
2997 | 3007 | known = { |
|
2998 | 3008 | 'backend', |
|
2999 | 3009 | 'lfs', |
|
3000 | 3010 | 'narrowfiles', |
|
3001 | 3011 | 'sharedrepo', |
|
3002 | 3012 | 'sharedrelative', |
|
3003 | 3013 | 'shareditems', |
|
3004 | 3014 | 'shallowfilestore', |
|
3005 | 3015 | } |
|
3006 | 3016 | |
|
3007 | 3017 | return {k: v for k, v in createopts.items() if k not in known} |
|
3008 | 3018 | |
|
3009 | 3019 | def createrepository(ui, path, createopts=None): |
|
3010 | 3020 | """Create a new repository in a vfs. |
|
3011 | 3021 | |
|
3012 | 3022 | ``path`` path to the new repo's working directory. |
|
3013 | 3023 | ``createopts`` options for the new repository. |
|
3014 | 3024 | |
|
3015 | 3025 | The following keys for ``createopts`` are recognized: |
|
3016 | 3026 | |
|
3017 | 3027 | backend |
|
3018 | 3028 | The storage backend to use. |
|
3019 | 3029 | lfs |
|
3020 | 3030 | Repository will be created with ``lfs`` requirement. The lfs extension |
|
3021 | 3031 | will automatically be loaded when the repository is accessed. |
|
3022 | 3032 | narrowfiles |
|
3023 | 3033 | Set up repository to support narrow file storage. |
|
3024 | 3034 | sharedrepo |
|
3025 | 3035 | Repository object from which storage should be shared. |
|
3026 | 3036 | sharedrelative |
|
3027 | 3037 | Boolean indicating if the path to the shared repo should be |
|
3028 | 3038 | stored as relative. By default, the pointer to the "parent" repo |
|
3029 | 3039 | is stored as an absolute path. |
|
3030 | 3040 | shareditems |
|
3031 | 3041 | Set of items to share to the new repository (in addition to storage). |
|
3032 | 3042 | shallowfilestore |
|
3033 | 3043 | Indicates that storage for files should be shallow (not all ancestor |
|
3034 | 3044 | revisions are known). |
|
3035 | 3045 | """ |
|
3036 | 3046 | createopts = defaultcreateopts(ui, createopts=createopts) |
|
3037 | 3047 | |
|
3038 | 3048 | unknownopts = filterknowncreateopts(ui, createopts) |
|
3039 | 3049 | |
|
3040 | 3050 | if not isinstance(unknownopts, dict): |
|
3041 | 3051 | raise error.ProgrammingError('filterknowncreateopts() did not return ' |
|
3042 | 3052 | 'a dict') |
|
3043 | 3053 | |
|
3044 | 3054 | if unknownopts: |
|
3045 | 3055 | raise error.Abort(_('unable to create repository because of unknown ' |
|
3046 | 3056 | 'creation option: %s') % |
|
3047 | 3057 | ', '.join(sorted(unknownopts)), |
|
3048 | 3058 | hint=_('is a required extension not loaded?')) |
|
3049 | 3059 | |
|
3050 | 3060 | requirements = newreporequirements(ui, createopts=createopts) |
|
3051 | 3061 | |
|
3052 | 3062 | wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) |
|
3053 | 3063 | |
|
3054 | 3064 | hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg')) |
|
3055 | 3065 | if hgvfs.exists(): |
|
3056 | 3066 | raise error.RepoError(_('repository %s already exists') % path) |
|
3057 | 3067 | |
|
3058 | 3068 | if 'sharedrepo' in createopts: |
|
3059 | 3069 | sharedpath = createopts['sharedrepo'].sharedpath |
|
3060 | 3070 | |
|
3061 | 3071 | if createopts.get('sharedrelative'): |
|
3062 | 3072 | try: |
|
3063 | 3073 | sharedpath = os.path.relpath(sharedpath, hgvfs.base) |
|
3064 | 3074 | except (IOError, ValueError) as e: |
|
3065 | 3075 | # ValueError is raised on Windows if the drive letters differ |
|
3066 | 3076 | # on each path. |
|
3067 | 3077 | raise error.Abort(_('cannot calculate relative path'), |
|
3068 | 3078 | hint=stringutil.forcebytestr(e)) |
|
3069 | 3079 | |
|
3070 | 3080 | if not wdirvfs.exists(): |
|
3071 | 3081 | wdirvfs.makedirs() |
|
3072 | 3082 | |
|
3073 | 3083 | hgvfs.makedir(notindexed=True) |
|
3074 | 3084 | if 'sharedrepo' not in createopts: |
|
3075 | 3085 | hgvfs.mkdir(b'cache') |
|
3076 | 3086 | hgvfs.mkdir(b'wcache') |
|
3077 | 3087 | |
|
3078 | 3088 | if b'store' in requirements and 'sharedrepo' not in createopts: |
|
3079 | 3089 | hgvfs.mkdir(b'store') |
|
3080 | 3090 | |
|
3081 | 3091 | # We create an invalid changelog outside the store so very old |
|
3082 | 3092 | # Mercurial versions (which didn't know about the requirements |
|
3083 | 3093 | # file) encounter an error on reading the changelog. This |
|
3084 | 3094 | # effectively locks out old clients and prevents them from |
|
3085 | 3095 | # mucking with a repo in an unknown format. |
|
3086 | 3096 | # |
|
3087 | 3097 | # The revlog header has version 2, which won't be recognized by |
|
3088 | 3098 | # such old clients. |
|
3089 | 3099 | hgvfs.append(b'00changelog.i', |
|
3090 | 3100 | b'\0\0\0\2 dummy changelog to prevent using the old repo ' |
|
3091 | 3101 | b'layout') |
|
3092 | 3102 | |
|
3093 | 3103 | scmutil.writerequires(hgvfs, requirements) |
|
3094 | 3104 | |
|
3095 | 3105 | # Write out file telling readers where to find the shared store. |
|
3096 | 3106 | if 'sharedrepo' in createopts: |
|
3097 | 3107 | hgvfs.write(b'sharedpath', sharedpath) |
|
3098 | 3108 | |
|
3099 | 3109 | if createopts.get('shareditems'): |
|
3100 | 3110 | shared = b'\n'.join(sorted(createopts['shareditems'])) + b'\n' |
|
3101 | 3111 | hgvfs.write(b'shared', shared) |
|
3102 | 3112 | |
|
3103 | 3113 | def poisonrepository(repo): |
|
3104 | 3114 | """Poison a repository instance so it can no longer be used.""" |
|
3105 | 3115 | # Perform any cleanup on the instance. |
|
3106 | 3116 | repo.close() |
|
3107 | 3117 | |
|
3108 | 3118 | # Our strategy is to replace the type of the object with one that |
|
3109 | 3119 | # has all attribute lookups result in error. |
|
3110 | 3120 | # |
|
3111 | 3121 | # But we have to allow the close() method because some constructors |
|
3112 | 3122 | # of repos call close() on repo references. |
|
3113 | 3123 | class poisonedrepository(object): |
|
3114 | 3124 | def __getattribute__(self, item): |
|
3115 | 3125 | if item == r'close': |
|
3116 | 3126 | return object.__getattribute__(self, item) |
|
3117 | 3127 | |
|
3118 | 3128 | raise error.ProgrammingError('repo instances should not be used ' |
|
3119 | 3129 | 'after unshare') |
|
3120 | 3130 | |
|
3121 | 3131 | def close(self): |
|
3122 | 3132 | pass |
|
3123 | 3133 | |
|
3124 | 3134 | # We may have a repoview, which intercepts __setattr__. So be sure |
|
3125 | 3135 | # we operate at the lowest level possible. |
|
3126 | 3136 | object.__setattr__(repo, r'__class__', poisonedrepository) |
@@ -1,1080 +1,1080 | |||
|
1 | 1 | $ HGMERGE=true; export HGMERGE |
|
2 | 2 | |
|
3 | 3 | init |
|
4 | 4 | |
|
5 | 5 | $ hg init repo |
|
6 | 6 | $ cd repo |
|
7 | 7 | |
|
8 | 8 | commit |
|
9 | 9 | |
|
10 | 10 | $ echo 'a' > a |
|
11 | 11 | $ hg ci -A -m test -u nobody -d '1 0' |
|
12 | 12 | adding a |
|
13 | 13 | |
|
14 | 14 | annotate -c |
|
15 | 15 | |
|
16 | 16 | $ hg annotate -c a |
|
17 | 17 | 8435f90966e4: a |
|
18 | 18 | |
|
19 | 19 | annotate -cl |
|
20 | 20 | |
|
21 | 21 | $ hg annotate -cl a |
|
22 | 22 | 8435f90966e4:1: a |
|
23 | 23 | |
|
24 | 24 | annotate -d |
|
25 | 25 | |
|
26 | 26 | $ hg annotate -d a |
|
27 | 27 | Thu Jan 01 00:00:01 1970 +0000: a |
|
28 | 28 | |
|
29 | 29 | annotate -n |
|
30 | 30 | |
|
31 | 31 | $ hg annotate -n a |
|
32 | 32 | 0: a |
|
33 | 33 | |
|
34 | 34 | annotate -nl |
|
35 | 35 | |
|
36 | 36 | $ hg annotate -nl a |
|
37 | 37 | 0:1: a |
|
38 | 38 | |
|
39 | 39 | annotate -u |
|
40 | 40 | |
|
41 | 41 | $ hg annotate -u a |
|
42 | 42 | nobody: a |
|
43 | 43 | |
|
44 | 44 | annotate -cdnu |
|
45 | 45 | |
|
46 | 46 | $ hg annotate -cdnu a |
|
47 | 47 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a |
|
48 | 48 | |
|
49 | 49 | annotate -cdnul |
|
50 | 50 | |
|
51 | 51 | $ hg annotate -cdnul a |
|
52 | 52 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a |
|
53 | 53 | |
|
54 | 54 | annotate (JSON) |
|
55 | 55 | |
|
56 | 56 | $ hg annotate -Tjson a |
|
57 | 57 | [ |
|
58 | 58 | { |
|
59 | 59 | "lines": [{"line": "a\n", "rev": 0}], |
|
60 | 60 | "path": "a" |
|
61 | 61 | } |
|
62 | 62 | ] |
|
63 | 63 | |
|
64 | 64 | $ hg annotate -Tjson -cdfnul a |
|
65 | 65 | [ |
|
66 | 66 | { |
|
67 | 67 | "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], |
|
68 | 68 | "path": "a" |
|
69 | 69 | } |
|
70 | 70 | ] |
|
71 | 71 | |
|
72 | 72 | log-like templating |
|
73 | 73 | |
|
74 | 74 | $ hg annotate -T'{lines % "{rev} {node|shortest}: {line}"}' a |
|
75 | 75 | 0 8435: a |
|
76 | 76 | |
|
77 | 77 | '{lineno}' field should be populated as necessary |
|
78 | 78 | |
|
79 | 79 | $ hg annotate -T'{lines % "{rev}:{lineno}: {line}"}' a |
|
80 | 80 | 0:1: a |
|
81 | 81 | $ hg annotate -Ta a \ |
|
82 | 82 | > --config templates.a='"{lines % "{rev}:{lineno}: {line}"}"' |
|
83 | 83 | 0:1: a |
|
84 | 84 | |
|
85 | 85 | $ cat <<EOF >>a |
|
86 | 86 | > a |
|
87 | 87 | > a |
|
88 | 88 | > EOF |
|
89 | 89 | $ hg ci -ma1 -d '1 0' |
|
90 | 90 | $ hg cp a b |
|
91 | 91 | $ hg ci -mb -d '1 0' |
|
92 | 92 | $ cat <<EOF >> b |
|
93 | 93 | > b4 |
|
94 | 94 | > b5 |
|
95 | 95 | > b6 |
|
96 | 96 | > EOF |
|
97 | 97 | $ hg ci -mb2 -d '2 0' |
|
98 | 98 | |
|
99 | 99 | default output of '{lines}' should be readable |
|
100 | 100 | |
|
101 | 101 | $ hg annotate -T'{lines}' a |
|
102 | 102 | 0: a |
|
103 | 103 | 1: a |
|
104 | 104 | 1: a |
|
105 | 105 | $ hg annotate -T'{join(lines, "\n")}' a |
|
106 | 106 | 0: a |
|
107 | 107 | |
|
108 | 108 | 1: a |
|
109 | 109 | |
|
110 | 110 | 1: a |
|
111 | 111 | |
|
112 | 112 | several filters can be applied to '{lines}' |
|
113 | 113 | |
|
114 | 114 | $ hg annotate -T'{lines|json}\n' a |
|
115 | 115 | [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}] |
|
116 | 116 | $ hg annotate -T'{lines|stringify}' a |
|
117 | 117 | 0: a |
|
118 | 118 | 1: a |
|
119 | 119 | 1: a |
|
120 | 120 | $ hg annotate -T'{lines|count}\n' a |
|
121 | 121 | 3 |
|
122 | 122 | |
|
123 | 123 | annotate multiple files (JSON) |
|
124 | 124 | |
|
125 | 125 | $ hg annotate -Tjson a b |
|
126 | 126 | [ |
|
127 | 127 | { |
|
128 | 128 | "lines": [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}], |
|
129 | 129 | "path": "a" |
|
130 | 130 | }, |
|
131 | 131 | { |
|
132 | 132 | "lines": [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}, {"line": "b4\n", "rev": 3}, {"line": "b5\n", "rev": 3}, {"line": "b6\n", "rev": 3}], |
|
133 | 133 | "path": "b" |
|
134 | 134 | } |
|
135 | 135 | ] |
|
136 | 136 | |
|
137 | 137 | annotate multiple files (template) |
|
138 | 138 | |
|
139 | 139 | $ hg annotate -T'== {path} ==\n{lines % "{rev}: {line}"}' a b |
|
140 | 140 | == a == |
|
141 | 141 | 0: a |
|
142 | 142 | 1: a |
|
143 | 143 | 1: a |
|
144 | 144 | == b == |
|
145 | 145 | 0: a |
|
146 | 146 | 1: a |
|
147 | 147 | 1: a |
|
148 | 148 | 3: b4 |
|
149 | 149 | 3: b5 |
|
150 | 150 | 3: b6 |
|
151 | 151 | |
|
152 | 152 | annotate -n b |
|
153 | 153 | |
|
154 | 154 | $ hg annotate -n b |
|
155 | 155 | 0: a |
|
156 | 156 | 1: a |
|
157 | 157 | 1: a |
|
158 | 158 | 3: b4 |
|
159 | 159 | 3: b5 |
|
160 | 160 | 3: b6 |
|
161 | 161 | |
|
162 | 162 | annotate --no-follow b |
|
163 | 163 | |
|
164 | 164 | $ hg annotate --no-follow b |
|
165 | 165 | 2: a |
|
166 | 166 | 2: a |
|
167 | 167 | 2: a |
|
168 | 168 | 3: b4 |
|
169 | 169 | 3: b5 |
|
170 | 170 | 3: b6 |
|
171 | 171 | |
|
172 | 172 | annotate -nl b |
|
173 | 173 | |
|
174 | 174 | $ hg annotate -nl b |
|
175 | 175 | 0:1: a |
|
176 | 176 | 1:2: a |
|
177 | 177 | 1:3: a |
|
178 | 178 | 3:4: b4 |
|
179 | 179 | 3:5: b5 |
|
180 | 180 | 3:6: b6 |
|
181 | 181 | |
|
182 | 182 | annotate -nf b |
|
183 | 183 | |
|
184 | 184 | $ hg annotate -nf b |
|
185 | 185 | 0 a: a |
|
186 | 186 | 1 a: a |
|
187 | 187 | 1 a: a |
|
188 | 188 | 3 b: b4 |
|
189 | 189 | 3 b: b5 |
|
190 | 190 | 3 b: b6 |
|
191 | 191 | |
|
192 | 192 | annotate -nlf b |
|
193 | 193 | |
|
194 | 194 | $ hg annotate -nlf b |
|
195 | 195 | 0 a:1: a |
|
196 | 196 | 1 a:2: a |
|
197 | 197 | 1 a:3: a |
|
198 | 198 | 3 b:4: b4 |
|
199 | 199 | 3 b:5: b5 |
|
200 | 200 | 3 b:6: b6 |
|
201 | 201 | |
|
202 | 202 | $ hg up -C 2 |
|
203 | 203 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
204 | 204 | $ cat <<EOF >> b |
|
205 | 205 | > b4 |
|
206 | 206 | > c |
|
207 | 207 | > b5 |
|
208 | 208 | > EOF |
|
209 | 209 | $ hg ci -mb2.1 -d '2 0' |
|
210 | 210 | created new head |
|
211 | 211 | $ hg merge |
|
212 | 212 | merging b |
|
213 | 213 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
214 | 214 | (branch merge, don't forget to commit) |
|
215 | 215 | $ hg ci -mmergeb -d '3 0' |
|
216 | 216 | |
|
217 | 217 | annotate after merge |
|
218 | 218 | |
|
219 | 219 | $ hg annotate -nf b |
|
220 | 220 | 0 a: a |
|
221 | 221 | 1 a: a |
|
222 | 222 | 1 a: a |
|
223 | 223 | 3 b: b4 |
|
224 | 224 | 4 b: c |
|
225 | 225 | 3 b: b5 |
|
226 | 226 | |
|
227 | 227 | annotate after merge with -l |
|
228 | 228 | |
|
229 | 229 | $ hg annotate -nlf b |
|
230 | 230 | 0 a:1: a |
|
231 | 231 | 1 a:2: a |
|
232 | 232 | 1 a:3: a |
|
233 | 233 | 3 b:4: b4 |
|
234 | 234 | 4 b:5: c |
|
235 | 235 | 3 b:5: b5 |
|
236 | 236 | |
|
237 | 237 | $ hg up -C 1 |
|
238 | 238 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
239 | 239 | $ hg cp a b |
|
240 | 240 | $ cat <<EOF > b |
|
241 | 241 | > a |
|
242 | 242 | > z |
|
243 | 243 | > a |
|
244 | 244 | > EOF |
|
245 | 245 | $ hg ci -mc -d '3 0' |
|
246 | 246 | created new head |
|
247 | 247 | $ hg merge |
|
248 | 248 | merging b |
|
249 | 249 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
250 | 250 | (branch merge, don't forget to commit) |
|
251 | 251 | $ cat <<EOF >> b |
|
252 | 252 | > b4 |
|
253 | 253 | > c |
|
254 | 254 | > b5 |
|
255 | 255 | > EOF |
|
256 | 256 | $ echo d >> b |
|
257 | 257 | $ hg ci -mmerge2 -d '4 0' |
|
258 | 258 | |
|
259 | 259 | annotate after rename merge |
|
260 | 260 | |
|
261 | 261 | $ hg annotate -nf b |
|
262 | 262 | 0 a: a |
|
263 | 263 | 6 b: z |
|
264 | 264 | 1 a: a |
|
265 | 265 | 3 b: b4 |
|
266 | 266 | 4 b: c |
|
267 | 267 | 3 b: b5 |
|
268 | 268 | 7 b: d |
|
269 | 269 | |
|
270 | 270 | annotate after rename merge with -l |
|
271 | 271 | |
|
272 | 272 | $ hg annotate -nlf b |
|
273 | 273 | 0 a:1: a |
|
274 | 274 | 6 b:2: z |
|
275 | 275 | 1 a:3: a |
|
276 | 276 | 3 b:4: b4 |
|
277 | 277 | 4 b:5: c |
|
278 | 278 | 3 b:5: b5 |
|
279 | 279 | 7 b:7: d |
|
280 | 280 | |
|
281 | 281 | --skip nothing (should be the same as no --skip at all) |
|
282 | 282 | |
|
283 | 283 | $ hg annotate -nlf b --skip '1::0' |
|
284 | 284 | 0 a:1: a |
|
285 | 285 | 6 b:2: z |
|
286 | 286 | 1 a:3: a |
|
287 | 287 | 3 b:4: b4 |
|
288 | 288 | 4 b:5: c |
|
289 | 289 | 3 b:5: b5 |
|
290 | 290 | 7 b:7: d |
|
291 | 291 | |
|
292 | 292 | --skip a modified line. Note a slight behavior difference in pure - this is |
|
293 | 293 | because the pure code comes up with slightly different deltas internally. |
|
294 | 294 | |
|
295 | 295 | $ hg annotate -nlf b --skip 6 |
|
296 | 296 | 0 a:1: a |
|
297 | 297 | 1 a:2* z (no-pure !) |
|
298 | 298 | 0 a:1* z (pure !) |
|
299 | 299 | 1 a:3: a |
|
300 | 300 | 3 b:4: b4 |
|
301 | 301 | 4 b:5: c |
|
302 | 302 | 3 b:5: b5 |
|
303 | 303 | 7 b:7: d |
|
304 | 304 | |
|
305 | 305 | --skip added lines (and test multiple skip) |
|
306 | 306 | |
|
307 | 307 | $ hg annotate -nlf b --skip 3 |
|
308 | 308 | 0 a:1: a |
|
309 | 309 | 6 b:2: z |
|
310 | 310 | 1 a:3: a |
|
311 | 311 | 1 a:3* b4 |
|
312 | 312 | 4 b:5: c |
|
313 | 313 | 1 a:3* b5 |
|
314 | 314 | 7 b:7: d |
|
315 | 315 | |
|
316 | 316 | $ hg annotate -nlf b --skip 4 |
|
317 | 317 | 0 a:1: a |
|
318 | 318 | 6 b:2: z |
|
319 | 319 | 1 a:3: a |
|
320 | 320 | 3 b:4: b4 |
|
321 | 321 | 1 a:3* c |
|
322 | 322 | 3 b:5: b5 |
|
323 | 323 | 7 b:7: d |
|
324 | 324 | |
|
325 | 325 | $ hg annotate -nlf b --skip 3 --skip 4 |
|
326 | 326 | 0 a:1: a |
|
327 | 327 | 6 b:2: z |
|
328 | 328 | 1 a:3: a |
|
329 | 329 | 1 a:3* b4 |
|
330 | 330 | 1 a:3* c |
|
331 | 331 | 1 a:3* b5 |
|
332 | 332 | 7 b:7: d |
|
333 | 333 | |
|
334 | 334 | $ hg annotate -nlf b --skip 'merge()' |
|
335 | 335 | 0 a:1: a |
|
336 | 336 | 6 b:2: z |
|
337 | 337 | 1 a:3: a |
|
338 | 338 | 3 b:4: b4 |
|
339 | 339 | 4 b:5: c |
|
340 | 340 | 3 b:5: b5 |
|
341 | 341 | 3 b:5* d |
|
342 | 342 | |
|
343 | 343 | --skip everything -- use the revision the file was introduced in |
|
344 | 344 | |
|
345 | 345 | $ hg annotate -nlf b --skip 'all()' |
|
346 | 346 | 0 a:1: a |
|
347 | 347 | 0 a:1* z |
|
348 | 348 | 0 a:1* a |
|
349 | 349 | 0 a:1* b4 |
|
350 | 350 | 0 a:1* c |
|
351 | 351 | 0 a:1* b5 |
|
352 | 352 | 0 a:1* d |
|
353 | 353 | |
|
354 | 354 | Issue2807: alignment of line numbers with -l |
|
355 | 355 | |
|
356 | 356 | $ echo more >> b |
|
357 | 357 | $ hg ci -mmore -d '5 0' |
|
358 | 358 | $ echo more >> b |
|
359 | 359 | $ hg ci -mmore -d '6 0' |
|
360 | 360 | $ echo more >> b |
|
361 | 361 | $ hg ci -mmore -d '7 0' |
|
362 | 362 | $ hg annotate -nlf b |
|
363 | 363 | 0 a: 1: a |
|
364 | 364 | 6 b: 2: z |
|
365 | 365 | 1 a: 3: a |
|
366 | 366 | 3 b: 4: b4 |
|
367 | 367 | 4 b: 5: c |
|
368 | 368 | 3 b: 5: b5 |
|
369 | 369 | 7 b: 7: d |
|
370 | 370 | 8 b: 8: more |
|
371 | 371 | 9 b: 9: more |
|
372 | 372 | 10 b:10: more |
|
373 | 373 | |
|
374 | 374 | linkrev vs rev |
|
375 | 375 | |
|
376 | 376 | $ hg annotate -r tip -n a |
|
377 | 377 | 0: a |
|
378 | 378 | 1: a |
|
379 | 379 | 1: a |
|
380 | 380 | |
|
381 | 381 | linkrev vs rev with -l |
|
382 | 382 | |
|
383 | 383 | $ hg annotate -r tip -nl a |
|
384 | 384 | 0:1: a |
|
385 | 385 | 1:2: a |
|
386 | 386 | 1:3: a |
|
387 | 387 | |
|
388 | 388 | Issue589: "undelete" sequence leads to crash |
|
389 | 389 | |
|
390 | 390 | annotate was crashing when trying to --follow something |
|
391 | 391 | |
|
392 | 392 | like A -> B -> A |
|
393 | 393 | |
|
394 | 394 | generate ABA rename configuration |
|
395 | 395 | |
|
396 | 396 | $ echo foo > foo |
|
397 | 397 | $ hg add foo |
|
398 | 398 | $ hg ci -m addfoo |
|
399 | 399 | $ hg rename foo bar |
|
400 | 400 | $ hg ci -m renamefoo |
|
401 | 401 | $ hg rename bar foo |
|
402 | 402 | $ hg ci -m renamebar |
|
403 | 403 | |
|
404 | 404 | annotate after ABA with follow |
|
405 | 405 | |
|
406 | 406 | $ hg annotate --follow foo |
|
407 | 407 | foo: foo |
|
408 | 408 | |
|
409 | 409 | missing file |
|
410 | 410 | |
|
411 | 411 | $ hg ann nosuchfile |
|
412 | 412 | abort: nosuchfile: no such file in rev e9e6b4fa872f |
|
413 | 413 | [255] |
|
414 | 414 | |
|
415 | 415 | annotate file without '\n' on last line |
|
416 | 416 | |
|
417 | 417 | $ printf "" > c |
|
418 | 418 | $ hg ci -A -m test -u nobody -d '1 0' |
|
419 | 419 | adding c |
|
420 | 420 | $ hg annotate c |
|
421 | 421 | $ printf "a\nb" > c |
|
422 | 422 | $ hg ci -m test |
|
423 | 423 | $ hg annotate c |
|
424 | 424 | [0-9]+: a (re) |
|
425 | 425 | [0-9]+: b (re) |
|
426 | 426 | |
|
427 | 427 | Issue3841: check annotation of the file of which filelog includes |
|
428 | 428 | merging between the revision and its ancestor |
|
429 | 429 | |
|
430 | 430 | to reproduce the situation with recent Mercurial, this script uses (1) |
|
431 | 431 | "hg debugsetparents" to merge without ancestor check by "hg merge", |
|
432 | 432 | and (2) the extension to allow filelog merging between the revision |
|
433 | 433 | and its ancestor by overriding "repo._filecommit". |
|
434 | 434 | |
|
435 | 435 | $ cat > ../legacyrepo.py <<EOF |
|
436 | 436 | > from __future__ import absolute_import |
|
437 | 437 | > from mercurial import error, node |
|
438 | 438 | > def reposetup(ui, repo): |
|
439 | 439 | > class legacyrepo(repo.__class__): |
|
440 | 440 | > def _filecommit(self, fctx, manifest1, manifest2, |
|
441 | > linkrev, tr, changelist): | |
|
441 | > linkrev, tr, changelist, includecopymeta): | |
|
442 | 442 | > fname = fctx.path() |
|
443 | 443 | > text = fctx.data() |
|
444 | 444 | > flog = self.file(fname) |
|
445 | 445 | > fparent1 = manifest1.get(fname, node.nullid) |
|
446 | 446 | > fparent2 = manifest2.get(fname, node.nullid) |
|
447 | 447 | > meta = {} |
|
448 | 448 | > copy = fctx.copysource() |
|
449 | 449 | > if copy and copy != fname: |
|
450 | 450 | > raise error.Abort('copying is not supported') |
|
451 | 451 | > if fparent2 != node.nullid: |
|
452 | 452 | > changelist.append(fname) |
|
453 | 453 | > return flog.add(text, meta, tr, linkrev, |
|
454 | 454 | > fparent1, fparent2) |
|
455 | 455 | > raise error.Abort('only merging is supported') |
|
456 | 456 | > repo.__class__ = legacyrepo |
|
457 | 457 | > EOF |
|
458 | 458 | |
|
459 | 459 | $ cat > baz <<EOF |
|
460 | 460 | > 1 |
|
461 | 461 | > 2 |
|
462 | 462 | > 3 |
|
463 | 463 | > 4 |
|
464 | 464 | > 5 |
|
465 | 465 | > EOF |
|
466 | 466 | $ hg add baz |
|
467 | 467 | $ hg commit -m "baz:0" |
|
468 | 468 | |
|
469 | 469 | $ cat > baz <<EOF |
|
470 | 470 | > 1 baz:1 |
|
471 | 471 | > 2 |
|
472 | 472 | > 3 |
|
473 | 473 | > 4 |
|
474 | 474 | > 5 |
|
475 | 475 | > EOF |
|
476 | 476 | $ hg commit -m "baz:1" |
|
477 | 477 | |
|
478 | 478 | $ cat > baz <<EOF |
|
479 | 479 | > 1 baz:1 |
|
480 | 480 | > 2 baz:2 |
|
481 | 481 | > 3 |
|
482 | 482 | > 4 |
|
483 | 483 | > 5 |
|
484 | 484 | > EOF |
|
485 | 485 | $ hg debugsetparents 17 17 |
|
486 | 486 | $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:2" |
|
487 | 487 | $ hg debugindexdot baz |
|
488 | 488 | digraph G { |
|
489 | 489 | -1 -> 0 |
|
490 | 490 | 0 -> 1 |
|
491 | 491 | 1 -> 2 |
|
492 | 492 | 1 -> 2 |
|
493 | 493 | } |
|
494 | 494 | $ hg annotate baz |
|
495 | 495 | 17: 1 baz:1 |
|
496 | 496 | 18: 2 baz:2 |
|
497 | 497 | 16: 3 |
|
498 | 498 | 16: 4 |
|
499 | 499 | 16: 5 |
|
500 | 500 | |
|
501 | 501 | $ cat > baz <<EOF |
|
502 | 502 | > 1 baz:1 |
|
503 | 503 | > 2 baz:2 |
|
504 | 504 | > 3 baz:3 |
|
505 | 505 | > 4 |
|
506 | 506 | > 5 |
|
507 | 507 | > EOF |
|
508 | 508 | $ hg commit -m "baz:3" |
|
509 | 509 | |
|
510 | 510 | $ cat > baz <<EOF |
|
511 | 511 | > 1 baz:1 |
|
512 | 512 | > 2 baz:2 |
|
513 | 513 | > 3 baz:3 |
|
514 | 514 | > 4 baz:4 |
|
515 | 515 | > 5 |
|
516 | 516 | > EOF |
|
517 | 517 | $ hg debugsetparents 19 18 |
|
518 | 518 | $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:4" |
|
519 | 519 | $ hg debugindexdot baz |
|
520 | 520 | digraph G { |
|
521 | 521 | -1 -> 0 |
|
522 | 522 | 0 -> 1 |
|
523 | 523 | 1 -> 2 |
|
524 | 524 | 1 -> 2 |
|
525 | 525 | 2 -> 3 |
|
526 | 526 | 3 -> 4 |
|
527 | 527 | 2 -> 4 |
|
528 | 528 | } |
|
529 | 529 | $ hg annotate baz |
|
530 | 530 | 17: 1 baz:1 |
|
531 | 531 | 18: 2 baz:2 |
|
532 | 532 | 19: 3 baz:3 |
|
533 | 533 | 20: 4 baz:4 |
|
534 | 534 | 16: 5 |
|
535 | 535 | |
|
536 | 536 | annotate clean file |
|
537 | 537 | |
|
538 | 538 | $ hg annotate -ncr "wdir()" foo |
|
539 | 539 | 11 472b18db256d : foo |
|
540 | 540 | |
|
541 | 541 | annotate modified file |
|
542 | 542 | |
|
543 | 543 | $ echo foofoo >> foo |
|
544 | 544 | $ hg annotate -r "wdir()" foo |
|
545 | 545 | 11 : foo |
|
546 | 546 | 20+: foofoo |
|
547 | 547 | |
|
548 | 548 | $ hg annotate -cr "wdir()" foo |
|
549 | 549 | 472b18db256d : foo |
|
550 | 550 | b6bedd5477e7+: foofoo |
|
551 | 551 | |
|
552 | 552 | $ hg annotate -ncr "wdir()" foo |
|
553 | 553 | 11 472b18db256d : foo |
|
554 | 554 | 20 b6bedd5477e7+: foofoo |
|
555 | 555 | |
|
556 | 556 | $ hg annotate --debug -ncr "wdir()" foo |
|
557 | 557 | 11 472b18db256d1e8282064eab4bfdaf48cbfe83cd : foo |
|
558 | 558 | 20 b6bedd5477e797f25e568a6402d4697f3f895a72+: foofoo |
|
559 | 559 | |
|
560 | 560 | $ hg annotate -udr "wdir()" foo |
|
561 | 561 | test Thu Jan 01 00:00:00 1970 +0000: foo |
|
562 | 562 | test [A-Za-z0-9:+ ]+: foofoo (re) |
|
563 | 563 | |
|
564 | 564 | $ hg annotate -ncr "wdir()" -Tjson foo |
|
565 | 565 | [ |
|
566 | 566 | { |
|
567 | 567 | "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": "ffffffffffffffffffffffffffffffffffffffff", "rev": 2147483647}], |
|
568 | 568 | "path": "foo" |
|
569 | 569 | } |
|
570 | 570 | ] |
|
571 | 571 | |
|
572 | 572 | annotate added file |
|
573 | 573 | |
|
574 | 574 | $ echo bar > bar |
|
575 | 575 | $ hg add bar |
|
576 | 576 | $ hg annotate -ncr "wdir()" bar |
|
577 | 577 | 20 b6bedd5477e7+: bar |
|
578 | 578 | |
|
579 | 579 | annotate renamed file |
|
580 | 580 | |
|
581 | 581 | $ hg rename foo renamefoo2 |
|
582 | 582 | $ hg annotate -ncr "wdir()" renamefoo2 |
|
583 | 583 | 11 472b18db256d : foo |
|
584 | 584 | 20 b6bedd5477e7+: foofoo |
|
585 | 585 | |
|
586 | 586 | annotate missing file |
|
587 | 587 | |
|
588 | 588 | $ rm baz |
|
589 | 589 | |
|
590 | 590 | $ hg annotate -ncr "wdir()" baz |
|
591 | 591 | abort: $TESTTMP\repo\baz: $ENOENT$ (windows !) |
|
592 | 592 | abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !) |
|
593 | 593 | [255] |
|
594 | 594 | |
|
595 | 595 | annotate removed file |
|
596 | 596 | |
|
597 | 597 | $ hg rm baz |
|
598 | 598 | |
|
599 | 599 | $ hg annotate -ncr "wdir()" baz |
|
600 | 600 | abort: $TESTTMP\repo\baz: $ENOENT$ (windows !) |
|
601 | 601 | abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !) |
|
602 | 602 | [255] |
|
603 | 603 | |
|
604 | 604 | $ hg revert --all --no-backup --quiet |
|
605 | 605 | $ hg id -n |
|
606 | 606 | 20 |
|
607 | 607 | |
|
608 | 608 | Test followlines() revset; we usually check both followlines(pat, range) and |
|
609 | 609 | followlines(pat, range, descend=True) to make sure both give the same result |
|
610 | 610 | when they should. |
|
611 | 611 | |
|
612 | 612 | $ echo a >> foo |
|
613 | 613 | $ hg ci -m 'foo: add a' |
|
614 | 614 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5)' |
|
615 | 615 | 16: baz:0 |
|
616 | 616 | 19: baz:3 |
|
617 | 617 | 20: baz:4 |
|
618 | 618 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=20)' |
|
619 | 619 | 16: baz:0 |
|
620 | 620 | 19: baz:3 |
|
621 | 621 | 20: baz:4 |
|
622 | 622 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19)' |
|
623 | 623 | 16: baz:0 |
|
624 | 624 | 19: baz:3 |
|
625 | 625 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=True)' |
|
626 | 626 | 19: baz:3 |
|
627 | 627 | 20: baz:4 |
|
628 | 628 | $ printf "0\n0\n" | cat - baz > baz1 |
|
629 | 629 | $ mv baz1 baz |
|
630 | 630 | $ hg ci -m 'added two lines with 0' |
|
631 | 631 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)' |
|
632 | 632 | 16: baz:0 |
|
633 | 633 | 19: baz:3 |
|
634 | 634 | 20: baz:4 |
|
635 | 635 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, descend=true, startrev=19)' |
|
636 | 636 | 19: baz:3 |
|
637 | 637 | 20: baz:4 |
|
638 | 638 | $ echo 6 >> baz |
|
639 | 639 | $ hg ci -m 'added line 8' |
|
640 | 640 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)' |
|
641 | 641 | 16: baz:0 |
|
642 | 642 | 19: baz:3 |
|
643 | 643 | 20: baz:4 |
|
644 | 644 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=1)' |
|
645 | 645 | 19: baz:3 |
|
646 | 646 | 20: baz:4 |
|
647 | 647 | $ sed 's/3/3+/' baz > baz.new |
|
648 | 648 | $ mv baz.new baz |
|
649 | 649 | $ hg ci -m 'baz:3->3+' |
|
650 | 650 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, descend=0)' |
|
651 | 651 | 16: baz:0 |
|
652 | 652 | 19: baz:3 |
|
653 | 653 | 20: baz:4 |
|
654 | 654 | 24: baz:3->3+ |
|
655 | 655 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=17, descend=True)' |
|
656 | 656 | 19: baz:3 |
|
657 | 657 | 20: baz:4 |
|
658 | 658 | 24: baz:3->3+ |
|
659 | 659 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 1:2, descend=false)' |
|
660 | 660 | 22: added two lines with 0 |
|
661 | 661 | |
|
662 | 662 | file patterns are okay |
|
663 | 663 | $ hg log -T '{rev}: {desc}\n' -r 'followlines("path:baz", 1:2)' |
|
664 | 664 | 22: added two lines with 0 |
|
665 | 665 | |
|
666 | 666 | renames are followed |
|
667 | 667 | $ hg mv baz qux |
|
668 | 668 | $ sed 's/4/4+/' qux > qux.new |
|
669 | 669 | $ mv qux.new qux |
|
670 | 670 | $ hg ci -m 'qux:4->4+' |
|
671 | 671 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)' |
|
672 | 672 | 16: baz:0 |
|
673 | 673 | 19: baz:3 |
|
674 | 674 | 20: baz:4 |
|
675 | 675 | 24: baz:3->3+ |
|
676 | 676 | 25: qux:4->4+ |
|
677 | 677 | |
|
678 | 678 | but are missed when following children |
|
679 | 679 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=22, descend=True)' |
|
680 | 680 | 24: baz:3->3+ |
|
681 | 681 | |
|
682 | 682 | merge |
|
683 | 683 | $ hg up 24 --quiet |
|
684 | 684 | $ echo 7 >> baz |
|
685 | 685 | $ hg ci -m 'one more line, out of line range' |
|
686 | 686 | created new head |
|
687 | 687 | $ sed 's/3+/3-/' baz > baz.new |
|
688 | 688 | $ mv baz.new baz |
|
689 | 689 | $ hg ci -m 'baz:3+->3-' |
|
690 | 690 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)' |
|
691 | 691 | 16: baz:0 |
|
692 | 692 | 19: baz:3 |
|
693 | 693 | 20: baz:4 |
|
694 | 694 | 24: baz:3->3+ |
|
695 | 695 | 27: baz:3+->3- |
|
696 | 696 | $ hg merge 25 |
|
697 | 697 | merging baz and qux to qux |
|
698 | 698 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
699 | 699 | (branch merge, don't forget to commit) |
|
700 | 700 | $ hg ci -m merge |
|
701 | 701 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)' |
|
702 | 702 | 16: baz:0 |
|
703 | 703 | 19: baz:3 |
|
704 | 704 | 20: baz:4 |
|
705 | 705 | 24: baz:3->3+ |
|
706 | 706 | 25: qux:4->4+ |
|
707 | 707 | 27: baz:3+->3- |
|
708 | 708 | 28: merge |
|
709 | 709 | $ hg up 25 --quiet |
|
710 | 710 | $ hg merge 27 |
|
711 | 711 | merging qux and baz to qux |
|
712 | 712 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
713 | 713 | (branch merge, don't forget to commit) |
|
714 | 714 | $ hg ci -m 'merge from other side' |
|
715 | 715 | created new head |
|
716 | 716 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)' |
|
717 | 717 | 16: baz:0 |
|
718 | 718 | 19: baz:3 |
|
719 | 719 | 20: baz:4 |
|
720 | 720 | 24: baz:3->3+ |
|
721 | 721 | 25: qux:4->4+ |
|
722 | 722 | 27: baz:3+->3- |
|
723 | 723 | 29: merge from other side |
|
724 | 724 | $ hg up 24 --quiet |
|
725 | 725 | |
|
726 | 726 | we are missing the branch with rename when following children |
|
727 | 727 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=26, descend=True)' |
|
728 | 728 | 27: baz:3+->3- |
|
729 | 729 | |
|
730 | 730 | we follow all branches in descending direction |
|
731 | 731 | $ hg up 23 --quiet |
|
732 | 732 | $ sed 's/3/+3/' baz > baz.new |
|
733 | 733 | $ mv baz.new baz |
|
734 | 734 | $ hg ci -m 'baz:3->+3' |
|
735 | 735 | created new head |
|
736 | 736 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 2:5, startrev=16, descend=True)' --graph |
|
737 | 737 | @ 30: baz:3->+3 |
|
738 | 738 | : |
|
739 | 739 | : o 27: baz:3+->3- |
|
740 | 740 | : : |
|
741 | 741 | : o 24: baz:3->3+ |
|
742 | 742 | :/ |
|
743 | 743 | o 20: baz:4 |
|
744 | 744 | |\ |
|
745 | 745 | | o 19: baz:3 |
|
746 | 746 | |/ |
|
747 | 747 | o 18: baz:2 |
|
748 | 748 | : |
|
749 | 749 | o 16: baz:0 |
|
750 | 750 | | |
|
751 | 751 | ~ |
|
752 | 752 | |
|
753 | 753 | Issue5595: on a merge changeset with different line ranges depending on |
|
754 | 754 | parent, be conservative and use the surrounding interval to avoid loosing |
|
755 | 755 | track of possible further descendants in specified range. |
|
756 | 756 | |
|
757 | 757 | $ hg up 23 --quiet |
|
758 | 758 | $ hg cat baz -r 24 |
|
759 | 759 | 0 |
|
760 | 760 | 0 |
|
761 | 761 | 1 baz:1 |
|
762 | 762 | 2 baz:2 |
|
763 | 763 | 3+ baz:3 |
|
764 | 764 | 4 baz:4 |
|
765 | 765 | 5 |
|
766 | 766 | 6 |
|
767 | 767 | $ cat > baz << EOF |
|
768 | 768 | > 0 |
|
769 | 769 | > 0 |
|
770 | 770 | > a |
|
771 | 771 | > b |
|
772 | 772 | > 3+ baz:3 |
|
773 | 773 | > 4 baz:4 |
|
774 | 774 | > y |
|
775 | 775 | > z |
|
776 | 776 | > EOF |
|
777 | 777 | $ hg ci -m 'baz: mostly rewrite with some content from 24' |
|
778 | 778 | created new head |
|
779 | 779 | $ hg merge --tool :merge-other 24 |
|
780 | 780 | merging baz |
|
781 | 781 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
782 | 782 | (branch merge, don't forget to commit) |
|
783 | 783 | $ hg ci -m 'merge forgetting about baz rewrite' |
|
784 | 784 | $ cat > baz << EOF |
|
785 | 785 | > 0 |
|
786 | 786 | > 0 |
|
787 | 787 | > 1 baz:1 |
|
788 | 788 | > 2+ baz:2 |
|
789 | 789 | > 3+ baz:3 |
|
790 | 790 | > 4 baz:4 |
|
791 | 791 | > 5 |
|
792 | 792 | > 6 |
|
793 | 793 | > EOF |
|
794 | 794 | $ hg ci -m 'baz: narrow change (2->2+)' |
|
795 | 795 | $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:4, startrev=20, descend=True)' --graph |
|
796 | 796 | @ 33: baz: narrow change (2->2+) |
|
797 | 797 | | |
|
798 | 798 | o 32: merge forgetting about baz rewrite |
|
799 | 799 | |\ |
|
800 | 800 | | o 31: baz: mostly rewrite with some content from 24 |
|
801 | 801 | | : |
|
802 | 802 | | : o 30: baz:3->+3 |
|
803 | 803 | | :/ |
|
804 | 804 | +---o 27: baz:3+->3- |
|
805 | 805 | | : |
|
806 | 806 | o : 24: baz:3->3+ |
|
807 | 807 | :/ |
|
808 | 808 | o 20: baz:4 |
|
809 | 809 | |\ |
|
810 | 810 | ~ ~ |
|
811 | 811 | |
|
812 | 812 | An integer as a line range, which is parsed as '1:1' |
|
813 | 813 | |
|
814 | 814 | $ hg log -r 'followlines(baz, 1)' |
|
815 | 815 | changeset: 22:2174d0bf352a |
|
816 | 816 | user: test |
|
817 | 817 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
818 | 818 | summary: added two lines with 0 |
|
819 | 819 | |
|
820 | 820 | |
|
821 | 821 | check error cases |
|
822 | 822 | $ hg up 24 --quiet |
|
823 | 823 | $ hg log -r 'followlines()' |
|
824 | 824 | hg: parse error: followlines takes at least 1 positional arguments |
|
825 | 825 | [255] |
|
826 | 826 | $ hg log -r 'followlines(baz)' |
|
827 | 827 | hg: parse error: followlines requires a line range |
|
828 | 828 | [255] |
|
829 | 829 | $ hg log -r 'followlines(baz, x)' |
|
830 | 830 | hg: parse error: followlines expects a line number or a range |
|
831 | 831 | [255] |
|
832 | 832 | $ hg log -r 'followlines(baz, 1:2, startrev=desc("b"))' |
|
833 | 833 | hg: parse error: followlines expects exactly one revision |
|
834 | 834 | [255] |
|
835 | 835 | $ hg log -r 'followlines("glob:*", 1:2)' |
|
836 | 836 | hg: parse error: followlines expects exactly one file |
|
837 | 837 | [255] |
|
838 | 838 | $ hg log -r 'followlines(baz, 1:)' |
|
839 | 839 | hg: parse error: line range bounds must be integers |
|
840 | 840 | [255] |
|
841 | 841 | $ hg log -r 'followlines(baz, :1)' |
|
842 | 842 | hg: parse error: line range bounds must be integers |
|
843 | 843 | [255] |
|
844 | 844 | $ hg log -r 'followlines(baz, x:4)' |
|
845 | 845 | hg: parse error: line range bounds must be integers |
|
846 | 846 | [255] |
|
847 | 847 | $ hg log -r 'followlines(baz, 5:4)' |
|
848 | 848 | hg: parse error: line range must be positive |
|
849 | 849 | [255] |
|
850 | 850 | $ hg log -r 'followlines(baz, 0:4)' |
|
851 | 851 | hg: parse error: fromline must be strictly positive |
|
852 | 852 | [255] |
|
853 | 853 | $ hg log -r 'followlines(baz, 2:40)' |
|
854 | 854 | abort: line range exceeds file size |
|
855 | 855 | [255] |
|
856 | 856 | $ hg log -r 'followlines(baz, 2:4, startrev=20, descend=[1])' |
|
857 | 857 | hg: parse error at 43: not a prefix: [ |
|
858 | 858 | (followlines(baz, 2:4, startrev=20, descend=[1]) |
|
859 | 859 | ^ here) |
|
860 | 860 | [255] |
|
861 | 861 | $ hg log -r 'followlines(baz, 2:4, startrev=20, descend=a)' |
|
862 | 862 | hg: parse error: descend argument must be a boolean |
|
863 | 863 | [255] |
|
864 | 864 | |
|
865 | 865 | Test empty annotate output |
|
866 | 866 | |
|
867 | 867 | $ printf '\0' > binary |
|
868 | 868 | $ touch empty |
|
869 | 869 | $ hg ci -qAm 'add binary and empty files' |
|
870 | 870 | |
|
871 | 871 | $ hg annotate binary empty |
|
872 | 872 | binary: binary file |
|
873 | 873 | |
|
874 | 874 | $ hg annotate -Tjson binary empty |
|
875 | 875 | [ |
|
876 | 876 | { |
|
877 | 877 | "path": "binary" |
|
878 | 878 | }, |
|
879 | 879 | { |
|
880 | 880 | "lines": [], |
|
881 | 881 | "path": "empty" |
|
882 | 882 | } |
|
883 | 883 | ] |
|
884 | 884 | |
|
885 | 885 | Test annotate with whitespace options |
|
886 | 886 | |
|
887 | 887 | $ cd .. |
|
888 | 888 | $ hg init repo-ws |
|
889 | 889 | $ cd repo-ws |
|
890 | 890 | $ cat > a <<EOF |
|
891 | 891 | > aa |
|
892 | 892 | > |
|
893 | 893 | > b b |
|
894 | 894 | > EOF |
|
895 | 895 | $ hg ci -Am "adda" |
|
896 | 896 | adding a |
|
897 | 897 | $ sed 's/EOL$//g' > a <<EOF |
|
898 | 898 | > a a |
|
899 | 899 | > |
|
900 | 900 | > EOL |
|
901 | 901 | > b b |
|
902 | 902 | > EOF |
|
903 | 903 | $ hg ci -m "changea" |
|
904 | 904 | |
|
905 | 905 | Annotate with no option |
|
906 | 906 | |
|
907 | 907 | $ hg annotate a |
|
908 | 908 | 1: a a |
|
909 | 909 | 0: |
|
910 | 910 | 1: |
|
911 | 911 | 1: b b |
|
912 | 912 | |
|
913 | 913 | Annotate with --ignore-space-change |
|
914 | 914 | |
|
915 | 915 | $ hg annotate --ignore-space-change a |
|
916 | 916 | 1: a a |
|
917 | 917 | 1: |
|
918 | 918 | 0: |
|
919 | 919 | 0: b b |
|
920 | 920 | |
|
921 | 921 | Annotate with --ignore-all-space |
|
922 | 922 | |
|
923 | 923 | $ hg annotate --ignore-all-space a |
|
924 | 924 | 0: a a |
|
925 | 925 | 0: |
|
926 | 926 | 1: |
|
927 | 927 | 0: b b |
|
928 | 928 | |
|
929 | 929 | Annotate with --ignore-blank-lines (similar to no options case) |
|
930 | 930 | |
|
931 | 931 | $ hg annotate --ignore-blank-lines a |
|
932 | 932 | 1: a a |
|
933 | 933 | 0: |
|
934 | 934 | 1: |
|
935 | 935 | 1: b b |
|
936 | 936 | |
|
937 | 937 | $ cd .. |
|
938 | 938 | |
|
939 | 939 | Annotate with orphaned CR (issue5798) |
|
940 | 940 | ------------------------------------- |
|
941 | 941 | |
|
942 | 942 | $ hg init repo-cr |
|
943 | 943 | $ cd repo-cr |
|
944 | 944 | |
|
945 | 945 | $ cat <<'EOF' >> "$TESTTMP/substcr.py" |
|
946 | 946 | > import sys |
|
947 | 947 | > from mercurial.utils import procutil |
|
948 | 948 | > procutil.setbinary(sys.stdin) |
|
949 | 949 | > procutil.setbinary(sys.stdout) |
|
950 | 950 | > stdin = getattr(sys.stdin, 'buffer', sys.stdin) |
|
951 | 951 | > stdout = getattr(sys.stdout, 'buffer', sys.stdout) |
|
952 | 952 | > stdout.write(stdin.read().replace(b'\r', b'[CR]')) |
|
953 | 953 | > EOF |
|
954 | 954 | |
|
955 | 955 | >>> with open('a', 'wb') as f: |
|
956 | 956 | ... f.write(b'0a\r0b\r\n0c\r0d\r\n0e\n0f\n0g') and None |
|
957 | 957 | $ hg ci -qAm0 |
|
958 | 958 | >>> with open('a', 'wb') as f: |
|
959 | 959 | ... f.write(b'0a\r0b\r\n1c\r1d\r\n0e\n1f\n0g') and None |
|
960 | 960 | $ hg ci -m1 |
|
961 | 961 | |
|
962 | 962 | $ hg annotate -r0 a | "$PYTHON" "$TESTTMP/substcr.py" |
|
963 | 963 | 0: 0a[CR]0b[CR] |
|
964 | 964 | 0: 0c[CR]0d[CR] |
|
965 | 965 | 0: 0e |
|
966 | 966 | 0: 0f |
|
967 | 967 | 0: 0g |
|
968 | 968 | $ hg annotate -r1 a | "$PYTHON" "$TESTTMP/substcr.py" |
|
969 | 969 | 0: 0a[CR]0b[CR] |
|
970 | 970 | 1: 1c[CR]1d[CR] |
|
971 | 971 | 0: 0e |
|
972 | 972 | 1: 1f |
|
973 | 973 | 0: 0g |
|
974 | 974 | |
|
975 | 975 | $ cd .. |
|
976 | 976 | |
|
977 | 977 | Annotate with linkrev pointing to another branch |
|
978 | 978 | ------------------------------------------------ |
|
979 | 979 | |
|
980 | 980 | create history with a filerev whose linkrev points to another branch |
|
981 | 981 | |
|
982 | 982 | $ hg init branchedlinkrev |
|
983 | 983 | $ cd branchedlinkrev |
|
984 | 984 | $ echo A > a |
|
985 | 985 | $ hg commit -Am 'contentA' |
|
986 | 986 | adding a |
|
987 | 987 | $ echo B >> a |
|
988 | 988 | $ hg commit -m 'contentB' |
|
989 | 989 | $ hg up --rev 'desc(contentA)' |
|
990 | 990 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
991 | 991 | $ echo unrelated > unrelated |
|
992 | 992 | $ hg commit -Am 'unrelated' |
|
993 | 993 | adding unrelated |
|
994 | 994 | created new head |
|
995 | 995 | $ hg graft -r 'desc(contentB)' |
|
996 | 996 | grafting 1:fd27c222e3e6 "contentB" |
|
997 | 997 | $ echo C >> a |
|
998 | 998 | $ hg commit -m 'contentC' |
|
999 | 999 | $ echo W >> a |
|
1000 | 1000 | $ hg log -G |
|
1001 | 1001 | @ changeset: 4:072f1e8df249 |
|
1002 | 1002 | | tag: tip |
|
1003 | 1003 | | user: test |
|
1004 | 1004 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1005 | 1005 | | summary: contentC |
|
1006 | 1006 | | |
|
1007 | 1007 | o changeset: 3:ff38df03cc4b |
|
1008 | 1008 | | user: test |
|
1009 | 1009 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1010 | 1010 | | summary: contentB |
|
1011 | 1011 | | |
|
1012 | 1012 | o changeset: 2:62aaf3f6fc06 |
|
1013 | 1013 | | parent: 0:f0932f74827e |
|
1014 | 1014 | | user: test |
|
1015 | 1015 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1016 | 1016 | | summary: unrelated |
|
1017 | 1017 | | |
|
1018 | 1018 | | o changeset: 1:fd27c222e3e6 |
|
1019 | 1019 | |/ user: test |
|
1020 | 1020 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1021 | 1021 | | summary: contentB |
|
1022 | 1022 | | |
|
1023 | 1023 | o changeset: 0:f0932f74827e |
|
1024 | 1024 | user: test |
|
1025 | 1025 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
1026 | 1026 | summary: contentA |
|
1027 | 1027 | |
|
1028 | 1028 | |
|
1029 | 1029 | Annotate should list ancestor of starting revision only |
|
1030 | 1030 | |
|
1031 | 1031 | $ hg annotate a |
|
1032 | 1032 | 0: A |
|
1033 | 1033 | 3: B |
|
1034 | 1034 | 4: C |
|
1035 | 1035 | |
|
1036 | 1036 | $ hg annotate a -r 'wdir()' |
|
1037 | 1037 | 0 : A |
|
1038 | 1038 | 3 : B |
|
1039 | 1039 | 4 : C |
|
1040 | 1040 | 4+: W |
|
1041 | 1041 | |
|
1042 | 1042 | Even when the starting revision is the linkrev-shadowed one: |
|
1043 | 1043 | |
|
1044 | 1044 | $ hg annotate a -r 3 |
|
1045 | 1045 | 0: A |
|
1046 | 1046 | 3: B |
|
1047 | 1047 | |
|
1048 | 1048 | $ cd .. |
|
1049 | 1049 | |
|
1050 | 1050 | Issue5360: Deleted chunk in p1 of a merge changeset |
|
1051 | 1051 | |
|
1052 | 1052 | $ hg init repo-5360 |
|
1053 | 1053 | $ cd repo-5360 |
|
1054 | 1054 | $ echo 1 > a |
|
1055 | 1055 | $ hg commit -A a -m 1 |
|
1056 | 1056 | $ echo 2 >> a |
|
1057 | 1057 | $ hg commit -m 2 |
|
1058 | 1058 | $ echo a > a |
|
1059 | 1059 | $ hg commit -m a |
|
1060 | 1060 | $ hg update '.^' -q |
|
1061 | 1061 | $ echo 3 >> a |
|
1062 | 1062 | $ hg commit -m 3 -q |
|
1063 | 1063 | $ hg merge 2 -q |
|
1064 | 1064 | $ cat > a << EOF |
|
1065 | 1065 | > b |
|
1066 | 1066 | > 1 |
|
1067 | 1067 | > 2 |
|
1068 | 1068 | > 3 |
|
1069 | 1069 | > a |
|
1070 | 1070 | > EOF |
|
1071 | 1071 | $ hg resolve --mark -q |
|
1072 | 1072 | $ hg commit -m m |
|
1073 | 1073 | $ hg annotate a |
|
1074 | 1074 | 4: b |
|
1075 | 1075 | 0: 1 |
|
1076 | 1076 | 1: 2 |
|
1077 | 1077 | 3: 3 |
|
1078 | 1078 | 2: a |
|
1079 | 1079 | |
|
1080 | 1080 | $ cd .. |
@@ -1,764 +1,764 | |||
|
1 | 1 | (this file is backported from core hg tests/test-annotate.t) |
|
2 | 2 | |
|
3 | 3 | $ cat >> $HGRCPATH << EOF |
|
4 | 4 | > [diff] |
|
5 | 5 | > git=1 |
|
6 | 6 | > [extensions] |
|
7 | 7 | > fastannotate= |
|
8 | 8 | > [fastannotate] |
|
9 | 9 | > modes=fctx |
|
10 | 10 | > forcefollow=False |
|
11 | 11 | > mainbranch=. |
|
12 | 12 | > EOF |
|
13 | 13 | |
|
14 | 14 | $ HGMERGE=true; export HGMERGE |
|
15 | 15 | |
|
16 | 16 | init |
|
17 | 17 | |
|
18 | 18 | $ hg init repo |
|
19 | 19 | $ cd repo |
|
20 | 20 | |
|
21 | 21 | commit |
|
22 | 22 | |
|
23 | 23 | $ echo 'a' > a |
|
24 | 24 | $ hg ci -A -m test -u nobody -d '1 0' |
|
25 | 25 | adding a |
|
26 | 26 | |
|
27 | 27 | annotate -c |
|
28 | 28 | |
|
29 | 29 | $ hg annotate -c a |
|
30 | 30 | 8435f90966e4: a |
|
31 | 31 | |
|
32 | 32 | annotate -cl |
|
33 | 33 | |
|
34 | 34 | $ hg annotate -cl a |
|
35 | 35 | 8435f90966e4:1: a |
|
36 | 36 | |
|
37 | 37 | annotate -d |
|
38 | 38 | |
|
39 | 39 | $ hg annotate -d a |
|
40 | 40 | Thu Jan 01 00:00:01 1970 +0000: a |
|
41 | 41 | |
|
42 | 42 | annotate -n |
|
43 | 43 | |
|
44 | 44 | $ hg annotate -n a |
|
45 | 45 | 0: a |
|
46 | 46 | |
|
47 | 47 | annotate -nl |
|
48 | 48 | |
|
49 | 49 | $ hg annotate -nl a |
|
50 | 50 | 0:1: a |
|
51 | 51 | |
|
52 | 52 | annotate -u |
|
53 | 53 | |
|
54 | 54 | $ hg annotate -u a |
|
55 | 55 | nobody: a |
|
56 | 56 | |
|
57 | 57 | annotate -cdnu |
|
58 | 58 | |
|
59 | 59 | $ hg annotate -cdnu a |
|
60 | 60 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a |
|
61 | 61 | |
|
62 | 62 | annotate -cdnul |
|
63 | 63 | |
|
64 | 64 | $ hg annotate -cdnul a |
|
65 | 65 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a |
|
66 | 66 | |
|
67 | 67 | annotate (JSON) |
|
68 | 68 | |
|
69 | 69 | $ hg annotate -Tjson a |
|
70 | 70 | [ |
|
71 | 71 | { |
|
72 | 72 | "lines": [{"line": "a\n", "rev": 0}], |
|
73 | 73 | "path": "a" |
|
74 | 74 | } |
|
75 | 75 | ] |
|
76 | 76 | |
|
77 | 77 | $ hg annotate -Tjson -cdfnul a |
|
78 | 78 | [ |
|
79 | 79 | { |
|
80 | 80 | "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], |
|
81 | 81 | "path": "a" |
|
82 | 82 | } |
|
83 | 83 | ] |
|
84 | 84 | |
|
85 | 85 | $ cat <<EOF >>a |
|
86 | 86 | > a |
|
87 | 87 | > a |
|
88 | 88 | > EOF |
|
89 | 89 | $ hg ci -ma1 -d '1 0' |
|
90 | 90 | $ hg cp a b |
|
91 | 91 | $ hg ci -mb -d '1 0' |
|
92 | 92 | $ cat <<EOF >> b |
|
93 | 93 | > b4 |
|
94 | 94 | > b5 |
|
95 | 95 | > b6 |
|
96 | 96 | > EOF |
|
97 | 97 | $ hg ci -mb2 -d '2 0' |
|
98 | 98 | |
|
99 | 99 | annotate -n b |
|
100 | 100 | |
|
101 | 101 | $ hg annotate -n b |
|
102 | 102 | 0: a |
|
103 | 103 | 1: a |
|
104 | 104 | 1: a |
|
105 | 105 | 3: b4 |
|
106 | 106 | 3: b5 |
|
107 | 107 | 3: b6 |
|
108 | 108 | |
|
109 | 109 | annotate --no-follow b |
|
110 | 110 | |
|
111 | 111 | $ hg annotate --no-follow b |
|
112 | 112 | 2: a |
|
113 | 113 | 2: a |
|
114 | 114 | 2: a |
|
115 | 115 | 3: b4 |
|
116 | 116 | 3: b5 |
|
117 | 117 | 3: b6 |
|
118 | 118 | |
|
119 | 119 | annotate -nl b |
|
120 | 120 | |
|
121 | 121 | $ hg annotate -nl b |
|
122 | 122 | 0:1: a |
|
123 | 123 | 1:2: a |
|
124 | 124 | 1:3: a |
|
125 | 125 | 3:4: b4 |
|
126 | 126 | 3:5: b5 |
|
127 | 127 | 3:6: b6 |
|
128 | 128 | |
|
129 | 129 | annotate -nf b |
|
130 | 130 | |
|
131 | 131 | $ hg annotate -nf b |
|
132 | 132 | 0 a: a |
|
133 | 133 | 1 a: a |
|
134 | 134 | 1 a: a |
|
135 | 135 | 3 b: b4 |
|
136 | 136 | 3 b: b5 |
|
137 | 137 | 3 b: b6 |
|
138 | 138 | |
|
139 | 139 | annotate -nlf b |
|
140 | 140 | |
|
141 | 141 | $ hg annotate -nlf b |
|
142 | 142 | 0 a:1: a |
|
143 | 143 | 1 a:2: a |
|
144 | 144 | 1 a:3: a |
|
145 | 145 | 3 b:4: b4 |
|
146 | 146 | 3 b:5: b5 |
|
147 | 147 | 3 b:6: b6 |
|
148 | 148 | |
|
149 | 149 | $ hg up -C 2 |
|
150 | 150 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
151 | 151 | $ cat <<EOF >> b |
|
152 | 152 | > b4 |
|
153 | 153 | > c |
|
154 | 154 | > b5 |
|
155 | 155 | > EOF |
|
156 | 156 | $ hg ci -mb2.1 -d '2 0' |
|
157 | 157 | created new head |
|
158 | 158 | $ hg merge |
|
159 | 159 | merging b |
|
160 | 160 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
161 | 161 | (branch merge, don't forget to commit) |
|
162 | 162 | $ hg ci -mmergeb -d '3 0' |
|
163 | 163 | |
|
164 | 164 | annotate after merge |
|
165 | 165 | (note: the first one falls back to the vanilla annotate which does not use linelog) |
|
166 | 166 | |
|
167 | 167 | $ hg annotate -nf b --debug |
|
168 | 168 | fastannotate: b: rebuilding broken cache |
|
169 | 169 | fastannotate: b: 5 new changesets in the main branch |
|
170 | 170 | 0 a: a |
|
171 | 171 | 1 a: a |
|
172 | 172 | 1 a: a |
|
173 | 173 | 3 b: b4 |
|
174 | 174 | 4 b: c |
|
175 | 175 | 3 b: b5 |
|
176 | 176 | |
|
177 | 177 | (difference explained below) |
|
178 | 178 | |
|
179 | 179 | $ hg annotate -nf b --debug |
|
180 | 180 | fastannotate: b: using fast path (resolved fctx: False) |
|
181 | 181 | 0 a: a |
|
182 | 182 | 1 a: a |
|
183 | 183 | 1 a: a |
|
184 | 184 | 4 b: b4 |
|
185 | 185 | 4 b: c |
|
186 | 186 | 4 b: b5 |
|
187 | 187 | |
|
188 | 188 | annotate after merge with -l |
|
189 | 189 | (fastannotate differs from annotate) |
|
190 | 190 | |
|
191 | 191 | $ hg log -Gp -T '{rev}:{node}' -r '2..5' |
|
192 | 192 | @ 5:64afcdf8e29e063c635be123d8d2fb160af00f7e |
|
193 | 193 | |\ |
|
194 | 194 | | o 4:5fbdc1152d97597717021ad9e063061b200f146bdiff --git a/b b/b |
|
195 | 195 | | | --- a/b |
|
196 | 196 | | | +++ b/b |
|
197 | 197 | | | @@ -1,3 +1,6 @@ |
|
198 | 198 | | | a |
|
199 | 199 | | | a |
|
200 | 200 | | | a |
|
201 | 201 | | | +b4 |
|
202 | 202 | | | +c |
|
203 | 203 | | | +b5 |
|
204 | 204 | | | |
|
205 | 205 | o | 3:37ec9f5c3d1f99572d7075971cb4876e2139b52fdiff --git a/b b/b |
|
206 | 206 | |/ --- a/b |
|
207 | 207 | | +++ b/b |
|
208 | 208 | | @@ -1,3 +1,6 @@ |
|
209 | 209 | | a |
|
210 | 210 | | a |
|
211 | 211 | | a |
|
212 | 212 | | +b4 |
|
213 | 213 | | +b5 |
|
214 | 214 | | +b6 |
|
215 | 215 | | |
|
216 | 216 | o 2:3086dbafde1ce745abfc8d2d367847280aabae9ddiff --git a/a b/b |
|
217 | 217 | | copy from a |
|
218 | 218 | ~ copy to b |
|
219 | 219 | |
|
220 | 220 | |
|
221 | 221 | (in this case, "b4", "b5" could be considered introduced by either rev 3, or rev 4. |
|
222 | 222 | and that causes the rev number difference) |
|
223 | 223 | |
|
224 | 224 | $ hg annotate -nlf b --config fastannotate.modes= |
|
225 | 225 | 0 a:1: a |
|
226 | 226 | 1 a:2: a |
|
227 | 227 | 1 a:3: a |
|
228 | 228 | 3 b:4: b4 |
|
229 | 229 | 4 b:5: c |
|
230 | 230 | 3 b:5: b5 |
|
231 | 231 | |
|
232 | 232 | $ hg annotate -nlf b |
|
233 | 233 | 0 a:1: a |
|
234 | 234 | 1 a:2: a |
|
235 | 235 | 1 a:3: a |
|
236 | 236 | 4 b:4: b4 |
|
237 | 237 | 4 b:5: c |
|
238 | 238 | 4 b:6: b5 |
|
239 | 239 | |
|
240 | 240 | $ hg up -C 1 |
|
241 | 241 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
242 | 242 | $ hg cp a b |
|
243 | 243 | $ cat <<EOF > b |
|
244 | 244 | > a |
|
245 | 245 | > z |
|
246 | 246 | > a |
|
247 | 247 | > EOF |
|
248 | 248 | $ hg ci -mc -d '3 0' |
|
249 | 249 | created new head |
|
250 | 250 | $ hg merge |
|
251 | 251 | merging b |
|
252 | 252 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
253 | 253 | (branch merge, don't forget to commit) |
|
254 | 254 | $ cat <<EOF >> b |
|
255 | 255 | > b4 |
|
256 | 256 | > c |
|
257 | 257 | > b5 |
|
258 | 258 | > EOF |
|
259 | 259 | $ echo d >> b |
|
260 | 260 | $ hg ci -mmerge2 -d '4 0' |
|
261 | 261 | |
|
262 | 262 | annotate after rename merge |
|
263 | 263 | |
|
264 | 264 | $ hg annotate -nf b |
|
265 | 265 | 0 a: a |
|
266 | 266 | 6 b: z |
|
267 | 267 | 1 a: a |
|
268 | 268 | 3 b: b4 |
|
269 | 269 | 4 b: c |
|
270 | 270 | 3 b: b5 |
|
271 | 271 | 7 b: d |
|
272 | 272 | |
|
273 | 273 | annotate after rename merge with -l |
|
274 | 274 | (fastannotate differs from annotate) |
|
275 | 275 | |
|
276 | 276 | $ hg log -Gp -T '{rev}:{node}' -r '0+1+6+7' |
|
277 | 277 | @ 7:6284bb6c38fef984a929862a53bbc71ce9eafa81diff --git a/b b/b |
|
278 | 278 | |\ --- a/b |
|
279 | 279 | | : +++ b/b |
|
280 | 280 | | : @@ -1,3 +1,7 @@ |
|
281 | 281 | | : a |
|
282 | 282 | | : z |
|
283 | 283 | | : a |
|
284 | 284 | | : +b4 |
|
285 | 285 | | : +c |
|
286 | 286 | | : +b5 |
|
287 | 287 | | : +d |
|
288 | 288 | | : |
|
289 | 289 | o : 6:b80e3e32f75a6a67cd4ac85496a11511e9112816diff --git a/a b/b |
|
290 | 290 | :/ copy from a |
|
291 | 291 | : copy to b |
|
292 | 292 | : --- a/a |
|
293 | 293 | : +++ b/b |
|
294 | 294 | : @@ -1,3 +1,3 @@ |
|
295 | 295 | : -a (?) |
|
296 | 296 | : a |
|
297 | 297 | : +z |
|
298 | 298 | : a |
|
299 | 299 | : -a (?) |
|
300 | 300 | : |
|
301 | 301 | o 1:762f04898e6684ff713415f7b8a8d53d33f96c92diff --git a/a b/a |
|
302 | 302 | | --- a/a |
|
303 | 303 | | +++ b/a |
|
304 | 304 | | @@ -1,1 +1,3 @@ |
|
305 | 305 | | a |
|
306 | 306 | | +a |
|
307 | 307 | | +a |
|
308 | 308 | | |
|
309 | 309 | o 0:8435f90966e442695d2ded29fdade2bac5ad8065diff --git a/a b/a |
|
310 | 310 | new file mode 100644 |
|
311 | 311 | --- /dev/null |
|
312 | 312 | +++ b/a |
|
313 | 313 | @@ -0,0 +1,1 @@ |
|
314 | 314 | +a |
|
315 | 315 | |
|
316 | 316 | |
|
317 | 317 | (note on question marks: |
|
318 | 318 | the upstream bdiff change (96f2f50d923f+3633403888ae+8c0c75aa3ff4+5c4e2636c1a9 |
|
319 | 319 | +38ed54888617) alters the output so deletion is not always at the end of the |
|
320 | 320 | output. for example: |
|
321 | 321 | | a | b | old | new | # old: e1d6aa0e4c3a, new: 8836f13e3c5b |
|
322 | 322 | |-------------------| |
|
323 | 323 | | a | a | a | -a | |
|
324 | 324 | | a | z | +z | a | |
|
325 | 325 | | a | a | a | +z | |
|
326 | 326 | | | | -a | a | |
|
327 | 327 | |-------------------| |
|
328 | 328 | | a | a | a | |
|
329 | 329 | | a | a | a | |
|
330 | 330 | | a | | -a | |
|
331 | 331 | this leads to more question marks below) |
|
332 | 332 | |
|
333 | 333 | (rev 1 adds two "a"s and rev 6 deletes one "a". |
|
334 | 334 | the "a" that rev 6 deletes could be either the first or the second "a" of those two "a"s added by rev 1. |
|
335 | 335 | and that causes the line number difference) |
|
336 | 336 | |
|
337 | 337 | $ hg annotate -nlf b --config fastannotate.modes= |
|
338 | 338 | 0 a:1: a |
|
339 | 339 | 6 b:2: z |
|
340 | 340 | 1 a:3: a |
|
341 | 341 | 3 b:4: b4 |
|
342 | 342 | 4 b:5: c |
|
343 | 343 | 3 b:5: b5 |
|
344 | 344 | 7 b:7: d |
|
345 | 345 | |
|
346 | 346 | $ hg annotate -nlf b |
|
347 | 347 | 0 a:1: a (?) |
|
348 | 348 | 1 a:2: a (?) |
|
349 | 349 | 6 b:2: z |
|
350 | 350 | 1 a:2: a (?) |
|
351 | 351 | 1 a:3: a (?) |
|
352 | 352 | 3 b:4: b4 |
|
353 | 353 | 4 b:5: c |
|
354 | 354 | 3 b:5: b5 |
|
355 | 355 | 7 b:7: d |
|
356 | 356 | |
|
357 | 357 | Issue2807: alignment of line numbers with -l |
|
358 | 358 | (fastannotate differs from annotate, same reason as above) |
|
359 | 359 | |
|
360 | 360 | $ echo more >> b |
|
361 | 361 | $ hg ci -mmore -d '5 0' |
|
362 | 362 | $ echo more >> b |
|
363 | 363 | $ hg ci -mmore -d '6 0' |
|
364 | 364 | $ echo more >> b |
|
365 | 365 | $ hg ci -mmore -d '7 0' |
|
366 | 366 | $ hg annotate -nlf b |
|
367 | 367 | 0 a: 1: a (?) |
|
368 | 368 | 1 a: 2: a (?) |
|
369 | 369 | 6 b: 2: z |
|
370 | 370 | 1 a: 2: a (?) |
|
371 | 371 | 1 a: 3: a (?) |
|
372 | 372 | 3 b: 4: b4 |
|
373 | 373 | 4 b: 5: c |
|
374 | 374 | 3 b: 5: b5 |
|
375 | 375 | 7 b: 7: d |
|
376 | 376 | 8 b: 8: more |
|
377 | 377 | 9 b: 9: more |
|
378 | 378 | 10 b:10: more |
|
379 | 379 | |
|
380 | 380 | linkrev vs rev |
|
381 | 381 | |
|
382 | 382 | $ hg annotate -r tip -n a |
|
383 | 383 | 0: a |
|
384 | 384 | 1: a |
|
385 | 385 | 1: a |
|
386 | 386 | |
|
387 | 387 | linkrev vs rev with -l |
|
388 | 388 | |
|
389 | 389 | $ hg annotate -r tip -nl a |
|
390 | 390 | 0:1: a |
|
391 | 391 | 1:2: a |
|
392 | 392 | 1:3: a |
|
393 | 393 | |
|
394 | 394 | Issue589: "undelete" sequence leads to crash |
|
395 | 395 | |
|
396 | 396 | annotate was crashing when trying to --follow something |
|
397 | 397 | |
|
398 | 398 | like A -> B -> A |
|
399 | 399 | |
|
400 | 400 | generate ABA rename configuration |
|
401 | 401 | |
|
402 | 402 | $ echo foo > foo |
|
403 | 403 | $ hg add foo |
|
404 | 404 | $ hg ci -m addfoo |
|
405 | 405 | $ hg rename foo bar |
|
406 | 406 | $ hg ci -m renamefoo |
|
407 | 407 | $ hg rename bar foo |
|
408 | 408 | $ hg ci -m renamebar |
|
409 | 409 | |
|
410 | 410 | annotate after ABA with follow |
|
411 | 411 | |
|
412 | 412 | $ hg annotate --follow foo |
|
413 | 413 | foo: foo |
|
414 | 414 | |
|
415 | 415 | missing file |
|
416 | 416 | |
|
417 | 417 | $ hg ann nosuchfile |
|
418 | 418 | abort: nosuchfile: no such file in rev e9e6b4fa872f |
|
419 | 419 | [255] |
|
420 | 420 | |
|
421 | 421 | annotate file without '\n' on last line |
|
422 | 422 | |
|
423 | 423 | $ printf "" > c |
|
424 | 424 | $ hg ci -A -m test -u nobody -d '1 0' |
|
425 | 425 | adding c |
|
426 | 426 | $ hg annotate c |
|
427 | 427 | $ printf "a\nb" > c |
|
428 | 428 | $ hg ci -m test |
|
429 | 429 | $ hg annotate c |
|
430 | 430 | [0-9]+: a (re) |
|
431 | 431 | [0-9]+: b (re) |
|
432 | 432 | |
|
433 | 433 | Issue3841: check annotation of the file of which filelog includes |
|
434 | 434 | merging between the revision and its ancestor |
|
435 | 435 | |
|
436 | 436 | to reproduce the situation with recent Mercurial, this script uses (1) |
|
437 | 437 | "hg debugsetparents" to merge without ancestor check by "hg merge", |
|
438 | 438 | and (2) the extension to allow filelog merging between the revision |
|
439 | 439 | and its ancestor by overriding "repo._filecommit". |
|
440 | 440 | |
|
441 | 441 | $ cat > ../legacyrepo.py <<EOF |
|
442 | 442 | > from mercurial import error, node |
|
443 | 443 | > def reposetup(ui, repo): |
|
444 | 444 | > class legacyrepo(repo.__class__): |
|
445 | 445 | > def _filecommit(self, fctx, manifest1, manifest2, |
|
446 | > linkrev, tr, changelist): | |
|
446 | > linkrev, tr, changelist, includecopymeta): | |
|
447 | 447 | > fname = fctx.path() |
|
448 | 448 | > text = fctx.data() |
|
449 | 449 | > flog = self.file(fname) |
|
450 | 450 | > fparent1 = manifest1.get(fname, node.nullid) |
|
451 | 451 | > fparent2 = manifest2.get(fname, node.nullid) |
|
452 | 452 | > meta = {} |
|
453 | 453 | > copy = fctx.renamed() |
|
454 | 454 | > if copy and copy[0] != fname: |
|
455 | 455 | > raise error.Abort('copying is not supported') |
|
456 | 456 | > if fparent2 != node.nullid: |
|
457 | 457 | > changelist.append(fname) |
|
458 | 458 | > return flog.add(text, meta, tr, linkrev, |
|
459 | 459 | > fparent1, fparent2) |
|
460 | 460 | > raise error.Abort('only merging is supported') |
|
461 | 461 | > repo.__class__ = legacyrepo |
|
462 | 462 | > EOF |
|
463 | 463 | |
|
464 | 464 | $ cat > baz <<EOF |
|
465 | 465 | > 1 |
|
466 | 466 | > 2 |
|
467 | 467 | > 3 |
|
468 | 468 | > 4 |
|
469 | 469 | > 5 |
|
470 | 470 | > EOF |
|
471 | 471 | $ hg add baz |
|
472 | 472 | $ hg commit -m "baz:0" |
|
473 | 473 | |
|
474 | 474 | $ cat > baz <<EOF |
|
475 | 475 | > 1 baz:1 |
|
476 | 476 | > 2 |
|
477 | 477 | > 3 |
|
478 | 478 | > 4 |
|
479 | 479 | > 5 |
|
480 | 480 | > EOF |
|
481 | 481 | $ hg commit -m "baz:1" |
|
482 | 482 | |
|
483 | 483 | $ cat > baz <<EOF |
|
484 | 484 | > 1 baz:1 |
|
485 | 485 | > 2 baz:2 |
|
486 | 486 | > 3 |
|
487 | 487 | > 4 |
|
488 | 488 | > 5 |
|
489 | 489 | > EOF |
|
490 | 490 | $ hg debugsetparents 17 17 |
|
491 | 491 | $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:2" |
|
492 | 492 | $ hg debugindexdot baz |
|
493 | 493 | digraph G { |
|
494 | 494 | -1 -> 0 |
|
495 | 495 | 0 -> 1 |
|
496 | 496 | 1 -> 2 |
|
497 | 497 | 1 -> 2 |
|
498 | 498 | } |
|
499 | 499 | $ hg annotate baz |
|
500 | 500 | 17: 1 baz:1 |
|
501 | 501 | 18: 2 baz:2 |
|
502 | 502 | 16: 3 |
|
503 | 503 | 16: 4 |
|
504 | 504 | 16: 5 |
|
505 | 505 | |
|
506 | 506 | $ cat > baz <<EOF |
|
507 | 507 | > 1 baz:1 |
|
508 | 508 | > 2 baz:2 |
|
509 | 509 | > 3 baz:3 |
|
510 | 510 | > 4 |
|
511 | 511 | > 5 |
|
512 | 512 | > EOF |
|
513 | 513 | $ hg commit -m "baz:3" |
|
514 | 514 | |
|
515 | 515 | $ cat > baz <<EOF |
|
516 | 516 | > 1 baz:1 |
|
517 | 517 | > 2 baz:2 |
|
518 | 518 | > 3 baz:3 |
|
519 | 519 | > 4 baz:4 |
|
520 | 520 | > 5 |
|
521 | 521 | > EOF |
|
522 | 522 | $ hg debugsetparents 19 18 |
|
523 | 523 | $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:4" |
|
524 | 524 | $ hg debugindexdot baz |
|
525 | 525 | digraph G { |
|
526 | 526 | -1 -> 0 |
|
527 | 527 | 0 -> 1 |
|
528 | 528 | 1 -> 2 |
|
529 | 529 | 1 -> 2 |
|
530 | 530 | 2 -> 3 |
|
531 | 531 | 3 -> 4 |
|
532 | 532 | 2 -> 4 |
|
533 | 533 | } |
|
534 | 534 | $ hg annotate baz |
|
535 | 535 | 17: 1 baz:1 |
|
536 | 536 | 18: 2 baz:2 |
|
537 | 537 | 19: 3 baz:3 |
|
538 | 538 | 20: 4 baz:4 |
|
539 | 539 | 16: 5 |
|
540 | 540 | |
|
541 | 541 | annotate clean file |
|
542 | 542 | |
|
543 | 543 | $ hg annotate -ncr "wdir()" foo |
|
544 | 544 | 11 472b18db256d : foo |
|
545 | 545 | |
|
546 | 546 | annotate modified file |
|
547 | 547 | |
|
548 | 548 | $ echo foofoo >> foo |
|
549 | 549 | $ hg annotate -r "wdir()" foo |
|
550 | 550 | 11 : foo |
|
551 | 551 | 20+: foofoo |
|
552 | 552 | |
|
553 | 553 | $ hg annotate -cr "wdir()" foo |
|
554 | 554 | 472b18db256d : foo |
|
555 | 555 | b6bedd5477e7+: foofoo |
|
556 | 556 | |
|
557 | 557 | $ hg annotate -ncr "wdir()" foo |
|
558 | 558 | 11 472b18db256d : foo |
|
559 | 559 | 20 b6bedd5477e7+: foofoo |
|
560 | 560 | |
|
561 | 561 | $ hg annotate --debug -ncr "wdir()" foo |
|
562 | 562 | 11 472b18db256d1e8282064eab4bfdaf48cbfe83cd : foo |
|
563 | 563 | 20 b6bedd5477e797f25e568a6402d4697f3f895a72+: foofoo |
|
564 | 564 | |
|
565 | 565 | $ hg annotate -udr "wdir()" foo |
|
566 | 566 | test Thu Jan 01 00:00:00 1970 +0000: foo |
|
567 | 567 | test [A-Za-z0-9:+ ]+: foofoo (re) |
|
568 | 568 | |
|
569 | 569 | $ hg annotate -ncr "wdir()" -Tjson foo |
|
570 | 570 | [ |
|
571 | 571 | { |
|
572 | 572 | "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": "ffffffffffffffffffffffffffffffffffffffff", "rev": 2147483647}], |
|
573 | 573 | "path": "foo" |
|
574 | 574 | } |
|
575 | 575 | ] |
|
576 | 576 | |
|
577 | 577 | annotate added file |
|
578 | 578 | |
|
579 | 579 | $ echo bar > bar |
|
580 | 580 | $ hg add bar |
|
581 | 581 | $ hg annotate -ncr "wdir()" bar |
|
582 | 582 | 20 b6bedd5477e7+: bar |
|
583 | 583 | |
|
584 | 584 | annotate renamed file |
|
585 | 585 | |
|
586 | 586 | $ hg rename foo renamefoo2 |
|
587 | 587 | $ hg annotate -ncr "wdir()" renamefoo2 |
|
588 | 588 | 11 472b18db256d : foo |
|
589 | 589 | 20 b6bedd5477e7+: foofoo |
|
590 | 590 | |
|
591 | 591 | annotate missing file |
|
592 | 592 | |
|
593 | 593 | $ rm baz |
|
594 | 594 | $ hg annotate -ncr "wdir()" baz |
|
595 | 595 | abort: $TESTTMP/repo/baz: $ENOENT$ (windows !) |
|
596 | 596 | abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !) |
|
597 | 597 | [255] |
|
598 | 598 | |
|
599 | 599 | annotate removed file |
|
600 | 600 | |
|
601 | 601 | $ hg rm baz |
|
602 | 602 | $ hg annotate -ncr "wdir()" baz |
|
603 | 603 | abort: $TESTTMP/repo/baz: $ENOENT$ (windows !) |
|
604 | 604 | abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !) |
|
605 | 605 | [255] |
|
606 | 606 | |
|
607 | 607 | Test annotate with whitespace options |
|
608 | 608 | |
|
609 | 609 | $ cd .. |
|
610 | 610 | $ hg init repo-ws |
|
611 | 611 | $ cd repo-ws |
|
612 | 612 | $ cat > a <<EOF |
|
613 | 613 | > aa |
|
614 | 614 | > |
|
615 | 615 | > b b |
|
616 | 616 | > EOF |
|
617 | 617 | $ hg ci -Am "adda" |
|
618 | 618 | adding a |
|
619 | 619 | $ sed 's/EOL$//g' > a <<EOF |
|
620 | 620 | > a a |
|
621 | 621 | > |
|
622 | 622 | > EOL |
|
623 | 623 | > b b |
|
624 | 624 | > EOF |
|
625 | 625 | $ hg ci -m "changea" |
|
626 | 626 | |
|
627 | 627 | Annotate with no option |
|
628 | 628 | |
|
629 | 629 | $ hg annotate a |
|
630 | 630 | 1: a a |
|
631 | 631 | 0: |
|
632 | 632 | 1: |
|
633 | 633 | 1: b b |
|
634 | 634 | |
|
635 | 635 | Annotate with --ignore-space-change |
|
636 | 636 | |
|
637 | 637 | $ hg annotate --ignore-space-change a |
|
638 | 638 | 1: a a |
|
639 | 639 | 1: |
|
640 | 640 | 0: |
|
641 | 641 | 0: b b |
|
642 | 642 | |
|
643 | 643 | Annotate with --ignore-all-space |
|
644 | 644 | |
|
645 | 645 | $ hg annotate --ignore-all-space a |
|
646 | 646 | 0: a a |
|
647 | 647 | 0: |
|
648 | 648 | 1: |
|
649 | 649 | 0: b b |
|
650 | 650 | |
|
651 | 651 | Annotate with --ignore-blank-lines (similar to no options case) |
|
652 | 652 | |
|
653 | 653 | $ hg annotate --ignore-blank-lines a |
|
654 | 654 | 1: a a |
|
655 | 655 | 0: |
|
656 | 656 | 1: |
|
657 | 657 | 1: b b |
|
658 | 658 | |
|
659 | 659 | $ cd .. |
|
660 | 660 | |
|
661 | 661 | Annotate with linkrev pointing to another branch |
|
662 | 662 | ------------------------------------------------ |
|
663 | 663 | |
|
664 | 664 | create history with a filerev whose linkrev points to another branch |
|
665 | 665 | |
|
666 | 666 | $ hg init branchedlinkrev |
|
667 | 667 | $ cd branchedlinkrev |
|
668 | 668 | $ echo A > a |
|
669 | 669 | $ hg commit -Am 'contentA' |
|
670 | 670 | adding a |
|
671 | 671 | $ echo B >> a |
|
672 | 672 | $ hg commit -m 'contentB' |
|
673 | 673 | $ hg up --rev 'desc(contentA)' |
|
674 | 674 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
675 | 675 | $ echo unrelated > unrelated |
|
676 | 676 | $ hg commit -Am 'unrelated' |
|
677 | 677 | adding unrelated |
|
678 | 678 | created new head |
|
679 | 679 | $ hg graft -r 'desc(contentB)' |
|
680 | 680 | grafting 1:fd27c222e3e6 "contentB" |
|
681 | 681 | $ echo C >> a |
|
682 | 682 | $ hg commit -m 'contentC' |
|
683 | 683 | $ echo W >> a |
|
684 | 684 | $ hg log -G |
|
685 | 685 | @ changeset: 4:072f1e8df249 |
|
686 | 686 | | tag: tip |
|
687 | 687 | | user: test |
|
688 | 688 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
689 | 689 | | summary: contentC |
|
690 | 690 | | |
|
691 | 691 | o changeset: 3:ff38df03cc4b |
|
692 | 692 | | user: test |
|
693 | 693 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
694 | 694 | | summary: contentB |
|
695 | 695 | | |
|
696 | 696 | o changeset: 2:62aaf3f6fc06 |
|
697 | 697 | | parent: 0:f0932f74827e |
|
698 | 698 | | user: test |
|
699 | 699 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
700 | 700 | | summary: unrelated |
|
701 | 701 | | |
|
702 | 702 | | o changeset: 1:fd27c222e3e6 |
|
703 | 703 | |/ user: test |
|
704 | 704 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
705 | 705 | | summary: contentB |
|
706 | 706 | | |
|
707 | 707 | o changeset: 0:f0932f74827e |
|
708 | 708 | user: test |
|
709 | 709 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
710 | 710 | summary: contentA |
|
711 | 711 | |
|
712 | 712 | |
|
713 | 713 | Annotate should list ancestor of starting revision only |
|
714 | 714 | |
|
715 | 715 | $ hg annotate a |
|
716 | 716 | 0: A |
|
717 | 717 | 3: B |
|
718 | 718 | 4: C |
|
719 | 719 | |
|
720 | 720 | $ hg annotate a -r 'wdir()' |
|
721 | 721 | 0 : A |
|
722 | 722 | 3 : B |
|
723 | 723 | 4 : C |
|
724 | 724 | 4+: W |
|
725 | 725 | |
|
726 | 726 | Even when the starting revision is the linkrev-shadowed one: |
|
727 | 727 | |
|
728 | 728 | $ hg annotate a -r 3 |
|
729 | 729 | 0: A |
|
730 | 730 | 3: B |
|
731 | 731 | |
|
732 | 732 | $ cd .. |
|
733 | 733 | |
|
734 | 734 | Issue5360: Deleted chunk in p1 of a merge changeset |
|
735 | 735 | |
|
736 | 736 | $ hg init repo-5360 |
|
737 | 737 | $ cd repo-5360 |
|
738 | 738 | $ echo 1 > a |
|
739 | 739 | $ hg commit -A a -m 1 |
|
740 | 740 | $ echo 2 >> a |
|
741 | 741 | $ hg commit -m 2 |
|
742 | 742 | $ echo a > a |
|
743 | 743 | $ hg commit -m a |
|
744 | 744 | $ hg update '.^' -q |
|
745 | 745 | $ echo 3 >> a |
|
746 | 746 | $ hg commit -m 3 -q |
|
747 | 747 | $ hg merge 2 -q |
|
748 | 748 | $ cat > a << EOF |
|
749 | 749 | > b |
|
750 | 750 | > 1 |
|
751 | 751 | > 2 |
|
752 | 752 | > 3 |
|
753 | 753 | > a |
|
754 | 754 | > EOF |
|
755 | 755 | $ hg resolve --mark -q |
|
756 | 756 | $ hg commit -m m |
|
757 | 757 | $ hg annotate a |
|
758 | 758 | 4: b |
|
759 | 759 | 0: 1 |
|
760 | 760 | 1: 2 |
|
761 | 761 | 3: 3 |
|
762 | 762 | 2: a |
|
763 | 763 | |
|
764 | 764 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now