##// END OF EJS Templates
requirements: add an official `REVLOG_COMPRESSION_ZSTD` const...
marmoute -
r49498:6fd9a17c default
parent child Browse files
Show More
@@ -1,3911 +1,3911 b''
1 # localrepo.py - read/write repository class for mercurial
1 # localrepo.py - read/write repository class for mercurial
2 # coding: utf-8
2 # coding: utf-8
3 #
3 #
4 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 from __future__ import absolute_import
9 from __future__ import absolute_import
10
10
11 import errno
11 import errno
12 import functools
12 import functools
13 import os
13 import os
14 import random
14 import random
15 import sys
15 import sys
16 import time
16 import time
17 import weakref
17 import weakref
18
18
19 from .i18n import _
19 from .i18n import _
20 from .node import (
20 from .node import (
21 bin,
21 bin,
22 hex,
22 hex,
23 nullrev,
23 nullrev,
24 sha1nodeconstants,
24 sha1nodeconstants,
25 short,
25 short,
26 )
26 )
27 from .pycompat import (
27 from .pycompat import (
28 delattr,
28 delattr,
29 getattr,
29 getattr,
30 )
30 )
31 from . import (
31 from . import (
32 bookmarks,
32 bookmarks,
33 branchmap,
33 branchmap,
34 bundle2,
34 bundle2,
35 bundlecaches,
35 bundlecaches,
36 changegroup,
36 changegroup,
37 color,
37 color,
38 commit,
38 commit,
39 context,
39 context,
40 dirstate,
40 dirstate,
41 dirstateguard,
41 dirstateguard,
42 discovery,
42 discovery,
43 encoding,
43 encoding,
44 error,
44 error,
45 exchange,
45 exchange,
46 extensions,
46 extensions,
47 filelog,
47 filelog,
48 hook,
48 hook,
49 lock as lockmod,
49 lock as lockmod,
50 match as matchmod,
50 match as matchmod,
51 mergestate as mergestatemod,
51 mergestate as mergestatemod,
52 mergeutil,
52 mergeutil,
53 namespaces,
53 namespaces,
54 narrowspec,
54 narrowspec,
55 obsolete,
55 obsolete,
56 pathutil,
56 pathutil,
57 phases,
57 phases,
58 pushkey,
58 pushkey,
59 pycompat,
59 pycompat,
60 rcutil,
60 rcutil,
61 repoview,
61 repoview,
62 requirements as requirementsmod,
62 requirements as requirementsmod,
63 revlog,
63 revlog,
64 revset,
64 revset,
65 revsetlang,
65 revsetlang,
66 scmutil,
66 scmutil,
67 sparse,
67 sparse,
68 store as storemod,
68 store as storemod,
69 subrepoutil,
69 subrepoutil,
70 tags as tagsmod,
70 tags as tagsmod,
71 transaction,
71 transaction,
72 txnutil,
72 txnutil,
73 util,
73 util,
74 vfs as vfsmod,
74 vfs as vfsmod,
75 wireprototypes,
75 wireprototypes,
76 )
76 )
77
77
78 from .interfaces import (
78 from .interfaces import (
79 repository,
79 repository,
80 util as interfaceutil,
80 util as interfaceutil,
81 )
81 )
82
82
83 from .utils import (
83 from .utils import (
84 hashutil,
84 hashutil,
85 procutil,
85 procutil,
86 stringutil,
86 stringutil,
87 urlutil,
87 urlutil,
88 )
88 )
89
89
90 from .revlogutils import (
90 from .revlogutils import (
91 concurrency_checker as revlogchecker,
91 concurrency_checker as revlogchecker,
92 constants as revlogconst,
92 constants as revlogconst,
93 sidedata as sidedatamod,
93 sidedata as sidedatamod,
94 )
94 )
95
95
96 release = lockmod.release
96 release = lockmod.release
97 urlerr = util.urlerr
97 urlerr = util.urlerr
98 urlreq = util.urlreq
98 urlreq = util.urlreq
99
99
100 # set of (path, vfs-location) tuples. vfs-location is:
100 # set of (path, vfs-location) tuples. vfs-location is:
101 # - 'plain for vfs relative paths
101 # - 'plain for vfs relative paths
102 # - '' for svfs relative paths
102 # - '' for svfs relative paths
103 _cachedfiles = set()
103 _cachedfiles = set()
104
104
105
105
106 class _basefilecache(scmutil.filecache):
106 class _basefilecache(scmutil.filecache):
107 """All filecache usage on repo are done for logic that should be unfiltered"""
107 """All filecache usage on repo are done for logic that should be unfiltered"""
108
108
109 def __get__(self, repo, type=None):
109 def __get__(self, repo, type=None):
110 if repo is None:
110 if repo is None:
111 return self
111 return self
112 # proxy to unfiltered __dict__ since filtered repo has no entry
112 # proxy to unfiltered __dict__ since filtered repo has no entry
113 unfi = repo.unfiltered()
113 unfi = repo.unfiltered()
114 try:
114 try:
115 return unfi.__dict__[self.sname]
115 return unfi.__dict__[self.sname]
116 except KeyError:
116 except KeyError:
117 pass
117 pass
118 return super(_basefilecache, self).__get__(unfi, type)
118 return super(_basefilecache, self).__get__(unfi, type)
119
119
120 def set(self, repo, value):
120 def set(self, repo, value):
121 return super(_basefilecache, self).set(repo.unfiltered(), value)
121 return super(_basefilecache, self).set(repo.unfiltered(), value)
122
122
123
123
124 class repofilecache(_basefilecache):
124 class repofilecache(_basefilecache):
125 """filecache for files in .hg but outside of .hg/store"""
125 """filecache for files in .hg but outside of .hg/store"""
126
126
127 def __init__(self, *paths):
127 def __init__(self, *paths):
128 super(repofilecache, self).__init__(*paths)
128 super(repofilecache, self).__init__(*paths)
129 for path in paths:
129 for path in paths:
130 _cachedfiles.add((path, b'plain'))
130 _cachedfiles.add((path, b'plain'))
131
131
132 def join(self, obj, fname):
132 def join(self, obj, fname):
133 return obj.vfs.join(fname)
133 return obj.vfs.join(fname)
134
134
135
135
136 class storecache(_basefilecache):
136 class storecache(_basefilecache):
137 """filecache for files in the store"""
137 """filecache for files in the store"""
138
138
139 def __init__(self, *paths):
139 def __init__(self, *paths):
140 super(storecache, self).__init__(*paths)
140 super(storecache, self).__init__(*paths)
141 for path in paths:
141 for path in paths:
142 _cachedfiles.add((path, b''))
142 _cachedfiles.add((path, b''))
143
143
144 def join(self, obj, fname):
144 def join(self, obj, fname):
145 return obj.sjoin(fname)
145 return obj.sjoin(fname)
146
146
147
147
148 class changelogcache(storecache):
148 class changelogcache(storecache):
149 """filecache for the changelog"""
149 """filecache for the changelog"""
150
150
151 def __init__(self):
151 def __init__(self):
152 super(changelogcache, self).__init__()
152 super(changelogcache, self).__init__()
153 _cachedfiles.add((b'00changelog.i', b''))
153 _cachedfiles.add((b'00changelog.i', b''))
154 _cachedfiles.add((b'00changelog.n', b''))
154 _cachedfiles.add((b'00changelog.n', b''))
155
155
156 def tracked_paths(self, obj):
156 def tracked_paths(self, obj):
157 paths = [self.join(obj, b'00changelog.i')]
157 paths = [self.join(obj, b'00changelog.i')]
158 if obj.store.opener.options.get(b'persistent-nodemap', False):
158 if obj.store.opener.options.get(b'persistent-nodemap', False):
159 paths.append(self.join(obj, b'00changelog.n'))
159 paths.append(self.join(obj, b'00changelog.n'))
160 return paths
160 return paths
161
161
162
162
163 class manifestlogcache(storecache):
163 class manifestlogcache(storecache):
164 """filecache for the manifestlog"""
164 """filecache for the manifestlog"""
165
165
166 def __init__(self):
166 def __init__(self):
167 super(manifestlogcache, self).__init__()
167 super(manifestlogcache, self).__init__()
168 _cachedfiles.add((b'00manifest.i', b''))
168 _cachedfiles.add((b'00manifest.i', b''))
169 _cachedfiles.add((b'00manifest.n', b''))
169 _cachedfiles.add((b'00manifest.n', b''))
170
170
171 def tracked_paths(self, obj):
171 def tracked_paths(self, obj):
172 paths = [self.join(obj, b'00manifest.i')]
172 paths = [self.join(obj, b'00manifest.i')]
173 if obj.store.opener.options.get(b'persistent-nodemap', False):
173 if obj.store.opener.options.get(b'persistent-nodemap', False):
174 paths.append(self.join(obj, b'00manifest.n'))
174 paths.append(self.join(obj, b'00manifest.n'))
175 return paths
175 return paths
176
176
177
177
178 class mixedrepostorecache(_basefilecache):
178 class mixedrepostorecache(_basefilecache):
179 """filecache for a mix files in .hg/store and outside"""
179 """filecache for a mix files in .hg/store and outside"""
180
180
181 def __init__(self, *pathsandlocations):
181 def __init__(self, *pathsandlocations):
182 # scmutil.filecache only uses the path for passing back into our
182 # scmutil.filecache only uses the path for passing back into our
183 # join(), so we can safely pass a list of paths and locations
183 # join(), so we can safely pass a list of paths and locations
184 super(mixedrepostorecache, self).__init__(*pathsandlocations)
184 super(mixedrepostorecache, self).__init__(*pathsandlocations)
185 _cachedfiles.update(pathsandlocations)
185 _cachedfiles.update(pathsandlocations)
186
186
187 def join(self, obj, fnameandlocation):
187 def join(self, obj, fnameandlocation):
188 fname, location = fnameandlocation
188 fname, location = fnameandlocation
189 if location == b'plain':
189 if location == b'plain':
190 return obj.vfs.join(fname)
190 return obj.vfs.join(fname)
191 else:
191 else:
192 if location != b'':
192 if location != b'':
193 raise error.ProgrammingError(
193 raise error.ProgrammingError(
194 b'unexpected location: %s' % location
194 b'unexpected location: %s' % location
195 )
195 )
196 return obj.sjoin(fname)
196 return obj.sjoin(fname)
197
197
198
198
199 def isfilecached(repo, name):
199 def isfilecached(repo, name):
200 """check if a repo has already cached "name" filecache-ed property
200 """check if a repo has already cached "name" filecache-ed property
201
201
202 This returns (cachedobj-or-None, iscached) tuple.
202 This returns (cachedobj-or-None, iscached) tuple.
203 """
203 """
204 cacheentry = repo.unfiltered()._filecache.get(name, None)
204 cacheentry = repo.unfiltered()._filecache.get(name, None)
205 if not cacheentry:
205 if not cacheentry:
206 return None, False
206 return None, False
207 return cacheentry.obj, True
207 return cacheentry.obj, True
208
208
209
209
210 class unfilteredpropertycache(util.propertycache):
210 class unfilteredpropertycache(util.propertycache):
211 """propertycache that apply to unfiltered repo only"""
211 """propertycache that apply to unfiltered repo only"""
212
212
213 def __get__(self, repo, type=None):
213 def __get__(self, repo, type=None):
214 unfi = repo.unfiltered()
214 unfi = repo.unfiltered()
215 if unfi is repo:
215 if unfi is repo:
216 return super(unfilteredpropertycache, self).__get__(unfi)
216 return super(unfilteredpropertycache, self).__get__(unfi)
217 return getattr(unfi, self.name)
217 return getattr(unfi, self.name)
218
218
219
219
220 class filteredpropertycache(util.propertycache):
220 class filteredpropertycache(util.propertycache):
221 """propertycache that must take filtering in account"""
221 """propertycache that must take filtering in account"""
222
222
223 def cachevalue(self, obj, value):
223 def cachevalue(self, obj, value):
224 object.__setattr__(obj, self.name, value)
224 object.__setattr__(obj, self.name, value)
225
225
226
226
227 def hasunfilteredcache(repo, name):
227 def hasunfilteredcache(repo, name):
228 """check if a repo has an unfilteredpropertycache value for <name>"""
228 """check if a repo has an unfilteredpropertycache value for <name>"""
229 return name in vars(repo.unfiltered())
229 return name in vars(repo.unfiltered())
230
230
231
231
232 def unfilteredmethod(orig):
232 def unfilteredmethod(orig):
233 """decorate method that always need to be run on unfiltered version"""
233 """decorate method that always need to be run on unfiltered version"""
234
234
235 @functools.wraps(orig)
235 @functools.wraps(orig)
236 def wrapper(repo, *args, **kwargs):
236 def wrapper(repo, *args, **kwargs):
237 return orig(repo.unfiltered(), *args, **kwargs)
237 return orig(repo.unfiltered(), *args, **kwargs)
238
238
239 return wrapper
239 return wrapper
240
240
241
241
242 moderncaps = {
242 moderncaps = {
243 b'lookup',
243 b'lookup',
244 b'branchmap',
244 b'branchmap',
245 b'pushkey',
245 b'pushkey',
246 b'known',
246 b'known',
247 b'getbundle',
247 b'getbundle',
248 b'unbundle',
248 b'unbundle',
249 }
249 }
250 legacycaps = moderncaps.union({b'changegroupsubset'})
250 legacycaps = moderncaps.union({b'changegroupsubset'})
251
251
252
252
253 @interfaceutil.implementer(repository.ipeercommandexecutor)
253 @interfaceutil.implementer(repository.ipeercommandexecutor)
254 class localcommandexecutor(object):
254 class localcommandexecutor(object):
255 def __init__(self, peer):
255 def __init__(self, peer):
256 self._peer = peer
256 self._peer = peer
257 self._sent = False
257 self._sent = False
258 self._closed = False
258 self._closed = False
259
259
260 def __enter__(self):
260 def __enter__(self):
261 return self
261 return self
262
262
263 def __exit__(self, exctype, excvalue, exctb):
263 def __exit__(self, exctype, excvalue, exctb):
264 self.close()
264 self.close()
265
265
266 def callcommand(self, command, args):
266 def callcommand(self, command, args):
267 if self._sent:
267 if self._sent:
268 raise error.ProgrammingError(
268 raise error.ProgrammingError(
269 b'callcommand() cannot be used after sendcommands()'
269 b'callcommand() cannot be used after sendcommands()'
270 )
270 )
271
271
272 if self._closed:
272 if self._closed:
273 raise error.ProgrammingError(
273 raise error.ProgrammingError(
274 b'callcommand() cannot be used after close()'
274 b'callcommand() cannot be used after close()'
275 )
275 )
276
276
277 # We don't need to support anything fancy. Just call the named
277 # We don't need to support anything fancy. Just call the named
278 # method on the peer and return a resolved future.
278 # method on the peer and return a resolved future.
279 fn = getattr(self._peer, pycompat.sysstr(command))
279 fn = getattr(self._peer, pycompat.sysstr(command))
280
280
281 f = pycompat.futures.Future()
281 f = pycompat.futures.Future()
282
282
283 try:
283 try:
284 result = fn(**pycompat.strkwargs(args))
284 result = fn(**pycompat.strkwargs(args))
285 except Exception:
285 except Exception:
286 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
286 pycompat.future_set_exception_info(f, sys.exc_info()[1:])
287 else:
287 else:
288 f.set_result(result)
288 f.set_result(result)
289
289
290 return f
290 return f
291
291
292 def sendcommands(self):
292 def sendcommands(self):
293 self._sent = True
293 self._sent = True
294
294
295 def close(self):
295 def close(self):
296 self._closed = True
296 self._closed = True
297
297
298
298
299 @interfaceutil.implementer(repository.ipeercommands)
299 @interfaceutil.implementer(repository.ipeercommands)
300 class localpeer(repository.peer):
300 class localpeer(repository.peer):
301 '''peer for a local repo; reflects only the most recent API'''
301 '''peer for a local repo; reflects only the most recent API'''
302
302
303 def __init__(self, repo, caps=None):
303 def __init__(self, repo, caps=None):
304 super(localpeer, self).__init__()
304 super(localpeer, self).__init__()
305
305
306 if caps is None:
306 if caps is None:
307 caps = moderncaps.copy()
307 caps = moderncaps.copy()
308 self._repo = repo.filtered(b'served')
308 self._repo = repo.filtered(b'served')
309 self.ui = repo.ui
309 self.ui = repo.ui
310
310
311 if repo._wanted_sidedata:
311 if repo._wanted_sidedata:
312 formatted = bundle2.format_remote_wanted_sidedata(repo)
312 formatted = bundle2.format_remote_wanted_sidedata(repo)
313 caps.add(b'exp-wanted-sidedata=' + formatted)
313 caps.add(b'exp-wanted-sidedata=' + formatted)
314
314
315 self._caps = repo._restrictcapabilities(caps)
315 self._caps = repo._restrictcapabilities(caps)
316
316
317 # Begin of _basepeer interface.
317 # Begin of _basepeer interface.
318
318
319 def url(self):
319 def url(self):
320 return self._repo.url()
320 return self._repo.url()
321
321
322 def local(self):
322 def local(self):
323 return self._repo
323 return self._repo
324
324
325 def peer(self):
325 def peer(self):
326 return self
326 return self
327
327
328 def canpush(self):
328 def canpush(self):
329 return True
329 return True
330
330
331 def close(self):
331 def close(self):
332 self._repo.close()
332 self._repo.close()
333
333
334 # End of _basepeer interface.
334 # End of _basepeer interface.
335
335
336 # Begin of _basewirecommands interface.
336 # Begin of _basewirecommands interface.
337
337
338 def branchmap(self):
338 def branchmap(self):
339 return self._repo.branchmap()
339 return self._repo.branchmap()
340
340
341 def capabilities(self):
341 def capabilities(self):
342 return self._caps
342 return self._caps
343
343
344 def clonebundles(self):
344 def clonebundles(self):
345 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
345 return self._repo.tryread(bundlecaches.CB_MANIFEST_FILE)
346
346
347 def debugwireargs(self, one, two, three=None, four=None, five=None):
347 def debugwireargs(self, one, two, three=None, four=None, five=None):
348 """Used to test argument passing over the wire"""
348 """Used to test argument passing over the wire"""
349 return b"%s %s %s %s %s" % (
349 return b"%s %s %s %s %s" % (
350 one,
350 one,
351 two,
351 two,
352 pycompat.bytestr(three),
352 pycompat.bytestr(three),
353 pycompat.bytestr(four),
353 pycompat.bytestr(four),
354 pycompat.bytestr(five),
354 pycompat.bytestr(five),
355 )
355 )
356
356
357 def getbundle(
357 def getbundle(
358 self,
358 self,
359 source,
359 source,
360 heads=None,
360 heads=None,
361 common=None,
361 common=None,
362 bundlecaps=None,
362 bundlecaps=None,
363 remote_sidedata=None,
363 remote_sidedata=None,
364 **kwargs
364 **kwargs
365 ):
365 ):
366 chunks = exchange.getbundlechunks(
366 chunks = exchange.getbundlechunks(
367 self._repo,
367 self._repo,
368 source,
368 source,
369 heads=heads,
369 heads=heads,
370 common=common,
370 common=common,
371 bundlecaps=bundlecaps,
371 bundlecaps=bundlecaps,
372 remote_sidedata=remote_sidedata,
372 remote_sidedata=remote_sidedata,
373 **kwargs
373 **kwargs
374 )[1]
374 )[1]
375 cb = util.chunkbuffer(chunks)
375 cb = util.chunkbuffer(chunks)
376
376
377 if exchange.bundle2requested(bundlecaps):
377 if exchange.bundle2requested(bundlecaps):
378 # When requesting a bundle2, getbundle returns a stream to make the
378 # When requesting a bundle2, getbundle returns a stream to make the
379 # wire level function happier. We need to build a proper object
379 # wire level function happier. We need to build a proper object
380 # from it in local peer.
380 # from it in local peer.
381 return bundle2.getunbundler(self.ui, cb)
381 return bundle2.getunbundler(self.ui, cb)
382 else:
382 else:
383 return changegroup.getunbundler(b'01', cb, None)
383 return changegroup.getunbundler(b'01', cb, None)
384
384
385 def heads(self):
385 def heads(self):
386 return self._repo.heads()
386 return self._repo.heads()
387
387
388 def known(self, nodes):
388 def known(self, nodes):
389 return self._repo.known(nodes)
389 return self._repo.known(nodes)
390
390
391 def listkeys(self, namespace):
391 def listkeys(self, namespace):
392 return self._repo.listkeys(namespace)
392 return self._repo.listkeys(namespace)
393
393
394 def lookup(self, key):
394 def lookup(self, key):
395 return self._repo.lookup(key)
395 return self._repo.lookup(key)
396
396
397 def pushkey(self, namespace, key, old, new):
397 def pushkey(self, namespace, key, old, new):
398 return self._repo.pushkey(namespace, key, old, new)
398 return self._repo.pushkey(namespace, key, old, new)
399
399
400 def stream_out(self):
400 def stream_out(self):
401 raise error.Abort(_(b'cannot perform stream clone against local peer'))
401 raise error.Abort(_(b'cannot perform stream clone against local peer'))
402
402
403 def unbundle(self, bundle, heads, url):
403 def unbundle(self, bundle, heads, url):
404 """apply a bundle on a repo
404 """apply a bundle on a repo
405
405
406 This function handles the repo locking itself."""
406 This function handles the repo locking itself."""
407 try:
407 try:
408 try:
408 try:
409 bundle = exchange.readbundle(self.ui, bundle, None)
409 bundle = exchange.readbundle(self.ui, bundle, None)
410 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
410 ret = exchange.unbundle(self._repo, bundle, heads, b'push', url)
411 if util.safehasattr(ret, b'getchunks'):
411 if util.safehasattr(ret, b'getchunks'):
412 # This is a bundle20 object, turn it into an unbundler.
412 # This is a bundle20 object, turn it into an unbundler.
413 # This little dance should be dropped eventually when the
413 # This little dance should be dropped eventually when the
414 # API is finally improved.
414 # API is finally improved.
415 stream = util.chunkbuffer(ret.getchunks())
415 stream = util.chunkbuffer(ret.getchunks())
416 ret = bundle2.getunbundler(self.ui, stream)
416 ret = bundle2.getunbundler(self.ui, stream)
417 return ret
417 return ret
418 except Exception as exc:
418 except Exception as exc:
419 # If the exception contains output salvaged from a bundle2
419 # If the exception contains output salvaged from a bundle2
420 # reply, we need to make sure it is printed before continuing
420 # reply, we need to make sure it is printed before continuing
421 # to fail. So we build a bundle2 with such output and consume
421 # to fail. So we build a bundle2 with such output and consume
422 # it directly.
422 # it directly.
423 #
423 #
424 # This is not very elegant but allows a "simple" solution for
424 # This is not very elegant but allows a "simple" solution for
425 # issue4594
425 # issue4594
426 output = getattr(exc, '_bundle2salvagedoutput', ())
426 output = getattr(exc, '_bundle2salvagedoutput', ())
427 if output:
427 if output:
428 bundler = bundle2.bundle20(self._repo.ui)
428 bundler = bundle2.bundle20(self._repo.ui)
429 for out in output:
429 for out in output:
430 bundler.addpart(out)
430 bundler.addpart(out)
431 stream = util.chunkbuffer(bundler.getchunks())
431 stream = util.chunkbuffer(bundler.getchunks())
432 b = bundle2.getunbundler(self.ui, stream)
432 b = bundle2.getunbundler(self.ui, stream)
433 bundle2.processbundle(self._repo, b)
433 bundle2.processbundle(self._repo, b)
434 raise
434 raise
435 except error.PushRaced as exc:
435 except error.PushRaced as exc:
436 raise error.ResponseError(
436 raise error.ResponseError(
437 _(b'push failed:'), stringutil.forcebytestr(exc)
437 _(b'push failed:'), stringutil.forcebytestr(exc)
438 )
438 )
439
439
440 # End of _basewirecommands interface.
440 # End of _basewirecommands interface.
441
441
442 # Begin of peer interface.
442 # Begin of peer interface.
443
443
444 def commandexecutor(self):
444 def commandexecutor(self):
445 return localcommandexecutor(self)
445 return localcommandexecutor(self)
446
446
447 # End of peer interface.
447 # End of peer interface.
448
448
449
449
450 @interfaceutil.implementer(repository.ipeerlegacycommands)
450 @interfaceutil.implementer(repository.ipeerlegacycommands)
451 class locallegacypeer(localpeer):
451 class locallegacypeer(localpeer):
452 """peer extension which implements legacy methods too; used for tests with
452 """peer extension which implements legacy methods too; used for tests with
453 restricted capabilities"""
453 restricted capabilities"""
454
454
455 def __init__(self, repo):
455 def __init__(self, repo):
456 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
456 super(locallegacypeer, self).__init__(repo, caps=legacycaps)
457
457
458 # Begin of baselegacywirecommands interface.
458 # Begin of baselegacywirecommands interface.
459
459
460 def between(self, pairs):
460 def between(self, pairs):
461 return self._repo.between(pairs)
461 return self._repo.between(pairs)
462
462
463 def branches(self, nodes):
463 def branches(self, nodes):
464 return self._repo.branches(nodes)
464 return self._repo.branches(nodes)
465
465
466 def changegroup(self, nodes, source):
466 def changegroup(self, nodes, source):
467 outgoing = discovery.outgoing(
467 outgoing = discovery.outgoing(
468 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
468 self._repo, missingroots=nodes, ancestorsof=self._repo.heads()
469 )
469 )
470 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
470 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
471
471
472 def changegroupsubset(self, bases, heads, source):
472 def changegroupsubset(self, bases, heads, source):
473 outgoing = discovery.outgoing(
473 outgoing = discovery.outgoing(
474 self._repo, missingroots=bases, ancestorsof=heads
474 self._repo, missingroots=bases, ancestorsof=heads
475 )
475 )
476 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
476 return changegroup.makechangegroup(self._repo, outgoing, b'01', source)
477
477
478 # End of baselegacywirecommands interface.
478 # End of baselegacywirecommands interface.
479
479
480
480
481 # Functions receiving (ui, features) that extensions can register to impact
481 # Functions receiving (ui, features) that extensions can register to impact
482 # the ability to load repositories with custom requirements. Only
482 # the ability to load repositories with custom requirements. Only
483 # functions defined in loaded extensions are called.
483 # functions defined in loaded extensions are called.
484 #
484 #
485 # The function receives a set of requirement strings that the repository
485 # The function receives a set of requirement strings that the repository
486 # is capable of opening. Functions will typically add elements to the
486 # is capable of opening. Functions will typically add elements to the
487 # set to reflect that the extension knows how to handle that requirements.
487 # set to reflect that the extension knows how to handle that requirements.
488 featuresetupfuncs = set()
488 featuresetupfuncs = set()
489
489
490
490
491 def _getsharedvfs(hgvfs, requirements):
491 def _getsharedvfs(hgvfs, requirements):
492 """returns the vfs object pointing to root of shared source
492 """returns the vfs object pointing to root of shared source
493 repo for a shared repository
493 repo for a shared repository
494
494
495 hgvfs is vfs pointing at .hg/ of current repo (shared one)
495 hgvfs is vfs pointing at .hg/ of current repo (shared one)
496 requirements is a set of requirements of current repo (shared one)
496 requirements is a set of requirements of current repo (shared one)
497 """
497 """
498 # The ``shared`` or ``relshared`` requirements indicate the
498 # The ``shared`` or ``relshared`` requirements indicate the
499 # store lives in the path contained in the ``.hg/sharedpath`` file.
499 # store lives in the path contained in the ``.hg/sharedpath`` file.
500 # This is an absolute path for ``shared`` and relative to
500 # This is an absolute path for ``shared`` and relative to
501 # ``.hg/`` for ``relshared``.
501 # ``.hg/`` for ``relshared``.
502 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
502 sharedpath = hgvfs.read(b'sharedpath').rstrip(b'\n')
503 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
503 if requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements:
504 sharedpath = util.normpath(hgvfs.join(sharedpath))
504 sharedpath = util.normpath(hgvfs.join(sharedpath))
505
505
506 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
506 sharedvfs = vfsmod.vfs(sharedpath, realpath=True)
507
507
508 if not sharedvfs.exists():
508 if not sharedvfs.exists():
509 raise error.RepoError(
509 raise error.RepoError(
510 _(b'.hg/sharedpath points to nonexistent directory %s')
510 _(b'.hg/sharedpath points to nonexistent directory %s')
511 % sharedvfs.base
511 % sharedvfs.base
512 )
512 )
513 return sharedvfs
513 return sharedvfs
514
514
515
515
516 def _readrequires(vfs, allowmissing):
516 def _readrequires(vfs, allowmissing):
517 """reads the require file present at root of this vfs
517 """reads the require file present at root of this vfs
518 and return a set of requirements
518 and return a set of requirements
519
519
520 If allowmissing is True, we suppress ENOENT if raised"""
520 If allowmissing is True, we suppress ENOENT if raised"""
521 # requires file contains a newline-delimited list of
521 # requires file contains a newline-delimited list of
522 # features/capabilities the opener (us) must have in order to use
522 # features/capabilities the opener (us) must have in order to use
523 # the repository. This file was introduced in Mercurial 0.9.2,
523 # the repository. This file was introduced in Mercurial 0.9.2,
524 # which means very old repositories may not have one. We assume
524 # which means very old repositories may not have one. We assume
525 # a missing file translates to no requirements.
525 # a missing file translates to no requirements.
526 try:
526 try:
527 requirements = set(vfs.read(b'requires').splitlines())
527 requirements = set(vfs.read(b'requires').splitlines())
528 except IOError as e:
528 except IOError as e:
529 if not (allowmissing and e.errno == errno.ENOENT):
529 if not (allowmissing and e.errno == errno.ENOENT):
530 raise
530 raise
531 requirements = set()
531 requirements = set()
532 return requirements
532 return requirements
533
533
534
534
535 def makelocalrepository(baseui, path, intents=None):
535 def makelocalrepository(baseui, path, intents=None):
536 """Create a local repository object.
536 """Create a local repository object.
537
537
538 Given arguments needed to construct a local repository, this function
538 Given arguments needed to construct a local repository, this function
539 performs various early repository loading functionality (such as
539 performs various early repository loading functionality (such as
540 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
540 reading the ``.hg/requires`` and ``.hg/hgrc`` files), validates that
541 the repository can be opened, derives a type suitable for representing
541 the repository can be opened, derives a type suitable for representing
542 that repository, and returns an instance of it.
542 that repository, and returns an instance of it.
543
543
544 The returned object conforms to the ``repository.completelocalrepository``
544 The returned object conforms to the ``repository.completelocalrepository``
545 interface.
545 interface.
546
546
547 The repository type is derived by calling a series of factory functions
547 The repository type is derived by calling a series of factory functions
548 for each aspect/interface of the final repository. These are defined by
548 for each aspect/interface of the final repository. These are defined by
549 ``REPO_INTERFACES``.
549 ``REPO_INTERFACES``.
550
550
551 Each factory function is called to produce a type implementing a specific
551 Each factory function is called to produce a type implementing a specific
552 interface. The cumulative list of returned types will be combined into a
552 interface. The cumulative list of returned types will be combined into a
553 new type and that type will be instantiated to represent the local
553 new type and that type will be instantiated to represent the local
554 repository.
554 repository.
555
555
556 The factory functions each receive various state that may be consulted
556 The factory functions each receive various state that may be consulted
557 as part of deriving a type.
557 as part of deriving a type.
558
558
559 Extensions should wrap these factory functions to customize repository type
559 Extensions should wrap these factory functions to customize repository type
560 creation. Note that an extension's wrapped function may be called even if
560 creation. Note that an extension's wrapped function may be called even if
561 that extension is not loaded for the repo being constructed. Extensions
561 that extension is not loaded for the repo being constructed. Extensions
562 should check if their ``__name__`` appears in the
562 should check if their ``__name__`` appears in the
563 ``extensionmodulenames`` set passed to the factory function and no-op if
563 ``extensionmodulenames`` set passed to the factory function and no-op if
564 not.
564 not.
565 """
565 """
566 ui = baseui.copy()
566 ui = baseui.copy()
567 # Prevent copying repo configuration.
567 # Prevent copying repo configuration.
568 ui.copy = baseui.copy
568 ui.copy = baseui.copy
569
569
570 # Working directory VFS rooted at repository root.
570 # Working directory VFS rooted at repository root.
571 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
571 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
572
572
573 # Main VFS for .hg/ directory.
573 # Main VFS for .hg/ directory.
574 hgpath = wdirvfs.join(b'.hg')
574 hgpath = wdirvfs.join(b'.hg')
575 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
575 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
576 # Whether this repository is shared one or not
576 # Whether this repository is shared one or not
577 shared = False
577 shared = False
578 # If this repository is shared, vfs pointing to shared repo
578 # If this repository is shared, vfs pointing to shared repo
579 sharedvfs = None
579 sharedvfs = None
580
580
581 # The .hg/ path should exist and should be a directory. All other
581 # The .hg/ path should exist and should be a directory. All other
582 # cases are errors.
582 # cases are errors.
583 if not hgvfs.isdir():
583 if not hgvfs.isdir():
584 try:
584 try:
585 hgvfs.stat()
585 hgvfs.stat()
586 except OSError as e:
586 except OSError as e:
587 if e.errno != errno.ENOENT:
587 if e.errno != errno.ENOENT:
588 raise
588 raise
589 except ValueError as e:
589 except ValueError as e:
590 # Can be raised on Python 3.8 when path is invalid.
590 # Can be raised on Python 3.8 when path is invalid.
591 raise error.Abort(
591 raise error.Abort(
592 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
592 _(b'invalid path %s: %s') % (path, stringutil.forcebytestr(e))
593 )
593 )
594
594
595 raise error.RepoError(_(b'repository %s not found') % path)
595 raise error.RepoError(_(b'repository %s not found') % path)
596
596
597 requirements = _readrequires(hgvfs, True)
597 requirements = _readrequires(hgvfs, True)
598 shared = (
598 shared = (
599 requirementsmod.SHARED_REQUIREMENT in requirements
599 requirementsmod.SHARED_REQUIREMENT in requirements
600 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
600 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
601 )
601 )
602 storevfs = None
602 storevfs = None
603 if shared:
603 if shared:
604 # This is a shared repo
604 # This is a shared repo
605 sharedvfs = _getsharedvfs(hgvfs, requirements)
605 sharedvfs = _getsharedvfs(hgvfs, requirements)
606 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
606 storevfs = vfsmod.vfs(sharedvfs.join(b'store'))
607 else:
607 else:
608 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
608 storevfs = vfsmod.vfs(hgvfs.join(b'store'))
609
609
610 # if .hg/requires contains the sharesafe requirement, it means
610 # if .hg/requires contains the sharesafe requirement, it means
611 # there exists a `.hg/store/requires` too and we should read it
611 # there exists a `.hg/store/requires` too and we should read it
612 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
612 # NOTE: presence of SHARESAFE_REQUIREMENT imply that store requirement
613 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
613 # is present. We never write SHARESAFE_REQUIREMENT for a repo if store
614 # is not present, refer checkrequirementscompat() for that
614 # is not present, refer checkrequirementscompat() for that
615 #
615 #
616 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
616 # However, if SHARESAFE_REQUIREMENT is not present, it means that the
617 # repository was shared the old way. We check the share source .hg/requires
617 # repository was shared the old way. We check the share source .hg/requires
618 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
618 # for SHARESAFE_REQUIREMENT to detect whether the current repository needs
619 # to be reshared
619 # to be reshared
620 hint = _(b"see `hg help config.format.use-share-safe` for more information")
620 hint = _(b"see `hg help config.format.use-share-safe` for more information")
621 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
621 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
622
622
623 if (
623 if (
624 shared
624 shared
625 and requirementsmod.SHARESAFE_REQUIREMENT
625 and requirementsmod.SHARESAFE_REQUIREMENT
626 not in _readrequires(sharedvfs, True)
626 not in _readrequires(sharedvfs, True)
627 ):
627 ):
628 mismatch_warn = ui.configbool(
628 mismatch_warn = ui.configbool(
629 b'share', b'safe-mismatch.source-not-safe.warn'
629 b'share', b'safe-mismatch.source-not-safe.warn'
630 )
630 )
631 mismatch_config = ui.config(
631 mismatch_config = ui.config(
632 b'share', b'safe-mismatch.source-not-safe'
632 b'share', b'safe-mismatch.source-not-safe'
633 )
633 )
634 if mismatch_config in (
634 if mismatch_config in (
635 b'downgrade-allow',
635 b'downgrade-allow',
636 b'allow',
636 b'allow',
637 b'downgrade-abort',
637 b'downgrade-abort',
638 ):
638 ):
639 # prevent cyclic import localrepo -> upgrade -> localrepo
639 # prevent cyclic import localrepo -> upgrade -> localrepo
640 from . import upgrade
640 from . import upgrade
641
641
642 upgrade.downgrade_share_to_non_safe(
642 upgrade.downgrade_share_to_non_safe(
643 ui,
643 ui,
644 hgvfs,
644 hgvfs,
645 sharedvfs,
645 sharedvfs,
646 requirements,
646 requirements,
647 mismatch_config,
647 mismatch_config,
648 mismatch_warn,
648 mismatch_warn,
649 )
649 )
650 elif mismatch_config == b'abort':
650 elif mismatch_config == b'abort':
651 raise error.Abort(
651 raise error.Abort(
652 _(b"share source does not support share-safe requirement"),
652 _(b"share source does not support share-safe requirement"),
653 hint=hint,
653 hint=hint,
654 )
654 )
655 else:
655 else:
656 raise error.Abort(
656 raise error.Abort(
657 _(
657 _(
658 b"share-safe mismatch with source.\nUnrecognized"
658 b"share-safe mismatch with source.\nUnrecognized"
659 b" value '%s' of `share.safe-mismatch.source-not-safe`"
659 b" value '%s' of `share.safe-mismatch.source-not-safe`"
660 b" set."
660 b" set."
661 )
661 )
662 % mismatch_config,
662 % mismatch_config,
663 hint=hint,
663 hint=hint,
664 )
664 )
665 else:
665 else:
666 requirements |= _readrequires(storevfs, False)
666 requirements |= _readrequires(storevfs, False)
667 elif shared:
667 elif shared:
668 sourcerequires = _readrequires(sharedvfs, False)
668 sourcerequires = _readrequires(sharedvfs, False)
669 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
669 if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires:
670 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
670 mismatch_config = ui.config(b'share', b'safe-mismatch.source-safe')
671 mismatch_warn = ui.configbool(
671 mismatch_warn = ui.configbool(
672 b'share', b'safe-mismatch.source-safe.warn'
672 b'share', b'safe-mismatch.source-safe.warn'
673 )
673 )
674 if mismatch_config in (
674 if mismatch_config in (
675 b'upgrade-allow',
675 b'upgrade-allow',
676 b'allow',
676 b'allow',
677 b'upgrade-abort',
677 b'upgrade-abort',
678 ):
678 ):
679 # prevent cyclic import localrepo -> upgrade -> localrepo
679 # prevent cyclic import localrepo -> upgrade -> localrepo
680 from . import upgrade
680 from . import upgrade
681
681
682 upgrade.upgrade_share_to_safe(
682 upgrade.upgrade_share_to_safe(
683 ui,
683 ui,
684 hgvfs,
684 hgvfs,
685 storevfs,
685 storevfs,
686 requirements,
686 requirements,
687 mismatch_config,
687 mismatch_config,
688 mismatch_warn,
688 mismatch_warn,
689 )
689 )
690 elif mismatch_config == b'abort':
690 elif mismatch_config == b'abort':
691 raise error.Abort(
691 raise error.Abort(
692 _(
692 _(
693 b'version mismatch: source uses share-safe'
693 b'version mismatch: source uses share-safe'
694 b' functionality while the current share does not'
694 b' functionality while the current share does not'
695 ),
695 ),
696 hint=hint,
696 hint=hint,
697 )
697 )
698 else:
698 else:
699 raise error.Abort(
699 raise error.Abort(
700 _(
700 _(
701 b"share-safe mismatch with source.\nUnrecognized"
701 b"share-safe mismatch with source.\nUnrecognized"
702 b" value '%s' of `share.safe-mismatch.source-safe` set."
702 b" value '%s' of `share.safe-mismatch.source-safe` set."
703 )
703 )
704 % mismatch_config,
704 % mismatch_config,
705 hint=hint,
705 hint=hint,
706 )
706 )
707
707
708 # The .hg/hgrc file may load extensions or contain config options
708 # The .hg/hgrc file may load extensions or contain config options
709 # that influence repository construction. Attempt to load it and
709 # that influence repository construction. Attempt to load it and
710 # process any new extensions that it may have pulled in.
710 # process any new extensions that it may have pulled in.
711 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
711 if loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs):
712 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
712 afterhgrcload(ui, wdirvfs, hgvfs, requirements)
713 extensions.loadall(ui)
713 extensions.loadall(ui)
714 extensions.populateui(ui)
714 extensions.populateui(ui)
715
715
716 # Set of module names of extensions loaded for this repository.
716 # Set of module names of extensions loaded for this repository.
717 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
717 extensionmodulenames = {m.__name__ for n, m in extensions.extensions(ui)}
718
718
719 supportedrequirements = gathersupportedrequirements(ui)
719 supportedrequirements = gathersupportedrequirements(ui)
720
720
721 # We first validate the requirements are known.
721 # We first validate the requirements are known.
722 ensurerequirementsrecognized(requirements, supportedrequirements)
722 ensurerequirementsrecognized(requirements, supportedrequirements)
723
723
724 # Then we validate that the known set is reasonable to use together.
724 # Then we validate that the known set is reasonable to use together.
725 ensurerequirementscompatible(ui, requirements)
725 ensurerequirementscompatible(ui, requirements)
726
726
727 # TODO there are unhandled edge cases related to opening repositories with
727 # TODO there are unhandled edge cases related to opening repositories with
728 # shared storage. If storage is shared, we should also test for requirements
728 # shared storage. If storage is shared, we should also test for requirements
729 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
729 # compatibility in the pointed-to repo. This entails loading the .hg/hgrc in
730 # that repo, as that repo may load extensions needed to open it. This is a
730 # that repo, as that repo may load extensions needed to open it. This is a
731 # bit complicated because we don't want the other hgrc to overwrite settings
731 # bit complicated because we don't want the other hgrc to overwrite settings
732 # in this hgrc.
732 # in this hgrc.
733 #
733 #
734 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
734 # This bug is somewhat mitigated by the fact that we copy the .hg/requires
735 # file when sharing repos. But if a requirement is added after the share is
735 # file when sharing repos. But if a requirement is added after the share is
736 # performed, thereby introducing a new requirement for the opener, we may
736 # performed, thereby introducing a new requirement for the opener, we may
737 # will not see that and could encounter a run-time error interacting with
737 # will not see that and could encounter a run-time error interacting with
738 # that shared store since it has an unknown-to-us requirement.
738 # that shared store since it has an unknown-to-us requirement.
739
739
740 # At this point, we know we should be capable of opening the repository.
740 # At this point, we know we should be capable of opening the repository.
741 # Now get on with doing that.
741 # Now get on with doing that.
742
742
743 features = set()
743 features = set()
744
744
745 # The "store" part of the repository holds versioned data. How it is
745 # The "store" part of the repository holds versioned data. How it is
746 # accessed is determined by various requirements. If `shared` or
746 # accessed is determined by various requirements. If `shared` or
747 # `relshared` requirements are present, this indicates current repository
747 # `relshared` requirements are present, this indicates current repository
748 # is a share and store exists in path mentioned in `.hg/sharedpath`
748 # is a share and store exists in path mentioned in `.hg/sharedpath`
749 if shared:
749 if shared:
750 storebasepath = sharedvfs.base
750 storebasepath = sharedvfs.base
751 cachepath = sharedvfs.join(b'cache')
751 cachepath = sharedvfs.join(b'cache')
752 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
752 features.add(repository.REPO_FEATURE_SHARED_STORAGE)
753 else:
753 else:
754 storebasepath = hgvfs.base
754 storebasepath = hgvfs.base
755 cachepath = hgvfs.join(b'cache')
755 cachepath = hgvfs.join(b'cache')
756 wcachepath = hgvfs.join(b'wcache')
756 wcachepath = hgvfs.join(b'wcache')
757
757
758 # The store has changed over time and the exact layout is dictated by
758 # The store has changed over time and the exact layout is dictated by
759 # requirements. The store interface abstracts differences across all
759 # requirements. The store interface abstracts differences across all
760 # of them.
760 # of them.
761 store = makestore(
761 store = makestore(
762 requirements,
762 requirements,
763 storebasepath,
763 storebasepath,
764 lambda base: vfsmod.vfs(base, cacheaudited=True),
764 lambda base: vfsmod.vfs(base, cacheaudited=True),
765 )
765 )
766 hgvfs.createmode = store.createmode
766 hgvfs.createmode = store.createmode
767
767
768 storevfs = store.vfs
768 storevfs = store.vfs
769 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
769 storevfs.options = resolvestorevfsoptions(ui, requirements, features)
770
770
771 if (
771 if (
772 requirementsmod.REVLOGV2_REQUIREMENT in requirements
772 requirementsmod.REVLOGV2_REQUIREMENT in requirements
773 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
773 or requirementsmod.CHANGELOGV2_REQUIREMENT in requirements
774 ):
774 ):
775 features.add(repository.REPO_FEATURE_SIDE_DATA)
775 features.add(repository.REPO_FEATURE_SIDE_DATA)
776 # the revlogv2 docket introduced race condition that we need to fix
776 # the revlogv2 docket introduced race condition that we need to fix
777 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
777 features.discard(repository.REPO_FEATURE_STREAM_CLONE)
778
778
779 # The cache vfs is used to manage cache files.
779 # The cache vfs is used to manage cache files.
780 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
780 cachevfs = vfsmod.vfs(cachepath, cacheaudited=True)
781 cachevfs.createmode = store.createmode
781 cachevfs.createmode = store.createmode
782 # The cache vfs is used to manage cache files related to the working copy
782 # The cache vfs is used to manage cache files related to the working copy
783 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
783 wcachevfs = vfsmod.vfs(wcachepath, cacheaudited=True)
784 wcachevfs.createmode = store.createmode
784 wcachevfs.createmode = store.createmode
785
785
786 # Now resolve the type for the repository object. We do this by repeatedly
786 # Now resolve the type for the repository object. We do this by repeatedly
787 # calling a factory function to produces types for specific aspects of the
787 # calling a factory function to produces types for specific aspects of the
788 # repo's operation. The aggregate returned types are used as base classes
788 # repo's operation. The aggregate returned types are used as base classes
789 # for a dynamically-derived type, which will represent our new repository.
789 # for a dynamically-derived type, which will represent our new repository.
790
790
791 bases = []
791 bases = []
792 extrastate = {}
792 extrastate = {}
793
793
794 for iface, fn in REPO_INTERFACES:
794 for iface, fn in REPO_INTERFACES:
795 # We pass all potentially useful state to give extensions tons of
795 # We pass all potentially useful state to give extensions tons of
796 # flexibility.
796 # flexibility.
797 typ = fn()(
797 typ = fn()(
798 ui=ui,
798 ui=ui,
799 intents=intents,
799 intents=intents,
800 requirements=requirements,
800 requirements=requirements,
801 features=features,
801 features=features,
802 wdirvfs=wdirvfs,
802 wdirvfs=wdirvfs,
803 hgvfs=hgvfs,
803 hgvfs=hgvfs,
804 store=store,
804 store=store,
805 storevfs=storevfs,
805 storevfs=storevfs,
806 storeoptions=storevfs.options,
806 storeoptions=storevfs.options,
807 cachevfs=cachevfs,
807 cachevfs=cachevfs,
808 wcachevfs=wcachevfs,
808 wcachevfs=wcachevfs,
809 extensionmodulenames=extensionmodulenames,
809 extensionmodulenames=extensionmodulenames,
810 extrastate=extrastate,
810 extrastate=extrastate,
811 baseclasses=bases,
811 baseclasses=bases,
812 )
812 )
813
813
814 if not isinstance(typ, type):
814 if not isinstance(typ, type):
815 raise error.ProgrammingError(
815 raise error.ProgrammingError(
816 b'unable to construct type for %s' % iface
816 b'unable to construct type for %s' % iface
817 )
817 )
818
818
819 bases.append(typ)
819 bases.append(typ)
820
820
821 # type() allows you to use characters in type names that wouldn't be
821 # type() allows you to use characters in type names that wouldn't be
822 # recognized as Python symbols in source code. We abuse that to add
822 # recognized as Python symbols in source code. We abuse that to add
823 # rich information about our constructed repo.
823 # rich information about our constructed repo.
824 name = pycompat.sysstr(
824 name = pycompat.sysstr(
825 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
825 b'derivedrepo:%s<%s>' % (wdirvfs.base, b','.join(sorted(requirements)))
826 )
826 )
827
827
828 cls = type(name, tuple(bases), {})
828 cls = type(name, tuple(bases), {})
829
829
830 return cls(
830 return cls(
831 baseui=baseui,
831 baseui=baseui,
832 ui=ui,
832 ui=ui,
833 origroot=path,
833 origroot=path,
834 wdirvfs=wdirvfs,
834 wdirvfs=wdirvfs,
835 hgvfs=hgvfs,
835 hgvfs=hgvfs,
836 requirements=requirements,
836 requirements=requirements,
837 supportedrequirements=supportedrequirements,
837 supportedrequirements=supportedrequirements,
838 sharedpath=storebasepath,
838 sharedpath=storebasepath,
839 store=store,
839 store=store,
840 cachevfs=cachevfs,
840 cachevfs=cachevfs,
841 wcachevfs=wcachevfs,
841 wcachevfs=wcachevfs,
842 features=features,
842 features=features,
843 intents=intents,
843 intents=intents,
844 )
844 )
845
845
846
846
847 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
847 def loadhgrc(ui, wdirvfs, hgvfs, requirements, sharedvfs=None):
848 """Load hgrc files/content into a ui instance.
848 """Load hgrc files/content into a ui instance.
849
849
850 This is called during repository opening to load any additional
850 This is called during repository opening to load any additional
851 config files or settings relevant to the current repository.
851 config files or settings relevant to the current repository.
852
852
853 Returns a bool indicating whether any additional configs were loaded.
853 Returns a bool indicating whether any additional configs were loaded.
854
854
855 Extensions should monkeypatch this function to modify how per-repo
855 Extensions should monkeypatch this function to modify how per-repo
856 configs are loaded. For example, an extension may wish to pull in
856 configs are loaded. For example, an extension may wish to pull in
857 configs from alternate files or sources.
857 configs from alternate files or sources.
858
858
859 sharedvfs is vfs object pointing to source repo if the current one is a
859 sharedvfs is vfs object pointing to source repo if the current one is a
860 shared one
860 shared one
861 """
861 """
862 if not rcutil.use_repo_hgrc():
862 if not rcutil.use_repo_hgrc():
863 return False
863 return False
864
864
865 ret = False
865 ret = False
866 # first load config from shared source if we has to
866 # first load config from shared source if we has to
867 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
867 if requirementsmod.SHARESAFE_REQUIREMENT in requirements and sharedvfs:
868 try:
868 try:
869 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
869 ui.readconfig(sharedvfs.join(b'hgrc'), root=sharedvfs.base)
870 ret = True
870 ret = True
871 except IOError:
871 except IOError:
872 pass
872 pass
873
873
874 try:
874 try:
875 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
875 ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base)
876 ret = True
876 ret = True
877 except IOError:
877 except IOError:
878 pass
878 pass
879
879
880 try:
880 try:
881 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
881 ui.readconfig(hgvfs.join(b'hgrc-not-shared'), root=wdirvfs.base)
882 ret = True
882 ret = True
883 except IOError:
883 except IOError:
884 pass
884 pass
885
885
886 return ret
886 return ret
887
887
888
888
889 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
889 def afterhgrcload(ui, wdirvfs, hgvfs, requirements):
890 """Perform additional actions after .hg/hgrc is loaded.
890 """Perform additional actions after .hg/hgrc is loaded.
891
891
892 This function is called during repository loading immediately after
892 This function is called during repository loading immediately after
893 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
893 the .hg/hgrc file is loaded and before per-repo extensions are loaded.
894
894
895 The function can be used to validate configs, automatically add
895 The function can be used to validate configs, automatically add
896 options (including extensions) based on requirements, etc.
896 options (including extensions) based on requirements, etc.
897 """
897 """
898
898
899 # Map of requirements to list of extensions to load automatically when
899 # Map of requirements to list of extensions to load automatically when
900 # requirement is present.
900 # requirement is present.
901 autoextensions = {
901 autoextensions = {
902 b'git': [b'git'],
902 b'git': [b'git'],
903 b'largefiles': [b'largefiles'],
903 b'largefiles': [b'largefiles'],
904 b'lfs': [b'lfs'],
904 b'lfs': [b'lfs'],
905 }
905 }
906
906
907 for requirement, names in sorted(autoextensions.items()):
907 for requirement, names in sorted(autoextensions.items()):
908 if requirement not in requirements:
908 if requirement not in requirements:
909 continue
909 continue
910
910
911 for name in names:
911 for name in names:
912 if not ui.hasconfig(b'extensions', name):
912 if not ui.hasconfig(b'extensions', name):
913 ui.setconfig(b'extensions', name, b'', source=b'autoload')
913 ui.setconfig(b'extensions', name, b'', source=b'autoload')
914
914
915
915
916 def gathersupportedrequirements(ui):
916 def gathersupportedrequirements(ui):
917 """Determine the complete set of recognized requirements."""
917 """Determine the complete set of recognized requirements."""
918 # Start with all requirements supported by this file.
918 # Start with all requirements supported by this file.
919 supported = set(localrepository._basesupported)
919 supported = set(localrepository._basesupported)
920
920
921 # Execute ``featuresetupfuncs`` entries if they belong to an extension
921 # Execute ``featuresetupfuncs`` entries if they belong to an extension
922 # relevant to this ui instance.
922 # relevant to this ui instance.
923 modules = {m.__name__ for n, m in extensions.extensions(ui)}
923 modules = {m.__name__ for n, m in extensions.extensions(ui)}
924
924
925 for fn in featuresetupfuncs:
925 for fn in featuresetupfuncs:
926 if fn.__module__ in modules:
926 if fn.__module__ in modules:
927 fn(ui, supported)
927 fn(ui, supported)
928
928
929 # Add derived requirements from registered compression engines.
929 # Add derived requirements from registered compression engines.
930 for name in util.compengines:
930 for name in util.compengines:
931 engine = util.compengines[name]
931 engine = util.compengines[name]
932 if engine.available() and engine.revlogheader():
932 if engine.available() and engine.revlogheader():
933 supported.add(b'exp-compression-%s' % name)
933 supported.add(b'exp-compression-%s' % name)
934 if engine.name() == b'zstd':
934 if engine.name() == b'zstd':
935 supported.add(b'revlog-compression-zstd')
935 supported.add(requirementsmod.REVLOG_COMPRESSION_ZSTD)
936
936
937 return supported
937 return supported
938
938
939
939
940 def ensurerequirementsrecognized(requirements, supported):
940 def ensurerequirementsrecognized(requirements, supported):
941 """Validate that a set of local requirements is recognized.
941 """Validate that a set of local requirements is recognized.
942
942
943 Receives a set of requirements. Raises an ``error.RepoError`` if there
943 Receives a set of requirements. Raises an ``error.RepoError`` if there
944 exists any requirement in that set that currently loaded code doesn't
944 exists any requirement in that set that currently loaded code doesn't
945 recognize.
945 recognize.
946
946
947 Returns a set of supported requirements.
947 Returns a set of supported requirements.
948 """
948 """
949 missing = set()
949 missing = set()
950
950
951 for requirement in requirements:
951 for requirement in requirements:
952 if requirement in supported:
952 if requirement in supported:
953 continue
953 continue
954
954
955 if not requirement or not requirement[0:1].isalnum():
955 if not requirement or not requirement[0:1].isalnum():
956 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
956 raise error.RequirementError(_(b'.hg/requires file is corrupt'))
957
957
958 missing.add(requirement)
958 missing.add(requirement)
959
959
960 if missing:
960 if missing:
961 raise error.RequirementError(
961 raise error.RequirementError(
962 _(b'repository requires features unknown to this Mercurial: %s')
962 _(b'repository requires features unknown to this Mercurial: %s')
963 % b' '.join(sorted(missing)),
963 % b' '.join(sorted(missing)),
964 hint=_(
964 hint=_(
965 b'see https://mercurial-scm.org/wiki/MissingRequirement '
965 b'see https://mercurial-scm.org/wiki/MissingRequirement '
966 b'for more information'
966 b'for more information'
967 ),
967 ),
968 )
968 )
969
969
970
970
971 def ensurerequirementscompatible(ui, requirements):
971 def ensurerequirementscompatible(ui, requirements):
972 """Validates that a set of recognized requirements is mutually compatible.
972 """Validates that a set of recognized requirements is mutually compatible.
973
973
974 Some requirements may not be compatible with others or require
974 Some requirements may not be compatible with others or require
975 config options that aren't enabled. This function is called during
975 config options that aren't enabled. This function is called during
976 repository opening to ensure that the set of requirements needed
976 repository opening to ensure that the set of requirements needed
977 to open a repository is sane and compatible with config options.
977 to open a repository is sane and compatible with config options.
978
978
979 Extensions can monkeypatch this function to perform additional
979 Extensions can monkeypatch this function to perform additional
980 checking.
980 checking.
981
981
982 ``error.RepoError`` should be raised on failure.
982 ``error.RepoError`` should be raised on failure.
983 """
983 """
984 if (
984 if (
985 requirementsmod.SPARSE_REQUIREMENT in requirements
985 requirementsmod.SPARSE_REQUIREMENT in requirements
986 and not sparse.enabled
986 and not sparse.enabled
987 ):
987 ):
988 raise error.RepoError(
988 raise error.RepoError(
989 _(
989 _(
990 b'repository is using sparse feature but '
990 b'repository is using sparse feature but '
991 b'sparse is not enabled; enable the '
991 b'sparse is not enabled; enable the '
992 b'"sparse" extensions to access'
992 b'"sparse" extensions to access'
993 )
993 )
994 )
994 )
995
995
996
996
997 def makestore(requirements, path, vfstype):
997 def makestore(requirements, path, vfstype):
998 """Construct a storage object for a repository."""
998 """Construct a storage object for a repository."""
999 if requirementsmod.STORE_REQUIREMENT in requirements:
999 if requirementsmod.STORE_REQUIREMENT in requirements:
1000 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
1000 if requirementsmod.FNCACHE_REQUIREMENT in requirements:
1001 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
1001 dotencode = requirementsmod.DOTENCODE_REQUIREMENT in requirements
1002 return storemod.fncachestore(path, vfstype, dotencode)
1002 return storemod.fncachestore(path, vfstype, dotencode)
1003
1003
1004 return storemod.encodedstore(path, vfstype)
1004 return storemod.encodedstore(path, vfstype)
1005
1005
1006 return storemod.basicstore(path, vfstype)
1006 return storemod.basicstore(path, vfstype)
1007
1007
1008
1008
1009 def resolvestorevfsoptions(ui, requirements, features):
1009 def resolvestorevfsoptions(ui, requirements, features):
1010 """Resolve the options to pass to the store vfs opener.
1010 """Resolve the options to pass to the store vfs opener.
1011
1011
1012 The returned dict is used to influence behavior of the storage layer.
1012 The returned dict is used to influence behavior of the storage layer.
1013 """
1013 """
1014 options = {}
1014 options = {}
1015
1015
1016 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
1016 if requirementsmod.TREEMANIFEST_REQUIREMENT in requirements:
1017 options[b'treemanifest'] = True
1017 options[b'treemanifest'] = True
1018
1018
1019 # experimental config: format.manifestcachesize
1019 # experimental config: format.manifestcachesize
1020 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
1020 manifestcachesize = ui.configint(b'format', b'manifestcachesize')
1021 if manifestcachesize is not None:
1021 if manifestcachesize is not None:
1022 options[b'manifestcachesize'] = manifestcachesize
1022 options[b'manifestcachesize'] = manifestcachesize
1023
1023
1024 # In the absence of another requirement superseding a revlog-related
1024 # In the absence of another requirement superseding a revlog-related
1025 # requirement, we have to assume the repo is using revlog version 0.
1025 # requirement, we have to assume the repo is using revlog version 0.
1026 # This revlog format is super old and we don't bother trying to parse
1026 # This revlog format is super old and we don't bother trying to parse
1027 # opener options for it because those options wouldn't do anything
1027 # opener options for it because those options wouldn't do anything
1028 # meaningful on such old repos.
1028 # meaningful on such old repos.
1029 if (
1029 if (
1030 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1030 requirementsmod.REVLOGV1_REQUIREMENT in requirements
1031 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1031 or requirementsmod.REVLOGV2_REQUIREMENT in requirements
1032 ):
1032 ):
1033 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1033 options.update(resolverevlogstorevfsoptions(ui, requirements, features))
1034 else: # explicitly mark repo as using revlogv0
1034 else: # explicitly mark repo as using revlogv0
1035 options[b'revlogv0'] = True
1035 options[b'revlogv0'] = True
1036
1036
1037 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1037 if requirementsmod.COPIESSDC_REQUIREMENT in requirements:
1038 options[b'copies-storage'] = b'changeset-sidedata'
1038 options[b'copies-storage'] = b'changeset-sidedata'
1039 else:
1039 else:
1040 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1040 writecopiesto = ui.config(b'experimental', b'copies.write-to')
1041 copiesextramode = (b'changeset-only', b'compatibility')
1041 copiesextramode = (b'changeset-only', b'compatibility')
1042 if writecopiesto in copiesextramode:
1042 if writecopiesto in copiesextramode:
1043 options[b'copies-storage'] = b'extra'
1043 options[b'copies-storage'] = b'extra'
1044
1044
1045 return options
1045 return options
1046
1046
1047
1047
1048 def resolverevlogstorevfsoptions(ui, requirements, features):
1048 def resolverevlogstorevfsoptions(ui, requirements, features):
1049 """Resolve opener options specific to revlogs."""
1049 """Resolve opener options specific to revlogs."""
1050
1050
1051 options = {}
1051 options = {}
1052 options[b'flagprocessors'] = {}
1052 options[b'flagprocessors'] = {}
1053
1053
1054 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1054 if requirementsmod.REVLOGV1_REQUIREMENT in requirements:
1055 options[b'revlogv1'] = True
1055 options[b'revlogv1'] = True
1056 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1056 if requirementsmod.REVLOGV2_REQUIREMENT in requirements:
1057 options[b'revlogv2'] = True
1057 options[b'revlogv2'] = True
1058 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1058 if requirementsmod.CHANGELOGV2_REQUIREMENT in requirements:
1059 options[b'changelogv2'] = True
1059 options[b'changelogv2'] = True
1060
1060
1061 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1061 if requirementsmod.GENERALDELTA_REQUIREMENT in requirements:
1062 options[b'generaldelta'] = True
1062 options[b'generaldelta'] = True
1063
1063
1064 # experimental config: format.chunkcachesize
1064 # experimental config: format.chunkcachesize
1065 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1065 chunkcachesize = ui.configint(b'format', b'chunkcachesize')
1066 if chunkcachesize is not None:
1066 if chunkcachesize is not None:
1067 options[b'chunkcachesize'] = chunkcachesize
1067 options[b'chunkcachesize'] = chunkcachesize
1068
1068
1069 deltabothparents = ui.configbool(
1069 deltabothparents = ui.configbool(
1070 b'storage', b'revlog.optimize-delta-parent-choice'
1070 b'storage', b'revlog.optimize-delta-parent-choice'
1071 )
1071 )
1072 options[b'deltabothparents'] = deltabothparents
1072 options[b'deltabothparents'] = deltabothparents
1073
1073
1074 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1074 issue6528 = ui.configbool(b'storage', b'revlog.issue6528.fix-incoming')
1075 options[b'issue6528.fix-incoming'] = issue6528
1075 options[b'issue6528.fix-incoming'] = issue6528
1076
1076
1077 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1077 lazydelta = ui.configbool(b'storage', b'revlog.reuse-external-delta')
1078 lazydeltabase = False
1078 lazydeltabase = False
1079 if lazydelta:
1079 if lazydelta:
1080 lazydeltabase = ui.configbool(
1080 lazydeltabase = ui.configbool(
1081 b'storage', b'revlog.reuse-external-delta-parent'
1081 b'storage', b'revlog.reuse-external-delta-parent'
1082 )
1082 )
1083 if lazydeltabase is None:
1083 if lazydeltabase is None:
1084 lazydeltabase = not scmutil.gddeltaconfig(ui)
1084 lazydeltabase = not scmutil.gddeltaconfig(ui)
1085 options[b'lazydelta'] = lazydelta
1085 options[b'lazydelta'] = lazydelta
1086 options[b'lazydeltabase'] = lazydeltabase
1086 options[b'lazydeltabase'] = lazydeltabase
1087
1087
1088 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1088 chainspan = ui.configbytes(b'experimental', b'maxdeltachainspan')
1089 if 0 <= chainspan:
1089 if 0 <= chainspan:
1090 options[b'maxdeltachainspan'] = chainspan
1090 options[b'maxdeltachainspan'] = chainspan
1091
1091
1092 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1092 mmapindexthreshold = ui.configbytes(b'experimental', b'mmapindexthreshold')
1093 if mmapindexthreshold is not None:
1093 if mmapindexthreshold is not None:
1094 options[b'mmapindexthreshold'] = mmapindexthreshold
1094 options[b'mmapindexthreshold'] = mmapindexthreshold
1095
1095
1096 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1096 withsparseread = ui.configbool(b'experimental', b'sparse-read')
1097 srdensitythres = float(
1097 srdensitythres = float(
1098 ui.config(b'experimental', b'sparse-read.density-threshold')
1098 ui.config(b'experimental', b'sparse-read.density-threshold')
1099 )
1099 )
1100 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1100 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size')
1101 options[b'with-sparse-read'] = withsparseread
1101 options[b'with-sparse-read'] = withsparseread
1102 options[b'sparse-read-density-threshold'] = srdensitythres
1102 options[b'sparse-read-density-threshold'] = srdensitythres
1103 options[b'sparse-read-min-gap-size'] = srmingapsize
1103 options[b'sparse-read-min-gap-size'] = srmingapsize
1104
1104
1105 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1105 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements
1106 options[b'sparse-revlog'] = sparserevlog
1106 options[b'sparse-revlog'] = sparserevlog
1107 if sparserevlog:
1107 if sparserevlog:
1108 options[b'generaldelta'] = True
1108 options[b'generaldelta'] = True
1109
1109
1110 maxchainlen = None
1110 maxchainlen = None
1111 if sparserevlog:
1111 if sparserevlog:
1112 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1112 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
1113 # experimental config: format.maxchainlen
1113 # experimental config: format.maxchainlen
1114 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1114 maxchainlen = ui.configint(b'format', b'maxchainlen', maxchainlen)
1115 if maxchainlen is not None:
1115 if maxchainlen is not None:
1116 options[b'maxchainlen'] = maxchainlen
1116 options[b'maxchainlen'] = maxchainlen
1117
1117
1118 for r in requirements:
1118 for r in requirements:
1119 # we allow multiple compression engine requirement to co-exist because
1119 # we allow multiple compression engine requirement to co-exist because
1120 # strickly speaking, revlog seems to support mixed compression style.
1120 # strickly speaking, revlog seems to support mixed compression style.
1121 #
1121 #
1122 # The compression used for new entries will be "the last one"
1122 # The compression used for new entries will be "the last one"
1123 prefix = r.startswith
1123 prefix = r.startswith
1124 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1124 if prefix(b'revlog-compression-') or prefix(b'exp-compression-'):
1125 options[b'compengine'] = r.split(b'-', 2)[2]
1125 options[b'compengine'] = r.split(b'-', 2)[2]
1126
1126
1127 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1127 options[b'zlib.level'] = ui.configint(b'storage', b'revlog.zlib.level')
1128 if options[b'zlib.level'] is not None:
1128 if options[b'zlib.level'] is not None:
1129 if not (0 <= options[b'zlib.level'] <= 9):
1129 if not (0 <= options[b'zlib.level'] <= 9):
1130 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1130 msg = _(b'invalid value for `storage.revlog.zlib.level` config: %d')
1131 raise error.Abort(msg % options[b'zlib.level'])
1131 raise error.Abort(msg % options[b'zlib.level'])
1132 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1132 options[b'zstd.level'] = ui.configint(b'storage', b'revlog.zstd.level')
1133 if options[b'zstd.level'] is not None:
1133 if options[b'zstd.level'] is not None:
1134 if not (0 <= options[b'zstd.level'] <= 22):
1134 if not (0 <= options[b'zstd.level'] <= 22):
1135 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1135 msg = _(b'invalid value for `storage.revlog.zstd.level` config: %d')
1136 raise error.Abort(msg % options[b'zstd.level'])
1136 raise error.Abort(msg % options[b'zstd.level'])
1137
1137
1138 if requirementsmod.NARROW_REQUIREMENT in requirements:
1138 if requirementsmod.NARROW_REQUIREMENT in requirements:
1139 options[b'enableellipsis'] = True
1139 options[b'enableellipsis'] = True
1140
1140
1141 if ui.configbool(b'experimental', b'rust.index'):
1141 if ui.configbool(b'experimental', b'rust.index'):
1142 options[b'rust.index'] = True
1142 options[b'rust.index'] = True
1143 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1143 if requirementsmod.NODEMAP_REQUIREMENT in requirements:
1144 slow_path = ui.config(
1144 slow_path = ui.config(
1145 b'storage', b'revlog.persistent-nodemap.slow-path'
1145 b'storage', b'revlog.persistent-nodemap.slow-path'
1146 )
1146 )
1147 if slow_path not in (b'allow', b'warn', b'abort'):
1147 if slow_path not in (b'allow', b'warn', b'abort'):
1148 default = ui.config_default(
1148 default = ui.config_default(
1149 b'storage', b'revlog.persistent-nodemap.slow-path'
1149 b'storage', b'revlog.persistent-nodemap.slow-path'
1150 )
1150 )
1151 msg = _(
1151 msg = _(
1152 b'unknown value for config '
1152 b'unknown value for config '
1153 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1153 b'"storage.revlog.persistent-nodemap.slow-path": "%s"\n'
1154 )
1154 )
1155 ui.warn(msg % slow_path)
1155 ui.warn(msg % slow_path)
1156 if not ui.quiet:
1156 if not ui.quiet:
1157 ui.warn(_(b'falling back to default value: %s\n') % default)
1157 ui.warn(_(b'falling back to default value: %s\n') % default)
1158 slow_path = default
1158 slow_path = default
1159
1159
1160 msg = _(
1160 msg = _(
1161 b"accessing `persistent-nodemap` repository without associated "
1161 b"accessing `persistent-nodemap` repository without associated "
1162 b"fast implementation."
1162 b"fast implementation."
1163 )
1163 )
1164 hint = _(
1164 hint = _(
1165 b"check `hg help config.format.use-persistent-nodemap` "
1165 b"check `hg help config.format.use-persistent-nodemap` "
1166 b"for details"
1166 b"for details"
1167 )
1167 )
1168 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1168 if not revlog.HAS_FAST_PERSISTENT_NODEMAP:
1169 if slow_path == b'warn':
1169 if slow_path == b'warn':
1170 msg = b"warning: " + msg + b'\n'
1170 msg = b"warning: " + msg + b'\n'
1171 ui.warn(msg)
1171 ui.warn(msg)
1172 if not ui.quiet:
1172 if not ui.quiet:
1173 hint = b'(' + hint + b')\n'
1173 hint = b'(' + hint + b')\n'
1174 ui.warn(hint)
1174 ui.warn(hint)
1175 if slow_path == b'abort':
1175 if slow_path == b'abort':
1176 raise error.Abort(msg, hint=hint)
1176 raise error.Abort(msg, hint=hint)
1177 options[b'persistent-nodemap'] = True
1177 options[b'persistent-nodemap'] = True
1178 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1178 if requirementsmod.DIRSTATE_V2_REQUIREMENT in requirements:
1179 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1179 slow_path = ui.config(b'storage', b'dirstate-v2.slow-path')
1180 if slow_path not in (b'allow', b'warn', b'abort'):
1180 if slow_path not in (b'allow', b'warn', b'abort'):
1181 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1181 default = ui.config_default(b'storage', b'dirstate-v2.slow-path')
1182 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1182 msg = _(b'unknown value for config "dirstate-v2.slow-path": "%s"\n')
1183 ui.warn(msg % slow_path)
1183 ui.warn(msg % slow_path)
1184 if not ui.quiet:
1184 if not ui.quiet:
1185 ui.warn(_(b'falling back to default value: %s\n') % default)
1185 ui.warn(_(b'falling back to default value: %s\n') % default)
1186 slow_path = default
1186 slow_path = default
1187
1187
1188 msg = _(
1188 msg = _(
1189 b"accessing `dirstate-v2` repository without associated "
1189 b"accessing `dirstate-v2` repository without associated "
1190 b"fast implementation."
1190 b"fast implementation."
1191 )
1191 )
1192 hint = _(
1192 hint = _(
1193 b"check `hg help config.format.exp-rc-dirstate-v2` " b"for details"
1193 b"check `hg help config.format.exp-rc-dirstate-v2` " b"for details"
1194 )
1194 )
1195 if not dirstate.HAS_FAST_DIRSTATE_V2:
1195 if not dirstate.HAS_FAST_DIRSTATE_V2:
1196 if slow_path == b'warn':
1196 if slow_path == b'warn':
1197 msg = b"warning: " + msg + b'\n'
1197 msg = b"warning: " + msg + b'\n'
1198 ui.warn(msg)
1198 ui.warn(msg)
1199 if not ui.quiet:
1199 if not ui.quiet:
1200 hint = b'(' + hint + b')\n'
1200 hint = b'(' + hint + b')\n'
1201 ui.warn(hint)
1201 ui.warn(hint)
1202 if slow_path == b'abort':
1202 if slow_path == b'abort':
1203 raise error.Abort(msg, hint=hint)
1203 raise error.Abort(msg, hint=hint)
1204 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1204 if ui.configbool(b'storage', b'revlog.persistent-nodemap.mmap'):
1205 options[b'persistent-nodemap.mmap'] = True
1205 options[b'persistent-nodemap.mmap'] = True
1206 if ui.configbool(b'devel', b'persistent-nodemap'):
1206 if ui.configbool(b'devel', b'persistent-nodemap'):
1207 options[b'devel-force-nodemap'] = True
1207 options[b'devel-force-nodemap'] = True
1208
1208
1209 return options
1209 return options
1210
1210
1211
1211
1212 def makemain(**kwargs):
1212 def makemain(**kwargs):
1213 """Produce a type conforming to ``ilocalrepositorymain``."""
1213 """Produce a type conforming to ``ilocalrepositorymain``."""
1214 return localrepository
1214 return localrepository
1215
1215
1216
1216
1217 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1217 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1218 class revlogfilestorage(object):
1218 class revlogfilestorage(object):
1219 """File storage when using revlogs."""
1219 """File storage when using revlogs."""
1220
1220
1221 def file(self, path):
1221 def file(self, path):
1222 if path.startswith(b'/'):
1222 if path.startswith(b'/'):
1223 path = path[1:]
1223 path = path[1:]
1224
1224
1225 return filelog.filelog(self.svfs, path)
1225 return filelog.filelog(self.svfs, path)
1226
1226
1227
1227
1228 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1228 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1229 class revlognarrowfilestorage(object):
1229 class revlognarrowfilestorage(object):
1230 """File storage when using revlogs and narrow files."""
1230 """File storage when using revlogs and narrow files."""
1231
1231
1232 def file(self, path):
1232 def file(self, path):
1233 if path.startswith(b'/'):
1233 if path.startswith(b'/'):
1234 path = path[1:]
1234 path = path[1:]
1235
1235
1236 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1236 return filelog.narrowfilelog(self.svfs, path, self._storenarrowmatch)
1237
1237
1238
1238
1239 def makefilestorage(requirements, features, **kwargs):
1239 def makefilestorage(requirements, features, **kwargs):
1240 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1240 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1241 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1241 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
1242 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1242 features.add(repository.REPO_FEATURE_STREAM_CLONE)
1243
1243
1244 if requirementsmod.NARROW_REQUIREMENT in requirements:
1244 if requirementsmod.NARROW_REQUIREMENT in requirements:
1245 return revlognarrowfilestorage
1245 return revlognarrowfilestorage
1246 else:
1246 else:
1247 return revlogfilestorage
1247 return revlogfilestorage
1248
1248
1249
1249
1250 # List of repository interfaces and factory functions for them. Each
1250 # List of repository interfaces and factory functions for them. Each
1251 # will be called in order during ``makelocalrepository()`` to iteratively
1251 # will be called in order during ``makelocalrepository()`` to iteratively
1252 # derive the final type for a local repository instance. We capture the
1252 # derive the final type for a local repository instance. We capture the
1253 # function as a lambda so we don't hold a reference and the module-level
1253 # function as a lambda so we don't hold a reference and the module-level
1254 # functions can be wrapped.
1254 # functions can be wrapped.
1255 REPO_INTERFACES = [
1255 REPO_INTERFACES = [
1256 (repository.ilocalrepositorymain, lambda: makemain),
1256 (repository.ilocalrepositorymain, lambda: makemain),
1257 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1257 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1258 ]
1258 ]
1259
1259
1260
1260
1261 @interfaceutil.implementer(repository.ilocalrepositorymain)
1261 @interfaceutil.implementer(repository.ilocalrepositorymain)
1262 class localrepository(object):
1262 class localrepository(object):
1263 """Main class for representing local repositories.
1263 """Main class for representing local repositories.
1264
1264
1265 All local repositories are instances of this class.
1265 All local repositories are instances of this class.
1266
1266
1267 Constructed on its own, instances of this class are not usable as
1267 Constructed on its own, instances of this class are not usable as
1268 repository objects. To obtain a usable repository object, call
1268 repository objects. To obtain a usable repository object, call
1269 ``hg.repository()``, ``localrepo.instance()``, or
1269 ``hg.repository()``, ``localrepo.instance()``, or
1270 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1270 ``localrepo.makelocalrepository()``. The latter is the lowest-level.
1271 ``instance()`` adds support for creating new repositories.
1271 ``instance()`` adds support for creating new repositories.
1272 ``hg.repository()`` adds more extension integration, including calling
1272 ``hg.repository()`` adds more extension integration, including calling
1273 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1273 ``reposetup()``. Generally speaking, ``hg.repository()`` should be
1274 used.
1274 used.
1275 """
1275 """
1276
1276
1277 _basesupported = {
1277 _basesupported = {
1278 requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT,
1278 requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT,
1279 requirementsmod.CHANGELOGV2_REQUIREMENT,
1279 requirementsmod.CHANGELOGV2_REQUIREMENT,
1280 requirementsmod.COPIESSDC_REQUIREMENT,
1280 requirementsmod.COPIESSDC_REQUIREMENT,
1281 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1281 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1282 requirementsmod.DOTENCODE_REQUIREMENT,
1282 requirementsmod.DOTENCODE_REQUIREMENT,
1283 requirementsmod.FNCACHE_REQUIREMENT,
1283 requirementsmod.FNCACHE_REQUIREMENT,
1284 requirementsmod.GENERALDELTA_REQUIREMENT,
1284 requirementsmod.GENERALDELTA_REQUIREMENT,
1285 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1285 requirementsmod.INTERNAL_PHASE_REQUIREMENT,
1286 requirementsmod.NODEMAP_REQUIREMENT,
1286 requirementsmod.NODEMAP_REQUIREMENT,
1287 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1287 requirementsmod.RELATIVE_SHARED_REQUIREMENT,
1288 requirementsmod.REVLOGV1_REQUIREMENT,
1288 requirementsmod.REVLOGV1_REQUIREMENT,
1289 requirementsmod.REVLOGV2_REQUIREMENT,
1289 requirementsmod.REVLOGV2_REQUIREMENT,
1290 requirementsmod.SHARED_REQUIREMENT,
1290 requirementsmod.SHARED_REQUIREMENT,
1291 requirementsmod.SHARESAFE_REQUIREMENT,
1291 requirementsmod.SHARESAFE_REQUIREMENT,
1292 requirementsmod.SPARSE_REQUIREMENT,
1292 requirementsmod.SPARSE_REQUIREMENT,
1293 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1293 requirementsmod.SPARSEREVLOG_REQUIREMENT,
1294 requirementsmod.STORE_REQUIREMENT,
1294 requirementsmod.STORE_REQUIREMENT,
1295 requirementsmod.TREEMANIFEST_REQUIREMENT,
1295 requirementsmod.TREEMANIFEST_REQUIREMENT,
1296 }
1296 }
1297
1297
1298 # list of prefix for file which can be written without 'wlock'
1298 # list of prefix for file which can be written without 'wlock'
1299 # Extensions should extend this list when needed
1299 # Extensions should extend this list when needed
1300 _wlockfreeprefix = {
1300 _wlockfreeprefix = {
1301 # We migh consider requiring 'wlock' for the next
1301 # We migh consider requiring 'wlock' for the next
1302 # two, but pretty much all the existing code assume
1302 # two, but pretty much all the existing code assume
1303 # wlock is not needed so we keep them excluded for
1303 # wlock is not needed so we keep them excluded for
1304 # now.
1304 # now.
1305 b'hgrc',
1305 b'hgrc',
1306 b'requires',
1306 b'requires',
1307 # XXX cache is a complicatged business someone
1307 # XXX cache is a complicatged business someone
1308 # should investigate this in depth at some point
1308 # should investigate this in depth at some point
1309 b'cache/',
1309 b'cache/',
1310 # XXX shouldn't be dirstate covered by the wlock?
1310 # XXX shouldn't be dirstate covered by the wlock?
1311 b'dirstate',
1311 b'dirstate',
1312 # XXX bisect was still a bit too messy at the time
1312 # XXX bisect was still a bit too messy at the time
1313 # this changeset was introduced. Someone should fix
1313 # this changeset was introduced. Someone should fix
1314 # the remainig bit and drop this line
1314 # the remainig bit and drop this line
1315 b'bisect.state',
1315 b'bisect.state',
1316 }
1316 }
1317
1317
1318 def __init__(
1318 def __init__(
1319 self,
1319 self,
1320 baseui,
1320 baseui,
1321 ui,
1321 ui,
1322 origroot,
1322 origroot,
1323 wdirvfs,
1323 wdirvfs,
1324 hgvfs,
1324 hgvfs,
1325 requirements,
1325 requirements,
1326 supportedrequirements,
1326 supportedrequirements,
1327 sharedpath,
1327 sharedpath,
1328 store,
1328 store,
1329 cachevfs,
1329 cachevfs,
1330 wcachevfs,
1330 wcachevfs,
1331 features,
1331 features,
1332 intents=None,
1332 intents=None,
1333 ):
1333 ):
1334 """Create a new local repository instance.
1334 """Create a new local repository instance.
1335
1335
1336 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1336 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
1337 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1337 or ``localrepo.makelocalrepository()`` for obtaining a new repository
1338 object.
1338 object.
1339
1339
1340 Arguments:
1340 Arguments:
1341
1341
1342 baseui
1342 baseui
1343 ``ui.ui`` instance that ``ui`` argument was based off of.
1343 ``ui.ui`` instance that ``ui`` argument was based off of.
1344
1344
1345 ui
1345 ui
1346 ``ui.ui`` instance for use by the repository.
1346 ``ui.ui`` instance for use by the repository.
1347
1347
1348 origroot
1348 origroot
1349 ``bytes`` path to working directory root of this repository.
1349 ``bytes`` path to working directory root of this repository.
1350
1350
1351 wdirvfs
1351 wdirvfs
1352 ``vfs.vfs`` rooted at the working directory.
1352 ``vfs.vfs`` rooted at the working directory.
1353
1353
1354 hgvfs
1354 hgvfs
1355 ``vfs.vfs`` rooted at .hg/
1355 ``vfs.vfs`` rooted at .hg/
1356
1356
1357 requirements
1357 requirements
1358 ``set`` of bytestrings representing repository opening requirements.
1358 ``set`` of bytestrings representing repository opening requirements.
1359
1359
1360 supportedrequirements
1360 supportedrequirements
1361 ``set`` of bytestrings representing repository requirements that we
1361 ``set`` of bytestrings representing repository requirements that we
1362 know how to open. May be a supetset of ``requirements``.
1362 know how to open. May be a supetset of ``requirements``.
1363
1363
1364 sharedpath
1364 sharedpath
1365 ``bytes`` Defining path to storage base directory. Points to a
1365 ``bytes`` Defining path to storage base directory. Points to a
1366 ``.hg/`` directory somewhere.
1366 ``.hg/`` directory somewhere.
1367
1367
1368 store
1368 store
1369 ``store.basicstore`` (or derived) instance providing access to
1369 ``store.basicstore`` (or derived) instance providing access to
1370 versioned storage.
1370 versioned storage.
1371
1371
1372 cachevfs
1372 cachevfs
1373 ``vfs.vfs`` used for cache files.
1373 ``vfs.vfs`` used for cache files.
1374
1374
1375 wcachevfs
1375 wcachevfs
1376 ``vfs.vfs`` used for cache files related to the working copy.
1376 ``vfs.vfs`` used for cache files related to the working copy.
1377
1377
1378 features
1378 features
1379 ``set`` of bytestrings defining features/capabilities of this
1379 ``set`` of bytestrings defining features/capabilities of this
1380 instance.
1380 instance.
1381
1381
1382 intents
1382 intents
1383 ``set`` of system strings indicating what this repo will be used
1383 ``set`` of system strings indicating what this repo will be used
1384 for.
1384 for.
1385 """
1385 """
1386 self.baseui = baseui
1386 self.baseui = baseui
1387 self.ui = ui
1387 self.ui = ui
1388 self.origroot = origroot
1388 self.origroot = origroot
1389 # vfs rooted at working directory.
1389 # vfs rooted at working directory.
1390 self.wvfs = wdirvfs
1390 self.wvfs = wdirvfs
1391 self.root = wdirvfs.base
1391 self.root = wdirvfs.base
1392 # vfs rooted at .hg/. Used to access most non-store paths.
1392 # vfs rooted at .hg/. Used to access most non-store paths.
1393 self.vfs = hgvfs
1393 self.vfs = hgvfs
1394 self.path = hgvfs.base
1394 self.path = hgvfs.base
1395 self.requirements = requirements
1395 self.requirements = requirements
1396 self.nodeconstants = sha1nodeconstants
1396 self.nodeconstants = sha1nodeconstants
1397 self.nullid = self.nodeconstants.nullid
1397 self.nullid = self.nodeconstants.nullid
1398 self.supported = supportedrequirements
1398 self.supported = supportedrequirements
1399 self.sharedpath = sharedpath
1399 self.sharedpath = sharedpath
1400 self.store = store
1400 self.store = store
1401 self.cachevfs = cachevfs
1401 self.cachevfs = cachevfs
1402 self.wcachevfs = wcachevfs
1402 self.wcachevfs = wcachevfs
1403 self.features = features
1403 self.features = features
1404
1404
1405 self.filtername = None
1405 self.filtername = None
1406
1406
1407 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1407 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1408 b'devel', b'check-locks'
1408 b'devel', b'check-locks'
1409 ):
1409 ):
1410 self.vfs.audit = self._getvfsward(self.vfs.audit)
1410 self.vfs.audit = self._getvfsward(self.vfs.audit)
1411 # A list of callback to shape the phase if no data were found.
1411 # A list of callback to shape the phase if no data were found.
1412 # Callback are in the form: func(repo, roots) --> processed root.
1412 # Callback are in the form: func(repo, roots) --> processed root.
1413 # This list it to be filled by extension during repo setup
1413 # This list it to be filled by extension during repo setup
1414 self._phasedefaults = []
1414 self._phasedefaults = []
1415
1415
1416 color.setup(self.ui)
1416 color.setup(self.ui)
1417
1417
1418 self.spath = self.store.path
1418 self.spath = self.store.path
1419 self.svfs = self.store.vfs
1419 self.svfs = self.store.vfs
1420 self.sjoin = self.store.join
1420 self.sjoin = self.store.join
1421 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1421 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
1422 b'devel', b'check-locks'
1422 b'devel', b'check-locks'
1423 ):
1423 ):
1424 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1424 if util.safehasattr(self.svfs, b'vfs'): # this is filtervfs
1425 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1425 self.svfs.vfs.audit = self._getsvfsward(self.svfs.vfs.audit)
1426 else: # standard vfs
1426 else: # standard vfs
1427 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1427 self.svfs.audit = self._getsvfsward(self.svfs.audit)
1428
1428
1429 self._dirstatevalidatewarned = False
1429 self._dirstatevalidatewarned = False
1430
1430
1431 self._branchcaches = branchmap.BranchMapCache()
1431 self._branchcaches = branchmap.BranchMapCache()
1432 self._revbranchcache = None
1432 self._revbranchcache = None
1433 self._filterpats = {}
1433 self._filterpats = {}
1434 self._datafilters = {}
1434 self._datafilters = {}
1435 self._transref = self._lockref = self._wlockref = None
1435 self._transref = self._lockref = self._wlockref = None
1436
1436
1437 # A cache for various files under .hg/ that tracks file changes,
1437 # A cache for various files under .hg/ that tracks file changes,
1438 # (used by the filecache decorator)
1438 # (used by the filecache decorator)
1439 #
1439 #
1440 # Maps a property name to its util.filecacheentry
1440 # Maps a property name to its util.filecacheentry
1441 self._filecache = {}
1441 self._filecache = {}
1442
1442
1443 # hold sets of revision to be filtered
1443 # hold sets of revision to be filtered
1444 # should be cleared when something might have changed the filter value:
1444 # should be cleared when something might have changed the filter value:
1445 # - new changesets,
1445 # - new changesets,
1446 # - phase change,
1446 # - phase change,
1447 # - new obsolescence marker,
1447 # - new obsolescence marker,
1448 # - working directory parent change,
1448 # - working directory parent change,
1449 # - bookmark changes
1449 # - bookmark changes
1450 self.filteredrevcache = {}
1450 self.filteredrevcache = {}
1451
1451
1452 # post-dirstate-status hooks
1452 # post-dirstate-status hooks
1453 self._postdsstatus = []
1453 self._postdsstatus = []
1454
1454
1455 # generic mapping between names and nodes
1455 # generic mapping between names and nodes
1456 self.names = namespaces.namespaces()
1456 self.names = namespaces.namespaces()
1457
1457
1458 # Key to signature value.
1458 # Key to signature value.
1459 self._sparsesignaturecache = {}
1459 self._sparsesignaturecache = {}
1460 # Signature to cached matcher instance.
1460 # Signature to cached matcher instance.
1461 self._sparsematchercache = {}
1461 self._sparsematchercache = {}
1462
1462
1463 self._extrafilterid = repoview.extrafilter(ui)
1463 self._extrafilterid = repoview.extrafilter(ui)
1464
1464
1465 self.filecopiesmode = None
1465 self.filecopiesmode = None
1466 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1466 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements:
1467 self.filecopiesmode = b'changeset-sidedata'
1467 self.filecopiesmode = b'changeset-sidedata'
1468
1468
1469 self._wanted_sidedata = set()
1469 self._wanted_sidedata = set()
1470 self._sidedata_computers = {}
1470 self._sidedata_computers = {}
1471 sidedatamod.set_sidedata_spec_for_repo(self)
1471 sidedatamod.set_sidedata_spec_for_repo(self)
1472
1472
1473 def _getvfsward(self, origfunc):
1473 def _getvfsward(self, origfunc):
1474 """build a ward for self.vfs"""
1474 """build a ward for self.vfs"""
1475 rref = weakref.ref(self)
1475 rref = weakref.ref(self)
1476
1476
1477 def checkvfs(path, mode=None):
1477 def checkvfs(path, mode=None):
1478 ret = origfunc(path, mode=mode)
1478 ret = origfunc(path, mode=mode)
1479 repo = rref()
1479 repo = rref()
1480 if (
1480 if (
1481 repo is None
1481 repo is None
1482 or not util.safehasattr(repo, b'_wlockref')
1482 or not util.safehasattr(repo, b'_wlockref')
1483 or not util.safehasattr(repo, b'_lockref')
1483 or not util.safehasattr(repo, b'_lockref')
1484 ):
1484 ):
1485 return
1485 return
1486 if mode in (None, b'r', b'rb'):
1486 if mode in (None, b'r', b'rb'):
1487 return
1487 return
1488 if path.startswith(repo.path):
1488 if path.startswith(repo.path):
1489 # truncate name relative to the repository (.hg)
1489 # truncate name relative to the repository (.hg)
1490 path = path[len(repo.path) + 1 :]
1490 path = path[len(repo.path) + 1 :]
1491 if path.startswith(b'cache/'):
1491 if path.startswith(b'cache/'):
1492 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1492 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
1493 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1493 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
1494 # path prefixes covered by 'lock'
1494 # path prefixes covered by 'lock'
1495 vfs_path_prefixes = (
1495 vfs_path_prefixes = (
1496 b'journal.',
1496 b'journal.',
1497 b'undo.',
1497 b'undo.',
1498 b'strip-backup/',
1498 b'strip-backup/',
1499 b'cache/',
1499 b'cache/',
1500 )
1500 )
1501 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1501 if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
1502 if repo._currentlock(repo._lockref) is None:
1502 if repo._currentlock(repo._lockref) is None:
1503 repo.ui.develwarn(
1503 repo.ui.develwarn(
1504 b'write with no lock: "%s"' % path,
1504 b'write with no lock: "%s"' % path,
1505 stacklevel=3,
1505 stacklevel=3,
1506 config=b'check-locks',
1506 config=b'check-locks',
1507 )
1507 )
1508 elif repo._currentlock(repo._wlockref) is None:
1508 elif repo._currentlock(repo._wlockref) is None:
1509 # rest of vfs files are covered by 'wlock'
1509 # rest of vfs files are covered by 'wlock'
1510 #
1510 #
1511 # exclude special files
1511 # exclude special files
1512 for prefix in self._wlockfreeprefix:
1512 for prefix in self._wlockfreeprefix:
1513 if path.startswith(prefix):
1513 if path.startswith(prefix):
1514 return
1514 return
1515 repo.ui.develwarn(
1515 repo.ui.develwarn(
1516 b'write with no wlock: "%s"' % path,
1516 b'write with no wlock: "%s"' % path,
1517 stacklevel=3,
1517 stacklevel=3,
1518 config=b'check-locks',
1518 config=b'check-locks',
1519 )
1519 )
1520 return ret
1520 return ret
1521
1521
1522 return checkvfs
1522 return checkvfs
1523
1523
1524 def _getsvfsward(self, origfunc):
1524 def _getsvfsward(self, origfunc):
1525 """build a ward for self.svfs"""
1525 """build a ward for self.svfs"""
1526 rref = weakref.ref(self)
1526 rref = weakref.ref(self)
1527
1527
1528 def checksvfs(path, mode=None):
1528 def checksvfs(path, mode=None):
1529 ret = origfunc(path, mode=mode)
1529 ret = origfunc(path, mode=mode)
1530 repo = rref()
1530 repo = rref()
1531 if repo is None or not util.safehasattr(repo, b'_lockref'):
1531 if repo is None or not util.safehasattr(repo, b'_lockref'):
1532 return
1532 return
1533 if mode in (None, b'r', b'rb'):
1533 if mode in (None, b'r', b'rb'):
1534 return
1534 return
1535 if path.startswith(repo.sharedpath):
1535 if path.startswith(repo.sharedpath):
1536 # truncate name relative to the repository (.hg)
1536 # truncate name relative to the repository (.hg)
1537 path = path[len(repo.sharedpath) + 1 :]
1537 path = path[len(repo.sharedpath) + 1 :]
1538 if repo._currentlock(repo._lockref) is None:
1538 if repo._currentlock(repo._lockref) is None:
1539 repo.ui.develwarn(
1539 repo.ui.develwarn(
1540 b'write with no lock: "%s"' % path, stacklevel=4
1540 b'write with no lock: "%s"' % path, stacklevel=4
1541 )
1541 )
1542 return ret
1542 return ret
1543
1543
1544 return checksvfs
1544 return checksvfs
1545
1545
1546 def close(self):
1546 def close(self):
1547 self._writecaches()
1547 self._writecaches()
1548
1548
1549 def _writecaches(self):
1549 def _writecaches(self):
1550 if self._revbranchcache:
1550 if self._revbranchcache:
1551 self._revbranchcache.write()
1551 self._revbranchcache.write()
1552
1552
1553 def _restrictcapabilities(self, caps):
1553 def _restrictcapabilities(self, caps):
1554 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1554 if self.ui.configbool(b'experimental', b'bundle2-advertise'):
1555 caps = set(caps)
1555 caps = set(caps)
1556 capsblob = bundle2.encodecaps(
1556 capsblob = bundle2.encodecaps(
1557 bundle2.getrepocaps(self, role=b'client')
1557 bundle2.getrepocaps(self, role=b'client')
1558 )
1558 )
1559 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1559 caps.add(b'bundle2=' + urlreq.quote(capsblob))
1560 if self.ui.configbool(b'experimental', b'narrow'):
1560 if self.ui.configbool(b'experimental', b'narrow'):
1561 caps.add(wireprototypes.NARROWCAP)
1561 caps.add(wireprototypes.NARROWCAP)
1562 return caps
1562 return caps
1563
1563
1564 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1564 # Don't cache auditor/nofsauditor, or you'll end up with reference cycle:
1565 # self -> auditor -> self._checknested -> self
1565 # self -> auditor -> self._checknested -> self
1566
1566
1567 @property
1567 @property
1568 def auditor(self):
1568 def auditor(self):
1569 # This is only used by context.workingctx.match in order to
1569 # This is only used by context.workingctx.match in order to
1570 # detect files in subrepos.
1570 # detect files in subrepos.
1571 return pathutil.pathauditor(self.root, callback=self._checknested)
1571 return pathutil.pathauditor(self.root, callback=self._checknested)
1572
1572
1573 @property
1573 @property
1574 def nofsauditor(self):
1574 def nofsauditor(self):
1575 # This is only used by context.basectx.match in order to detect
1575 # This is only used by context.basectx.match in order to detect
1576 # files in subrepos.
1576 # files in subrepos.
1577 return pathutil.pathauditor(
1577 return pathutil.pathauditor(
1578 self.root, callback=self._checknested, realfs=False, cached=True
1578 self.root, callback=self._checknested, realfs=False, cached=True
1579 )
1579 )
1580
1580
1581 def _checknested(self, path):
1581 def _checknested(self, path):
1582 """Determine if path is a legal nested repository."""
1582 """Determine if path is a legal nested repository."""
1583 if not path.startswith(self.root):
1583 if not path.startswith(self.root):
1584 return False
1584 return False
1585 subpath = path[len(self.root) + 1 :]
1585 subpath = path[len(self.root) + 1 :]
1586 normsubpath = util.pconvert(subpath)
1586 normsubpath = util.pconvert(subpath)
1587
1587
1588 # XXX: Checking against the current working copy is wrong in
1588 # XXX: Checking against the current working copy is wrong in
1589 # the sense that it can reject things like
1589 # the sense that it can reject things like
1590 #
1590 #
1591 # $ hg cat -r 10 sub/x.txt
1591 # $ hg cat -r 10 sub/x.txt
1592 #
1592 #
1593 # if sub/ is no longer a subrepository in the working copy
1593 # if sub/ is no longer a subrepository in the working copy
1594 # parent revision.
1594 # parent revision.
1595 #
1595 #
1596 # However, it can of course also allow things that would have
1596 # However, it can of course also allow things that would have
1597 # been rejected before, such as the above cat command if sub/
1597 # been rejected before, such as the above cat command if sub/
1598 # is a subrepository now, but was a normal directory before.
1598 # is a subrepository now, but was a normal directory before.
1599 # The old path auditor would have rejected by mistake since it
1599 # The old path auditor would have rejected by mistake since it
1600 # panics when it sees sub/.hg/.
1600 # panics when it sees sub/.hg/.
1601 #
1601 #
1602 # All in all, checking against the working copy seems sensible
1602 # All in all, checking against the working copy seems sensible
1603 # since we want to prevent access to nested repositories on
1603 # since we want to prevent access to nested repositories on
1604 # the filesystem *now*.
1604 # the filesystem *now*.
1605 ctx = self[None]
1605 ctx = self[None]
1606 parts = util.splitpath(subpath)
1606 parts = util.splitpath(subpath)
1607 while parts:
1607 while parts:
1608 prefix = b'/'.join(parts)
1608 prefix = b'/'.join(parts)
1609 if prefix in ctx.substate:
1609 if prefix in ctx.substate:
1610 if prefix == normsubpath:
1610 if prefix == normsubpath:
1611 return True
1611 return True
1612 else:
1612 else:
1613 sub = ctx.sub(prefix)
1613 sub = ctx.sub(prefix)
1614 return sub.checknested(subpath[len(prefix) + 1 :])
1614 return sub.checknested(subpath[len(prefix) + 1 :])
1615 else:
1615 else:
1616 parts.pop()
1616 parts.pop()
1617 return False
1617 return False
1618
1618
1619 def peer(self):
1619 def peer(self):
1620 return localpeer(self) # not cached to avoid reference cycle
1620 return localpeer(self) # not cached to avoid reference cycle
1621
1621
1622 def unfiltered(self):
1622 def unfiltered(self):
1623 """Return unfiltered version of the repository
1623 """Return unfiltered version of the repository
1624
1624
1625 Intended to be overwritten by filtered repo."""
1625 Intended to be overwritten by filtered repo."""
1626 return self
1626 return self
1627
1627
1628 def filtered(self, name, visibilityexceptions=None):
1628 def filtered(self, name, visibilityexceptions=None):
1629 """Return a filtered version of a repository
1629 """Return a filtered version of a repository
1630
1630
1631 The `name` parameter is the identifier of the requested view. This
1631 The `name` parameter is the identifier of the requested view. This
1632 will return a repoview object set "exactly" to the specified view.
1632 will return a repoview object set "exactly" to the specified view.
1633
1633
1634 This function does not apply recursive filtering to a repository. For
1634 This function does not apply recursive filtering to a repository. For
1635 example calling `repo.filtered("served")` will return a repoview using
1635 example calling `repo.filtered("served")` will return a repoview using
1636 the "served" view, regardless of the initial view used by `repo`.
1636 the "served" view, regardless of the initial view used by `repo`.
1637
1637
1638 In other word, there is always only one level of `repoview` "filtering".
1638 In other word, there is always only one level of `repoview` "filtering".
1639 """
1639 """
1640 if self._extrafilterid is not None and b'%' not in name:
1640 if self._extrafilterid is not None and b'%' not in name:
1641 name = name + b'%' + self._extrafilterid
1641 name = name + b'%' + self._extrafilterid
1642
1642
1643 cls = repoview.newtype(self.unfiltered().__class__)
1643 cls = repoview.newtype(self.unfiltered().__class__)
1644 return cls(self, name, visibilityexceptions)
1644 return cls(self, name, visibilityexceptions)
1645
1645
1646 @mixedrepostorecache(
1646 @mixedrepostorecache(
1647 (b'bookmarks', b'plain'),
1647 (b'bookmarks', b'plain'),
1648 (b'bookmarks.current', b'plain'),
1648 (b'bookmarks.current', b'plain'),
1649 (b'bookmarks', b''),
1649 (b'bookmarks', b''),
1650 (b'00changelog.i', b''),
1650 (b'00changelog.i', b''),
1651 )
1651 )
1652 def _bookmarks(self):
1652 def _bookmarks(self):
1653 # Since the multiple files involved in the transaction cannot be
1653 # Since the multiple files involved in the transaction cannot be
1654 # written atomically (with current repository format), there is a race
1654 # written atomically (with current repository format), there is a race
1655 # condition here.
1655 # condition here.
1656 #
1656 #
1657 # 1) changelog content A is read
1657 # 1) changelog content A is read
1658 # 2) outside transaction update changelog to content B
1658 # 2) outside transaction update changelog to content B
1659 # 3) outside transaction update bookmark file referring to content B
1659 # 3) outside transaction update bookmark file referring to content B
1660 # 4) bookmarks file content is read and filtered against changelog-A
1660 # 4) bookmarks file content is read and filtered against changelog-A
1661 #
1661 #
1662 # When this happens, bookmarks against nodes missing from A are dropped.
1662 # When this happens, bookmarks against nodes missing from A are dropped.
1663 #
1663 #
1664 # Having this happening during read is not great, but it become worse
1664 # Having this happening during read is not great, but it become worse
1665 # when this happen during write because the bookmarks to the "unknown"
1665 # when this happen during write because the bookmarks to the "unknown"
1666 # nodes will be dropped for good. However, writes happen within locks.
1666 # nodes will be dropped for good. However, writes happen within locks.
1667 # This locking makes it possible to have a race free consistent read.
1667 # This locking makes it possible to have a race free consistent read.
1668 # For this purpose data read from disc before locking are
1668 # For this purpose data read from disc before locking are
1669 # "invalidated" right after the locks are taken. This invalidations are
1669 # "invalidated" right after the locks are taken. This invalidations are
1670 # "light", the `filecache` mechanism keep the data in memory and will
1670 # "light", the `filecache` mechanism keep the data in memory and will
1671 # reuse them if the underlying files did not changed. Not parsing the
1671 # reuse them if the underlying files did not changed. Not parsing the
1672 # same data multiple times helps performances.
1672 # same data multiple times helps performances.
1673 #
1673 #
1674 # Unfortunately in the case describe above, the files tracked by the
1674 # Unfortunately in the case describe above, the files tracked by the
1675 # bookmarks file cache might not have changed, but the in-memory
1675 # bookmarks file cache might not have changed, but the in-memory
1676 # content is still "wrong" because we used an older changelog content
1676 # content is still "wrong" because we used an older changelog content
1677 # to process the on-disk data. So after locking, the changelog would be
1677 # to process the on-disk data. So after locking, the changelog would be
1678 # refreshed but `_bookmarks` would be preserved.
1678 # refreshed but `_bookmarks` would be preserved.
1679 # Adding `00changelog.i` to the list of tracked file is not
1679 # Adding `00changelog.i` to the list of tracked file is not
1680 # enough, because at the time we build the content for `_bookmarks` in
1680 # enough, because at the time we build the content for `_bookmarks` in
1681 # (4), the changelog file has already diverged from the content used
1681 # (4), the changelog file has already diverged from the content used
1682 # for loading `changelog` in (1)
1682 # for loading `changelog` in (1)
1683 #
1683 #
1684 # To prevent the issue, we force the changelog to be explicitly
1684 # To prevent the issue, we force the changelog to be explicitly
1685 # reloaded while computing `_bookmarks`. The data race can still happen
1685 # reloaded while computing `_bookmarks`. The data race can still happen
1686 # without the lock (with a narrower window), but it would no longer go
1686 # without the lock (with a narrower window), but it would no longer go
1687 # undetected during the lock time refresh.
1687 # undetected during the lock time refresh.
1688 #
1688 #
1689 # The new schedule is as follow
1689 # The new schedule is as follow
1690 #
1690 #
1691 # 1) filecache logic detect that `_bookmarks` needs to be computed
1691 # 1) filecache logic detect that `_bookmarks` needs to be computed
1692 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1692 # 2) cachestat for `bookmarks` and `changelog` are captured (for book)
1693 # 3) We force `changelog` filecache to be tested
1693 # 3) We force `changelog` filecache to be tested
1694 # 4) cachestat for `changelog` are captured (for changelog)
1694 # 4) cachestat for `changelog` are captured (for changelog)
1695 # 5) `_bookmarks` is computed and cached
1695 # 5) `_bookmarks` is computed and cached
1696 #
1696 #
1697 # The step in (3) ensure we have a changelog at least as recent as the
1697 # The step in (3) ensure we have a changelog at least as recent as the
1698 # cache stat computed in (1). As a result at locking time:
1698 # cache stat computed in (1). As a result at locking time:
1699 # * if the changelog did not changed since (1) -> we can reuse the data
1699 # * if the changelog did not changed since (1) -> we can reuse the data
1700 # * otherwise -> the bookmarks get refreshed.
1700 # * otherwise -> the bookmarks get refreshed.
1701 self._refreshchangelog()
1701 self._refreshchangelog()
1702 return bookmarks.bmstore(self)
1702 return bookmarks.bmstore(self)
1703
1703
1704 def _refreshchangelog(self):
1704 def _refreshchangelog(self):
1705 """make sure the in memory changelog match the on-disk one"""
1705 """make sure the in memory changelog match the on-disk one"""
1706 if 'changelog' in vars(self) and self.currenttransaction() is None:
1706 if 'changelog' in vars(self) and self.currenttransaction() is None:
1707 del self.changelog
1707 del self.changelog
1708
1708
1709 @property
1709 @property
1710 def _activebookmark(self):
1710 def _activebookmark(self):
1711 return self._bookmarks.active
1711 return self._bookmarks.active
1712
1712
1713 # _phasesets depend on changelog. what we need is to call
1713 # _phasesets depend on changelog. what we need is to call
1714 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1714 # _phasecache.invalidate() if '00changelog.i' was changed, but it
1715 # can't be easily expressed in filecache mechanism.
1715 # can't be easily expressed in filecache mechanism.
1716 @storecache(b'phaseroots', b'00changelog.i')
1716 @storecache(b'phaseroots', b'00changelog.i')
1717 def _phasecache(self):
1717 def _phasecache(self):
1718 return phases.phasecache(self, self._phasedefaults)
1718 return phases.phasecache(self, self._phasedefaults)
1719
1719
1720 @storecache(b'obsstore')
1720 @storecache(b'obsstore')
1721 def obsstore(self):
1721 def obsstore(self):
1722 return obsolete.makestore(self.ui, self)
1722 return obsolete.makestore(self.ui, self)
1723
1723
1724 @changelogcache()
1724 @changelogcache()
1725 def changelog(repo):
1725 def changelog(repo):
1726 # load dirstate before changelog to avoid race see issue6303
1726 # load dirstate before changelog to avoid race see issue6303
1727 repo.dirstate.prefetch_parents()
1727 repo.dirstate.prefetch_parents()
1728 return repo.store.changelog(
1728 return repo.store.changelog(
1729 txnutil.mayhavepending(repo.root),
1729 txnutil.mayhavepending(repo.root),
1730 concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
1730 concurrencychecker=revlogchecker.get_checker(repo.ui, b'changelog'),
1731 )
1731 )
1732
1732
1733 @manifestlogcache()
1733 @manifestlogcache()
1734 def manifestlog(self):
1734 def manifestlog(self):
1735 return self.store.manifestlog(self, self._storenarrowmatch)
1735 return self.store.manifestlog(self, self._storenarrowmatch)
1736
1736
1737 @repofilecache(b'dirstate')
1737 @repofilecache(b'dirstate')
1738 def dirstate(self):
1738 def dirstate(self):
1739 return self._makedirstate()
1739 return self._makedirstate()
1740
1740
1741 def _makedirstate(self):
1741 def _makedirstate(self):
1742 """Extension point for wrapping the dirstate per-repo."""
1742 """Extension point for wrapping the dirstate per-repo."""
1743 sparsematchfn = lambda: sparse.matcher(self)
1743 sparsematchfn = lambda: sparse.matcher(self)
1744 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1744 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
1745 use_dirstate_v2 = v2_req in self.requirements
1745 use_dirstate_v2 = v2_req in self.requirements
1746
1746
1747 return dirstate.dirstate(
1747 return dirstate.dirstate(
1748 self.vfs,
1748 self.vfs,
1749 self.ui,
1749 self.ui,
1750 self.root,
1750 self.root,
1751 self._dirstatevalidate,
1751 self._dirstatevalidate,
1752 sparsematchfn,
1752 sparsematchfn,
1753 self.nodeconstants,
1753 self.nodeconstants,
1754 use_dirstate_v2,
1754 use_dirstate_v2,
1755 )
1755 )
1756
1756
1757 def _dirstatevalidate(self, node):
1757 def _dirstatevalidate(self, node):
1758 try:
1758 try:
1759 self.changelog.rev(node)
1759 self.changelog.rev(node)
1760 return node
1760 return node
1761 except error.LookupError:
1761 except error.LookupError:
1762 if not self._dirstatevalidatewarned:
1762 if not self._dirstatevalidatewarned:
1763 self._dirstatevalidatewarned = True
1763 self._dirstatevalidatewarned = True
1764 self.ui.warn(
1764 self.ui.warn(
1765 _(b"warning: ignoring unknown working parent %s!\n")
1765 _(b"warning: ignoring unknown working parent %s!\n")
1766 % short(node)
1766 % short(node)
1767 )
1767 )
1768 return self.nullid
1768 return self.nullid
1769
1769
1770 @storecache(narrowspec.FILENAME)
1770 @storecache(narrowspec.FILENAME)
1771 def narrowpats(self):
1771 def narrowpats(self):
1772 """matcher patterns for this repository's narrowspec
1772 """matcher patterns for this repository's narrowspec
1773
1773
1774 A tuple of (includes, excludes).
1774 A tuple of (includes, excludes).
1775 """
1775 """
1776 return narrowspec.load(self)
1776 return narrowspec.load(self)
1777
1777
1778 @storecache(narrowspec.FILENAME)
1778 @storecache(narrowspec.FILENAME)
1779 def _storenarrowmatch(self):
1779 def _storenarrowmatch(self):
1780 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1780 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1781 return matchmod.always()
1781 return matchmod.always()
1782 include, exclude = self.narrowpats
1782 include, exclude = self.narrowpats
1783 return narrowspec.match(self.root, include=include, exclude=exclude)
1783 return narrowspec.match(self.root, include=include, exclude=exclude)
1784
1784
1785 @storecache(narrowspec.FILENAME)
1785 @storecache(narrowspec.FILENAME)
1786 def _narrowmatch(self):
1786 def _narrowmatch(self):
1787 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1787 if requirementsmod.NARROW_REQUIREMENT not in self.requirements:
1788 return matchmod.always()
1788 return matchmod.always()
1789 narrowspec.checkworkingcopynarrowspec(self)
1789 narrowspec.checkworkingcopynarrowspec(self)
1790 include, exclude = self.narrowpats
1790 include, exclude = self.narrowpats
1791 return narrowspec.match(self.root, include=include, exclude=exclude)
1791 return narrowspec.match(self.root, include=include, exclude=exclude)
1792
1792
1793 def narrowmatch(self, match=None, includeexact=False):
1793 def narrowmatch(self, match=None, includeexact=False):
1794 """matcher corresponding the the repo's narrowspec
1794 """matcher corresponding the the repo's narrowspec
1795
1795
1796 If `match` is given, then that will be intersected with the narrow
1796 If `match` is given, then that will be intersected with the narrow
1797 matcher.
1797 matcher.
1798
1798
1799 If `includeexact` is True, then any exact matches from `match` will
1799 If `includeexact` is True, then any exact matches from `match` will
1800 be included even if they're outside the narrowspec.
1800 be included even if they're outside the narrowspec.
1801 """
1801 """
1802 if match:
1802 if match:
1803 if includeexact and not self._narrowmatch.always():
1803 if includeexact and not self._narrowmatch.always():
1804 # do not exclude explicitly-specified paths so that they can
1804 # do not exclude explicitly-specified paths so that they can
1805 # be warned later on
1805 # be warned later on
1806 em = matchmod.exact(match.files())
1806 em = matchmod.exact(match.files())
1807 nm = matchmod.unionmatcher([self._narrowmatch, em])
1807 nm = matchmod.unionmatcher([self._narrowmatch, em])
1808 return matchmod.intersectmatchers(match, nm)
1808 return matchmod.intersectmatchers(match, nm)
1809 return matchmod.intersectmatchers(match, self._narrowmatch)
1809 return matchmod.intersectmatchers(match, self._narrowmatch)
1810 return self._narrowmatch
1810 return self._narrowmatch
1811
1811
1812 def setnarrowpats(self, newincludes, newexcludes):
1812 def setnarrowpats(self, newincludes, newexcludes):
1813 narrowspec.save(self, newincludes, newexcludes)
1813 narrowspec.save(self, newincludes, newexcludes)
1814 self.invalidate(clearfilecache=True)
1814 self.invalidate(clearfilecache=True)
1815
1815
1816 @unfilteredpropertycache
1816 @unfilteredpropertycache
1817 def _quick_access_changeid_null(self):
1817 def _quick_access_changeid_null(self):
1818 return {
1818 return {
1819 b'null': (nullrev, self.nodeconstants.nullid),
1819 b'null': (nullrev, self.nodeconstants.nullid),
1820 nullrev: (nullrev, self.nodeconstants.nullid),
1820 nullrev: (nullrev, self.nodeconstants.nullid),
1821 self.nullid: (nullrev, self.nullid),
1821 self.nullid: (nullrev, self.nullid),
1822 }
1822 }
1823
1823
1824 @unfilteredpropertycache
1824 @unfilteredpropertycache
1825 def _quick_access_changeid_wc(self):
1825 def _quick_access_changeid_wc(self):
1826 # also fast path access to the working copy parents
1826 # also fast path access to the working copy parents
1827 # however, only do it for filter that ensure wc is visible.
1827 # however, only do it for filter that ensure wc is visible.
1828 quick = self._quick_access_changeid_null.copy()
1828 quick = self._quick_access_changeid_null.copy()
1829 cl = self.unfiltered().changelog
1829 cl = self.unfiltered().changelog
1830 for node in self.dirstate.parents():
1830 for node in self.dirstate.parents():
1831 if node == self.nullid:
1831 if node == self.nullid:
1832 continue
1832 continue
1833 rev = cl.index.get_rev(node)
1833 rev = cl.index.get_rev(node)
1834 if rev is None:
1834 if rev is None:
1835 # unknown working copy parent case:
1835 # unknown working copy parent case:
1836 #
1836 #
1837 # skip the fast path and let higher code deal with it
1837 # skip the fast path and let higher code deal with it
1838 continue
1838 continue
1839 pair = (rev, node)
1839 pair = (rev, node)
1840 quick[rev] = pair
1840 quick[rev] = pair
1841 quick[node] = pair
1841 quick[node] = pair
1842 # also add the parents of the parents
1842 # also add the parents of the parents
1843 for r in cl.parentrevs(rev):
1843 for r in cl.parentrevs(rev):
1844 if r == nullrev:
1844 if r == nullrev:
1845 continue
1845 continue
1846 n = cl.node(r)
1846 n = cl.node(r)
1847 pair = (r, n)
1847 pair = (r, n)
1848 quick[r] = pair
1848 quick[r] = pair
1849 quick[n] = pair
1849 quick[n] = pair
1850 p1node = self.dirstate.p1()
1850 p1node = self.dirstate.p1()
1851 if p1node != self.nullid:
1851 if p1node != self.nullid:
1852 quick[b'.'] = quick[p1node]
1852 quick[b'.'] = quick[p1node]
1853 return quick
1853 return quick
1854
1854
1855 @unfilteredmethod
1855 @unfilteredmethod
1856 def _quick_access_changeid_invalidate(self):
1856 def _quick_access_changeid_invalidate(self):
1857 if '_quick_access_changeid_wc' in vars(self):
1857 if '_quick_access_changeid_wc' in vars(self):
1858 del self.__dict__['_quick_access_changeid_wc']
1858 del self.__dict__['_quick_access_changeid_wc']
1859
1859
1860 @property
1860 @property
1861 def _quick_access_changeid(self):
1861 def _quick_access_changeid(self):
1862 """an helper dictionnary for __getitem__ calls
1862 """an helper dictionnary for __getitem__ calls
1863
1863
1864 This contains a list of symbol we can recognise right away without
1864 This contains a list of symbol we can recognise right away without
1865 further processing.
1865 further processing.
1866 """
1866 """
1867 if self.filtername in repoview.filter_has_wc:
1867 if self.filtername in repoview.filter_has_wc:
1868 return self._quick_access_changeid_wc
1868 return self._quick_access_changeid_wc
1869 return self._quick_access_changeid_null
1869 return self._quick_access_changeid_null
1870
1870
1871 def __getitem__(self, changeid):
1871 def __getitem__(self, changeid):
1872 # dealing with special cases
1872 # dealing with special cases
1873 if changeid is None:
1873 if changeid is None:
1874 return context.workingctx(self)
1874 return context.workingctx(self)
1875 if isinstance(changeid, context.basectx):
1875 if isinstance(changeid, context.basectx):
1876 return changeid
1876 return changeid
1877
1877
1878 # dealing with multiple revisions
1878 # dealing with multiple revisions
1879 if isinstance(changeid, slice):
1879 if isinstance(changeid, slice):
1880 # wdirrev isn't contiguous so the slice shouldn't include it
1880 # wdirrev isn't contiguous so the slice shouldn't include it
1881 return [
1881 return [
1882 self[i]
1882 self[i]
1883 for i in pycompat.xrange(*changeid.indices(len(self)))
1883 for i in pycompat.xrange(*changeid.indices(len(self)))
1884 if i not in self.changelog.filteredrevs
1884 if i not in self.changelog.filteredrevs
1885 ]
1885 ]
1886
1886
1887 # dealing with some special values
1887 # dealing with some special values
1888 quick_access = self._quick_access_changeid.get(changeid)
1888 quick_access = self._quick_access_changeid.get(changeid)
1889 if quick_access is not None:
1889 if quick_access is not None:
1890 rev, node = quick_access
1890 rev, node = quick_access
1891 return context.changectx(self, rev, node, maybe_filtered=False)
1891 return context.changectx(self, rev, node, maybe_filtered=False)
1892 if changeid == b'tip':
1892 if changeid == b'tip':
1893 node = self.changelog.tip()
1893 node = self.changelog.tip()
1894 rev = self.changelog.rev(node)
1894 rev = self.changelog.rev(node)
1895 return context.changectx(self, rev, node)
1895 return context.changectx(self, rev, node)
1896
1896
1897 # dealing with arbitrary values
1897 # dealing with arbitrary values
1898 try:
1898 try:
1899 if isinstance(changeid, int):
1899 if isinstance(changeid, int):
1900 node = self.changelog.node(changeid)
1900 node = self.changelog.node(changeid)
1901 rev = changeid
1901 rev = changeid
1902 elif changeid == b'.':
1902 elif changeid == b'.':
1903 # this is a hack to delay/avoid loading obsmarkers
1903 # this is a hack to delay/avoid loading obsmarkers
1904 # when we know that '.' won't be hidden
1904 # when we know that '.' won't be hidden
1905 node = self.dirstate.p1()
1905 node = self.dirstate.p1()
1906 rev = self.unfiltered().changelog.rev(node)
1906 rev = self.unfiltered().changelog.rev(node)
1907 elif len(changeid) == self.nodeconstants.nodelen:
1907 elif len(changeid) == self.nodeconstants.nodelen:
1908 try:
1908 try:
1909 node = changeid
1909 node = changeid
1910 rev = self.changelog.rev(changeid)
1910 rev = self.changelog.rev(changeid)
1911 except error.FilteredLookupError:
1911 except error.FilteredLookupError:
1912 changeid = hex(changeid) # for the error message
1912 changeid = hex(changeid) # for the error message
1913 raise
1913 raise
1914 except LookupError:
1914 except LookupError:
1915 # check if it might have come from damaged dirstate
1915 # check if it might have come from damaged dirstate
1916 #
1916 #
1917 # XXX we could avoid the unfiltered if we had a recognizable
1917 # XXX we could avoid the unfiltered if we had a recognizable
1918 # exception for filtered changeset access
1918 # exception for filtered changeset access
1919 if (
1919 if (
1920 self.local()
1920 self.local()
1921 and changeid in self.unfiltered().dirstate.parents()
1921 and changeid in self.unfiltered().dirstate.parents()
1922 ):
1922 ):
1923 msg = _(b"working directory has unknown parent '%s'!")
1923 msg = _(b"working directory has unknown parent '%s'!")
1924 raise error.Abort(msg % short(changeid))
1924 raise error.Abort(msg % short(changeid))
1925 changeid = hex(changeid) # for the error message
1925 changeid = hex(changeid) # for the error message
1926 raise
1926 raise
1927
1927
1928 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1928 elif len(changeid) == 2 * self.nodeconstants.nodelen:
1929 node = bin(changeid)
1929 node = bin(changeid)
1930 rev = self.changelog.rev(node)
1930 rev = self.changelog.rev(node)
1931 else:
1931 else:
1932 raise error.ProgrammingError(
1932 raise error.ProgrammingError(
1933 b"unsupported changeid '%s' of type %s"
1933 b"unsupported changeid '%s' of type %s"
1934 % (changeid, pycompat.bytestr(type(changeid)))
1934 % (changeid, pycompat.bytestr(type(changeid)))
1935 )
1935 )
1936
1936
1937 return context.changectx(self, rev, node)
1937 return context.changectx(self, rev, node)
1938
1938
1939 except (error.FilteredIndexError, error.FilteredLookupError):
1939 except (error.FilteredIndexError, error.FilteredLookupError):
1940 raise error.FilteredRepoLookupError(
1940 raise error.FilteredRepoLookupError(
1941 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1941 _(b"filtered revision '%s'") % pycompat.bytestr(changeid)
1942 )
1942 )
1943 except (IndexError, LookupError):
1943 except (IndexError, LookupError):
1944 raise error.RepoLookupError(
1944 raise error.RepoLookupError(
1945 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1945 _(b"unknown revision '%s'") % pycompat.bytestr(changeid)
1946 )
1946 )
1947 except error.WdirUnsupported:
1947 except error.WdirUnsupported:
1948 return context.workingctx(self)
1948 return context.workingctx(self)
1949
1949
1950 def __contains__(self, changeid):
1950 def __contains__(self, changeid):
1951 """True if the given changeid exists"""
1951 """True if the given changeid exists"""
1952 try:
1952 try:
1953 self[changeid]
1953 self[changeid]
1954 return True
1954 return True
1955 except error.RepoLookupError:
1955 except error.RepoLookupError:
1956 return False
1956 return False
1957
1957
1958 def __nonzero__(self):
1958 def __nonzero__(self):
1959 return True
1959 return True
1960
1960
1961 __bool__ = __nonzero__
1961 __bool__ = __nonzero__
1962
1962
1963 def __len__(self):
1963 def __len__(self):
1964 # no need to pay the cost of repoview.changelog
1964 # no need to pay the cost of repoview.changelog
1965 unfi = self.unfiltered()
1965 unfi = self.unfiltered()
1966 return len(unfi.changelog)
1966 return len(unfi.changelog)
1967
1967
1968 def __iter__(self):
1968 def __iter__(self):
1969 return iter(self.changelog)
1969 return iter(self.changelog)
1970
1970
1971 def revs(self, expr, *args):
1971 def revs(self, expr, *args):
1972 """Find revisions matching a revset.
1972 """Find revisions matching a revset.
1973
1973
1974 The revset is specified as a string ``expr`` that may contain
1974 The revset is specified as a string ``expr`` that may contain
1975 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1975 %-formatting to escape certain types. See ``revsetlang.formatspec``.
1976
1976
1977 Revset aliases from the configuration are not expanded. To expand
1977 Revset aliases from the configuration are not expanded. To expand
1978 user aliases, consider calling ``scmutil.revrange()`` or
1978 user aliases, consider calling ``scmutil.revrange()`` or
1979 ``repo.anyrevs([expr], user=True)``.
1979 ``repo.anyrevs([expr], user=True)``.
1980
1980
1981 Returns a smartset.abstractsmartset, which is a list-like interface
1981 Returns a smartset.abstractsmartset, which is a list-like interface
1982 that contains integer revisions.
1982 that contains integer revisions.
1983 """
1983 """
1984 tree = revsetlang.spectree(expr, *args)
1984 tree = revsetlang.spectree(expr, *args)
1985 return revset.makematcher(tree)(self)
1985 return revset.makematcher(tree)(self)
1986
1986
1987 def set(self, expr, *args):
1987 def set(self, expr, *args):
1988 """Find revisions matching a revset and emit changectx instances.
1988 """Find revisions matching a revset and emit changectx instances.
1989
1989
1990 This is a convenience wrapper around ``revs()`` that iterates the
1990 This is a convenience wrapper around ``revs()`` that iterates the
1991 result and is a generator of changectx instances.
1991 result and is a generator of changectx instances.
1992
1992
1993 Revset aliases from the configuration are not expanded. To expand
1993 Revset aliases from the configuration are not expanded. To expand
1994 user aliases, consider calling ``scmutil.revrange()``.
1994 user aliases, consider calling ``scmutil.revrange()``.
1995 """
1995 """
1996 for r in self.revs(expr, *args):
1996 for r in self.revs(expr, *args):
1997 yield self[r]
1997 yield self[r]
1998
1998
1999 def anyrevs(self, specs, user=False, localalias=None):
1999 def anyrevs(self, specs, user=False, localalias=None):
2000 """Find revisions matching one of the given revsets.
2000 """Find revisions matching one of the given revsets.
2001
2001
2002 Revset aliases from the configuration are not expanded by default. To
2002 Revset aliases from the configuration are not expanded by default. To
2003 expand user aliases, specify ``user=True``. To provide some local
2003 expand user aliases, specify ``user=True``. To provide some local
2004 definitions overriding user aliases, set ``localalias`` to
2004 definitions overriding user aliases, set ``localalias`` to
2005 ``{name: definitionstring}``.
2005 ``{name: definitionstring}``.
2006 """
2006 """
2007 if specs == [b'null']:
2007 if specs == [b'null']:
2008 return revset.baseset([nullrev])
2008 return revset.baseset([nullrev])
2009 if specs == [b'.']:
2009 if specs == [b'.']:
2010 quick_data = self._quick_access_changeid.get(b'.')
2010 quick_data = self._quick_access_changeid.get(b'.')
2011 if quick_data is not None:
2011 if quick_data is not None:
2012 return revset.baseset([quick_data[0]])
2012 return revset.baseset([quick_data[0]])
2013 if user:
2013 if user:
2014 m = revset.matchany(
2014 m = revset.matchany(
2015 self.ui,
2015 self.ui,
2016 specs,
2016 specs,
2017 lookup=revset.lookupfn(self),
2017 lookup=revset.lookupfn(self),
2018 localalias=localalias,
2018 localalias=localalias,
2019 )
2019 )
2020 else:
2020 else:
2021 m = revset.matchany(None, specs, localalias=localalias)
2021 m = revset.matchany(None, specs, localalias=localalias)
2022 return m(self)
2022 return m(self)
2023
2023
2024 def url(self):
2024 def url(self):
2025 return b'file:' + self.root
2025 return b'file:' + self.root
2026
2026
2027 def hook(self, name, throw=False, **args):
2027 def hook(self, name, throw=False, **args):
2028 """Call a hook, passing this repo instance.
2028 """Call a hook, passing this repo instance.
2029
2029
2030 This a convenience method to aid invoking hooks. Extensions likely
2030 This a convenience method to aid invoking hooks. Extensions likely
2031 won't call this unless they have registered a custom hook or are
2031 won't call this unless they have registered a custom hook or are
2032 replacing code that is expected to call a hook.
2032 replacing code that is expected to call a hook.
2033 """
2033 """
2034 return hook.hook(self.ui, self, name, throw, **args)
2034 return hook.hook(self.ui, self, name, throw, **args)
2035
2035
2036 @filteredpropertycache
2036 @filteredpropertycache
2037 def _tagscache(self):
2037 def _tagscache(self):
2038 """Returns a tagscache object that contains various tags related
2038 """Returns a tagscache object that contains various tags related
2039 caches."""
2039 caches."""
2040
2040
2041 # This simplifies its cache management by having one decorated
2041 # This simplifies its cache management by having one decorated
2042 # function (this one) and the rest simply fetch things from it.
2042 # function (this one) and the rest simply fetch things from it.
2043 class tagscache(object):
2043 class tagscache(object):
2044 def __init__(self):
2044 def __init__(self):
2045 # These two define the set of tags for this repository. tags
2045 # These two define the set of tags for this repository. tags
2046 # maps tag name to node; tagtypes maps tag name to 'global' or
2046 # maps tag name to node; tagtypes maps tag name to 'global' or
2047 # 'local'. (Global tags are defined by .hgtags across all
2047 # 'local'. (Global tags are defined by .hgtags across all
2048 # heads, and local tags are defined in .hg/localtags.)
2048 # heads, and local tags are defined in .hg/localtags.)
2049 # They constitute the in-memory cache of tags.
2049 # They constitute the in-memory cache of tags.
2050 self.tags = self.tagtypes = None
2050 self.tags = self.tagtypes = None
2051
2051
2052 self.nodetagscache = self.tagslist = None
2052 self.nodetagscache = self.tagslist = None
2053
2053
2054 cache = tagscache()
2054 cache = tagscache()
2055 cache.tags, cache.tagtypes = self._findtags()
2055 cache.tags, cache.tagtypes = self._findtags()
2056
2056
2057 return cache
2057 return cache
2058
2058
2059 def tags(self):
2059 def tags(self):
2060 '''return a mapping of tag to node'''
2060 '''return a mapping of tag to node'''
2061 t = {}
2061 t = {}
2062 if self.changelog.filteredrevs:
2062 if self.changelog.filteredrevs:
2063 tags, tt = self._findtags()
2063 tags, tt = self._findtags()
2064 else:
2064 else:
2065 tags = self._tagscache.tags
2065 tags = self._tagscache.tags
2066 rev = self.changelog.rev
2066 rev = self.changelog.rev
2067 for k, v in pycompat.iteritems(tags):
2067 for k, v in pycompat.iteritems(tags):
2068 try:
2068 try:
2069 # ignore tags to unknown nodes
2069 # ignore tags to unknown nodes
2070 rev(v)
2070 rev(v)
2071 t[k] = v
2071 t[k] = v
2072 except (error.LookupError, ValueError):
2072 except (error.LookupError, ValueError):
2073 pass
2073 pass
2074 return t
2074 return t
2075
2075
2076 def _findtags(self):
2076 def _findtags(self):
2077 """Do the hard work of finding tags. Return a pair of dicts
2077 """Do the hard work of finding tags. Return a pair of dicts
2078 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2078 (tags, tagtypes) where tags maps tag name to node, and tagtypes
2079 maps tag name to a string like \'global\' or \'local\'.
2079 maps tag name to a string like \'global\' or \'local\'.
2080 Subclasses or extensions are free to add their own tags, but
2080 Subclasses or extensions are free to add their own tags, but
2081 should be aware that the returned dicts will be retained for the
2081 should be aware that the returned dicts will be retained for the
2082 duration of the localrepo object."""
2082 duration of the localrepo object."""
2083
2083
2084 # XXX what tagtype should subclasses/extensions use? Currently
2084 # XXX what tagtype should subclasses/extensions use? Currently
2085 # mq and bookmarks add tags, but do not set the tagtype at all.
2085 # mq and bookmarks add tags, but do not set the tagtype at all.
2086 # Should each extension invent its own tag type? Should there
2086 # Should each extension invent its own tag type? Should there
2087 # be one tagtype for all such "virtual" tags? Or is the status
2087 # be one tagtype for all such "virtual" tags? Or is the status
2088 # quo fine?
2088 # quo fine?
2089
2089
2090 # map tag name to (node, hist)
2090 # map tag name to (node, hist)
2091 alltags = tagsmod.findglobaltags(self.ui, self)
2091 alltags = tagsmod.findglobaltags(self.ui, self)
2092 # map tag name to tag type
2092 # map tag name to tag type
2093 tagtypes = {tag: b'global' for tag in alltags}
2093 tagtypes = {tag: b'global' for tag in alltags}
2094
2094
2095 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2095 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
2096
2096
2097 # Build the return dicts. Have to re-encode tag names because
2097 # Build the return dicts. Have to re-encode tag names because
2098 # the tags module always uses UTF-8 (in order not to lose info
2098 # the tags module always uses UTF-8 (in order not to lose info
2099 # writing to the cache), but the rest of Mercurial wants them in
2099 # writing to the cache), but the rest of Mercurial wants them in
2100 # local encoding.
2100 # local encoding.
2101 tags = {}
2101 tags = {}
2102 for (name, (node, hist)) in pycompat.iteritems(alltags):
2102 for (name, (node, hist)) in pycompat.iteritems(alltags):
2103 if node != self.nullid:
2103 if node != self.nullid:
2104 tags[encoding.tolocal(name)] = node
2104 tags[encoding.tolocal(name)] = node
2105 tags[b'tip'] = self.changelog.tip()
2105 tags[b'tip'] = self.changelog.tip()
2106 tagtypes = {
2106 tagtypes = {
2107 encoding.tolocal(name): value
2107 encoding.tolocal(name): value
2108 for (name, value) in pycompat.iteritems(tagtypes)
2108 for (name, value) in pycompat.iteritems(tagtypes)
2109 }
2109 }
2110 return (tags, tagtypes)
2110 return (tags, tagtypes)
2111
2111
2112 def tagtype(self, tagname):
2112 def tagtype(self, tagname):
2113 """
2113 """
2114 return the type of the given tag. result can be:
2114 return the type of the given tag. result can be:
2115
2115
2116 'local' : a local tag
2116 'local' : a local tag
2117 'global' : a global tag
2117 'global' : a global tag
2118 None : tag does not exist
2118 None : tag does not exist
2119 """
2119 """
2120
2120
2121 return self._tagscache.tagtypes.get(tagname)
2121 return self._tagscache.tagtypes.get(tagname)
2122
2122
2123 def tagslist(self):
2123 def tagslist(self):
2124 '''return a list of tags ordered by revision'''
2124 '''return a list of tags ordered by revision'''
2125 if not self._tagscache.tagslist:
2125 if not self._tagscache.tagslist:
2126 l = []
2126 l = []
2127 for t, n in pycompat.iteritems(self.tags()):
2127 for t, n in pycompat.iteritems(self.tags()):
2128 l.append((self.changelog.rev(n), t, n))
2128 l.append((self.changelog.rev(n), t, n))
2129 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2129 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
2130
2130
2131 return self._tagscache.tagslist
2131 return self._tagscache.tagslist
2132
2132
2133 def nodetags(self, node):
2133 def nodetags(self, node):
2134 '''return the tags associated with a node'''
2134 '''return the tags associated with a node'''
2135 if not self._tagscache.nodetagscache:
2135 if not self._tagscache.nodetagscache:
2136 nodetagscache = {}
2136 nodetagscache = {}
2137 for t, n in pycompat.iteritems(self._tagscache.tags):
2137 for t, n in pycompat.iteritems(self._tagscache.tags):
2138 nodetagscache.setdefault(n, []).append(t)
2138 nodetagscache.setdefault(n, []).append(t)
2139 for tags in pycompat.itervalues(nodetagscache):
2139 for tags in pycompat.itervalues(nodetagscache):
2140 tags.sort()
2140 tags.sort()
2141 self._tagscache.nodetagscache = nodetagscache
2141 self._tagscache.nodetagscache = nodetagscache
2142 return self._tagscache.nodetagscache.get(node, [])
2142 return self._tagscache.nodetagscache.get(node, [])
2143
2143
2144 def nodebookmarks(self, node):
2144 def nodebookmarks(self, node):
2145 """return the list of bookmarks pointing to the specified node"""
2145 """return the list of bookmarks pointing to the specified node"""
2146 return self._bookmarks.names(node)
2146 return self._bookmarks.names(node)
2147
2147
2148 def branchmap(self):
2148 def branchmap(self):
2149 """returns a dictionary {branch: [branchheads]} with branchheads
2149 """returns a dictionary {branch: [branchheads]} with branchheads
2150 ordered by increasing revision number"""
2150 ordered by increasing revision number"""
2151 return self._branchcaches[self]
2151 return self._branchcaches[self]
2152
2152
2153 @unfilteredmethod
2153 @unfilteredmethod
2154 def revbranchcache(self):
2154 def revbranchcache(self):
2155 if not self._revbranchcache:
2155 if not self._revbranchcache:
2156 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2156 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
2157 return self._revbranchcache
2157 return self._revbranchcache
2158
2158
2159 def register_changeset(self, rev, changelogrevision):
2159 def register_changeset(self, rev, changelogrevision):
2160 self.revbranchcache().setdata(rev, changelogrevision)
2160 self.revbranchcache().setdata(rev, changelogrevision)
2161
2161
2162 def branchtip(self, branch, ignoremissing=False):
2162 def branchtip(self, branch, ignoremissing=False):
2163 """return the tip node for a given branch
2163 """return the tip node for a given branch
2164
2164
2165 If ignoremissing is True, then this method will not raise an error.
2165 If ignoremissing is True, then this method will not raise an error.
2166 This is helpful for callers that only expect None for a missing branch
2166 This is helpful for callers that only expect None for a missing branch
2167 (e.g. namespace).
2167 (e.g. namespace).
2168
2168
2169 """
2169 """
2170 try:
2170 try:
2171 return self.branchmap().branchtip(branch)
2171 return self.branchmap().branchtip(branch)
2172 except KeyError:
2172 except KeyError:
2173 if not ignoremissing:
2173 if not ignoremissing:
2174 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2174 raise error.RepoLookupError(_(b"unknown branch '%s'") % branch)
2175 else:
2175 else:
2176 pass
2176 pass
2177
2177
2178 def lookup(self, key):
2178 def lookup(self, key):
2179 node = scmutil.revsymbol(self, key).node()
2179 node = scmutil.revsymbol(self, key).node()
2180 if node is None:
2180 if node is None:
2181 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2181 raise error.RepoLookupError(_(b"unknown revision '%s'") % key)
2182 return node
2182 return node
2183
2183
2184 def lookupbranch(self, key):
2184 def lookupbranch(self, key):
2185 if self.branchmap().hasbranch(key):
2185 if self.branchmap().hasbranch(key):
2186 return key
2186 return key
2187
2187
2188 return scmutil.revsymbol(self, key).branch()
2188 return scmutil.revsymbol(self, key).branch()
2189
2189
2190 def known(self, nodes):
2190 def known(self, nodes):
2191 cl = self.changelog
2191 cl = self.changelog
2192 get_rev = cl.index.get_rev
2192 get_rev = cl.index.get_rev
2193 filtered = cl.filteredrevs
2193 filtered = cl.filteredrevs
2194 result = []
2194 result = []
2195 for n in nodes:
2195 for n in nodes:
2196 r = get_rev(n)
2196 r = get_rev(n)
2197 resp = not (r is None or r in filtered)
2197 resp = not (r is None or r in filtered)
2198 result.append(resp)
2198 result.append(resp)
2199 return result
2199 return result
2200
2200
2201 def local(self):
2201 def local(self):
2202 return self
2202 return self
2203
2203
2204 def publishing(self):
2204 def publishing(self):
2205 # it's safe (and desirable) to trust the publish flag unconditionally
2205 # it's safe (and desirable) to trust the publish flag unconditionally
2206 # so that we don't finalize changes shared between users via ssh or nfs
2206 # so that we don't finalize changes shared between users via ssh or nfs
2207 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2207 return self.ui.configbool(b'phases', b'publish', untrusted=True)
2208
2208
2209 def cancopy(self):
2209 def cancopy(self):
2210 # so statichttprepo's override of local() works
2210 # so statichttprepo's override of local() works
2211 if not self.local():
2211 if not self.local():
2212 return False
2212 return False
2213 if not self.publishing():
2213 if not self.publishing():
2214 return True
2214 return True
2215 # if publishing we can't copy if there is filtered content
2215 # if publishing we can't copy if there is filtered content
2216 return not self.filtered(b'visible').changelog.filteredrevs
2216 return not self.filtered(b'visible').changelog.filteredrevs
2217
2217
2218 def shared(self):
2218 def shared(self):
2219 '''the type of shared repository (None if not shared)'''
2219 '''the type of shared repository (None if not shared)'''
2220 if self.sharedpath != self.path:
2220 if self.sharedpath != self.path:
2221 return b'store'
2221 return b'store'
2222 return None
2222 return None
2223
2223
2224 def wjoin(self, f, *insidef):
2224 def wjoin(self, f, *insidef):
2225 return self.vfs.reljoin(self.root, f, *insidef)
2225 return self.vfs.reljoin(self.root, f, *insidef)
2226
2226
2227 def setparents(self, p1, p2=None):
2227 def setparents(self, p1, p2=None):
2228 if p2 is None:
2228 if p2 is None:
2229 p2 = self.nullid
2229 p2 = self.nullid
2230 self[None].setparents(p1, p2)
2230 self[None].setparents(p1, p2)
2231 self._quick_access_changeid_invalidate()
2231 self._quick_access_changeid_invalidate()
2232
2232
2233 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2233 def filectx(self, path, changeid=None, fileid=None, changectx=None):
2234 """changeid must be a changeset revision, if specified.
2234 """changeid must be a changeset revision, if specified.
2235 fileid can be a file revision or node."""
2235 fileid can be a file revision or node."""
2236 return context.filectx(
2236 return context.filectx(
2237 self, path, changeid, fileid, changectx=changectx
2237 self, path, changeid, fileid, changectx=changectx
2238 )
2238 )
2239
2239
2240 def getcwd(self):
2240 def getcwd(self):
2241 return self.dirstate.getcwd()
2241 return self.dirstate.getcwd()
2242
2242
2243 def pathto(self, f, cwd=None):
2243 def pathto(self, f, cwd=None):
2244 return self.dirstate.pathto(f, cwd)
2244 return self.dirstate.pathto(f, cwd)
2245
2245
2246 def _loadfilter(self, filter):
2246 def _loadfilter(self, filter):
2247 if filter not in self._filterpats:
2247 if filter not in self._filterpats:
2248 l = []
2248 l = []
2249 for pat, cmd in self.ui.configitems(filter):
2249 for pat, cmd in self.ui.configitems(filter):
2250 if cmd == b'!':
2250 if cmd == b'!':
2251 continue
2251 continue
2252 mf = matchmod.match(self.root, b'', [pat])
2252 mf = matchmod.match(self.root, b'', [pat])
2253 fn = None
2253 fn = None
2254 params = cmd
2254 params = cmd
2255 for name, filterfn in pycompat.iteritems(self._datafilters):
2255 for name, filterfn in pycompat.iteritems(self._datafilters):
2256 if cmd.startswith(name):
2256 if cmd.startswith(name):
2257 fn = filterfn
2257 fn = filterfn
2258 params = cmd[len(name) :].lstrip()
2258 params = cmd[len(name) :].lstrip()
2259 break
2259 break
2260 if not fn:
2260 if not fn:
2261 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2261 fn = lambda s, c, **kwargs: procutil.filter(s, c)
2262 fn.__name__ = 'commandfilter'
2262 fn.__name__ = 'commandfilter'
2263 # Wrap old filters not supporting keyword arguments
2263 # Wrap old filters not supporting keyword arguments
2264 if not pycompat.getargspec(fn)[2]:
2264 if not pycompat.getargspec(fn)[2]:
2265 oldfn = fn
2265 oldfn = fn
2266 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2266 fn = lambda s, c, oldfn=oldfn, **kwargs: oldfn(s, c)
2267 fn.__name__ = 'compat-' + oldfn.__name__
2267 fn.__name__ = 'compat-' + oldfn.__name__
2268 l.append((mf, fn, params))
2268 l.append((mf, fn, params))
2269 self._filterpats[filter] = l
2269 self._filterpats[filter] = l
2270 return self._filterpats[filter]
2270 return self._filterpats[filter]
2271
2271
2272 def _filter(self, filterpats, filename, data):
2272 def _filter(self, filterpats, filename, data):
2273 for mf, fn, cmd in filterpats:
2273 for mf, fn, cmd in filterpats:
2274 if mf(filename):
2274 if mf(filename):
2275 self.ui.debug(
2275 self.ui.debug(
2276 b"filtering %s through %s\n"
2276 b"filtering %s through %s\n"
2277 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2277 % (filename, cmd or pycompat.sysbytes(fn.__name__))
2278 )
2278 )
2279 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2279 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
2280 break
2280 break
2281
2281
2282 return data
2282 return data
2283
2283
2284 @unfilteredpropertycache
2284 @unfilteredpropertycache
2285 def _encodefilterpats(self):
2285 def _encodefilterpats(self):
2286 return self._loadfilter(b'encode')
2286 return self._loadfilter(b'encode')
2287
2287
2288 @unfilteredpropertycache
2288 @unfilteredpropertycache
2289 def _decodefilterpats(self):
2289 def _decodefilterpats(self):
2290 return self._loadfilter(b'decode')
2290 return self._loadfilter(b'decode')
2291
2291
2292 def adddatafilter(self, name, filter):
2292 def adddatafilter(self, name, filter):
2293 self._datafilters[name] = filter
2293 self._datafilters[name] = filter
2294
2294
2295 def wread(self, filename):
2295 def wread(self, filename):
2296 if self.wvfs.islink(filename):
2296 if self.wvfs.islink(filename):
2297 data = self.wvfs.readlink(filename)
2297 data = self.wvfs.readlink(filename)
2298 else:
2298 else:
2299 data = self.wvfs.read(filename)
2299 data = self.wvfs.read(filename)
2300 return self._filter(self._encodefilterpats, filename, data)
2300 return self._filter(self._encodefilterpats, filename, data)
2301
2301
2302 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2302 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
2303 """write ``data`` into ``filename`` in the working directory
2303 """write ``data`` into ``filename`` in the working directory
2304
2304
2305 This returns length of written (maybe decoded) data.
2305 This returns length of written (maybe decoded) data.
2306 """
2306 """
2307 data = self._filter(self._decodefilterpats, filename, data)
2307 data = self._filter(self._decodefilterpats, filename, data)
2308 if b'l' in flags:
2308 if b'l' in flags:
2309 self.wvfs.symlink(data, filename)
2309 self.wvfs.symlink(data, filename)
2310 else:
2310 else:
2311 self.wvfs.write(
2311 self.wvfs.write(
2312 filename, data, backgroundclose=backgroundclose, **kwargs
2312 filename, data, backgroundclose=backgroundclose, **kwargs
2313 )
2313 )
2314 if b'x' in flags:
2314 if b'x' in flags:
2315 self.wvfs.setflags(filename, False, True)
2315 self.wvfs.setflags(filename, False, True)
2316 else:
2316 else:
2317 self.wvfs.setflags(filename, False, False)
2317 self.wvfs.setflags(filename, False, False)
2318 return len(data)
2318 return len(data)
2319
2319
2320 def wwritedata(self, filename, data):
2320 def wwritedata(self, filename, data):
2321 return self._filter(self._decodefilterpats, filename, data)
2321 return self._filter(self._decodefilterpats, filename, data)
2322
2322
2323 def currenttransaction(self):
2323 def currenttransaction(self):
2324 """return the current transaction or None if non exists"""
2324 """return the current transaction or None if non exists"""
2325 if self._transref:
2325 if self._transref:
2326 tr = self._transref()
2326 tr = self._transref()
2327 else:
2327 else:
2328 tr = None
2328 tr = None
2329
2329
2330 if tr and tr.running():
2330 if tr and tr.running():
2331 return tr
2331 return tr
2332 return None
2332 return None
2333
2333
2334 def transaction(self, desc, report=None):
2334 def transaction(self, desc, report=None):
2335 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2335 if self.ui.configbool(b'devel', b'all-warnings') or self.ui.configbool(
2336 b'devel', b'check-locks'
2336 b'devel', b'check-locks'
2337 ):
2337 ):
2338 if self._currentlock(self._lockref) is None:
2338 if self._currentlock(self._lockref) is None:
2339 raise error.ProgrammingError(b'transaction requires locking')
2339 raise error.ProgrammingError(b'transaction requires locking')
2340 tr = self.currenttransaction()
2340 tr = self.currenttransaction()
2341 if tr is not None:
2341 if tr is not None:
2342 return tr.nest(name=desc)
2342 return tr.nest(name=desc)
2343
2343
2344 # abort here if the journal already exists
2344 # abort here if the journal already exists
2345 if self.svfs.exists(b"journal"):
2345 if self.svfs.exists(b"journal"):
2346 raise error.RepoError(
2346 raise error.RepoError(
2347 _(b"abandoned transaction found"),
2347 _(b"abandoned transaction found"),
2348 hint=_(b"run 'hg recover' to clean up transaction"),
2348 hint=_(b"run 'hg recover' to clean up transaction"),
2349 )
2349 )
2350
2350
2351 idbase = b"%.40f#%f" % (random.random(), time.time())
2351 idbase = b"%.40f#%f" % (random.random(), time.time())
2352 ha = hex(hashutil.sha1(idbase).digest())
2352 ha = hex(hashutil.sha1(idbase).digest())
2353 txnid = b'TXN:' + ha
2353 txnid = b'TXN:' + ha
2354 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2354 self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
2355
2355
2356 self._writejournal(desc)
2356 self._writejournal(desc)
2357 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2357 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
2358 if report:
2358 if report:
2359 rp = report
2359 rp = report
2360 else:
2360 else:
2361 rp = self.ui.warn
2361 rp = self.ui.warn
2362 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2362 vfsmap = {b'plain': self.vfs, b'store': self.svfs} # root of .hg/
2363 # we must avoid cyclic reference between repo and transaction.
2363 # we must avoid cyclic reference between repo and transaction.
2364 reporef = weakref.ref(self)
2364 reporef = weakref.ref(self)
2365 # Code to track tag movement
2365 # Code to track tag movement
2366 #
2366 #
2367 # Since tags are all handled as file content, it is actually quite hard
2367 # Since tags are all handled as file content, it is actually quite hard
2368 # to track these movement from a code perspective. So we fallback to a
2368 # to track these movement from a code perspective. So we fallback to a
2369 # tracking at the repository level. One could envision to track changes
2369 # tracking at the repository level. One could envision to track changes
2370 # to the '.hgtags' file through changegroup apply but that fails to
2370 # to the '.hgtags' file through changegroup apply but that fails to
2371 # cope with case where transaction expose new heads without changegroup
2371 # cope with case where transaction expose new heads without changegroup
2372 # being involved (eg: phase movement).
2372 # being involved (eg: phase movement).
2373 #
2373 #
2374 # For now, We gate the feature behind a flag since this likely comes
2374 # For now, We gate the feature behind a flag since this likely comes
2375 # with performance impacts. The current code run more often than needed
2375 # with performance impacts. The current code run more often than needed
2376 # and do not use caches as much as it could. The current focus is on
2376 # and do not use caches as much as it could. The current focus is on
2377 # the behavior of the feature so we disable it by default. The flag
2377 # the behavior of the feature so we disable it by default. The flag
2378 # will be removed when we are happy with the performance impact.
2378 # will be removed when we are happy with the performance impact.
2379 #
2379 #
2380 # Once this feature is no longer experimental move the following
2380 # Once this feature is no longer experimental move the following
2381 # documentation to the appropriate help section:
2381 # documentation to the appropriate help section:
2382 #
2382 #
2383 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2383 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
2384 # tags (new or changed or deleted tags). In addition the details of
2384 # tags (new or changed or deleted tags). In addition the details of
2385 # these changes are made available in a file at:
2385 # these changes are made available in a file at:
2386 # ``REPOROOT/.hg/changes/tags.changes``.
2386 # ``REPOROOT/.hg/changes/tags.changes``.
2387 # Make sure you check for HG_TAG_MOVED before reading that file as it
2387 # Make sure you check for HG_TAG_MOVED before reading that file as it
2388 # might exist from a previous transaction even if no tag were touched
2388 # might exist from a previous transaction even if no tag were touched
2389 # in this one. Changes are recorded in a line base format::
2389 # in this one. Changes are recorded in a line base format::
2390 #
2390 #
2391 # <action> <hex-node> <tag-name>\n
2391 # <action> <hex-node> <tag-name>\n
2392 #
2392 #
2393 # Actions are defined as follow:
2393 # Actions are defined as follow:
2394 # "-R": tag is removed,
2394 # "-R": tag is removed,
2395 # "+A": tag is added,
2395 # "+A": tag is added,
2396 # "-M": tag is moved (old value),
2396 # "-M": tag is moved (old value),
2397 # "+M": tag is moved (new value),
2397 # "+M": tag is moved (new value),
2398 tracktags = lambda x: None
2398 tracktags = lambda x: None
2399 # experimental config: experimental.hook-track-tags
2399 # experimental config: experimental.hook-track-tags
2400 shouldtracktags = self.ui.configbool(
2400 shouldtracktags = self.ui.configbool(
2401 b'experimental', b'hook-track-tags'
2401 b'experimental', b'hook-track-tags'
2402 )
2402 )
2403 if desc != b'strip' and shouldtracktags:
2403 if desc != b'strip' and shouldtracktags:
2404 oldheads = self.changelog.headrevs()
2404 oldheads = self.changelog.headrevs()
2405
2405
2406 def tracktags(tr2):
2406 def tracktags(tr2):
2407 repo = reporef()
2407 repo = reporef()
2408 assert repo is not None # help pytype
2408 assert repo is not None # help pytype
2409 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2409 oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads)
2410 newheads = repo.changelog.headrevs()
2410 newheads = repo.changelog.headrevs()
2411 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2411 newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads)
2412 # notes: we compare lists here.
2412 # notes: we compare lists here.
2413 # As we do it only once buiding set would not be cheaper
2413 # As we do it only once buiding set would not be cheaper
2414 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2414 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
2415 if changes:
2415 if changes:
2416 tr2.hookargs[b'tag_moved'] = b'1'
2416 tr2.hookargs[b'tag_moved'] = b'1'
2417 with repo.vfs(
2417 with repo.vfs(
2418 b'changes/tags.changes', b'w', atomictemp=True
2418 b'changes/tags.changes', b'w', atomictemp=True
2419 ) as changesfile:
2419 ) as changesfile:
2420 # note: we do not register the file to the transaction
2420 # note: we do not register the file to the transaction
2421 # because we needs it to still exist on the transaction
2421 # because we needs it to still exist on the transaction
2422 # is close (for txnclose hooks)
2422 # is close (for txnclose hooks)
2423 tagsmod.writediff(changesfile, changes)
2423 tagsmod.writediff(changesfile, changes)
2424
2424
2425 def validate(tr2):
2425 def validate(tr2):
2426 """will run pre-closing hooks"""
2426 """will run pre-closing hooks"""
2427 # XXX the transaction API is a bit lacking here so we take a hacky
2427 # XXX the transaction API is a bit lacking here so we take a hacky
2428 # path for now
2428 # path for now
2429 #
2429 #
2430 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2430 # We cannot add this as a "pending" hooks since the 'tr.hookargs'
2431 # dict is copied before these run. In addition we needs the data
2431 # dict is copied before these run. In addition we needs the data
2432 # available to in memory hooks too.
2432 # available to in memory hooks too.
2433 #
2433 #
2434 # Moreover, we also need to make sure this runs before txnclose
2434 # Moreover, we also need to make sure this runs before txnclose
2435 # hooks and there is no "pending" mechanism that would execute
2435 # hooks and there is no "pending" mechanism that would execute
2436 # logic only if hooks are about to run.
2436 # logic only if hooks are about to run.
2437 #
2437 #
2438 # Fixing this limitation of the transaction is also needed to track
2438 # Fixing this limitation of the transaction is also needed to track
2439 # other families of changes (bookmarks, phases, obsolescence).
2439 # other families of changes (bookmarks, phases, obsolescence).
2440 #
2440 #
2441 # This will have to be fixed before we remove the experimental
2441 # This will have to be fixed before we remove the experimental
2442 # gating.
2442 # gating.
2443 tracktags(tr2)
2443 tracktags(tr2)
2444 repo = reporef()
2444 repo = reporef()
2445 assert repo is not None # help pytype
2445 assert repo is not None # help pytype
2446
2446
2447 singleheadopt = (b'experimental', b'single-head-per-branch')
2447 singleheadopt = (b'experimental', b'single-head-per-branch')
2448 singlehead = repo.ui.configbool(*singleheadopt)
2448 singlehead = repo.ui.configbool(*singleheadopt)
2449 if singlehead:
2449 if singlehead:
2450 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2450 singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
2451 accountclosed = singleheadsub.get(
2451 accountclosed = singleheadsub.get(
2452 b"account-closed-heads", False
2452 b"account-closed-heads", False
2453 )
2453 )
2454 if singleheadsub.get(b"public-changes-only", False):
2454 if singleheadsub.get(b"public-changes-only", False):
2455 filtername = b"immutable"
2455 filtername = b"immutable"
2456 else:
2456 else:
2457 filtername = b"visible"
2457 filtername = b"visible"
2458 scmutil.enforcesinglehead(
2458 scmutil.enforcesinglehead(
2459 repo, tr2, desc, accountclosed, filtername
2459 repo, tr2, desc, accountclosed, filtername
2460 )
2460 )
2461 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2461 if hook.hashook(repo.ui, b'pretxnclose-bookmark'):
2462 for name, (old, new) in sorted(
2462 for name, (old, new) in sorted(
2463 tr.changes[b'bookmarks'].items()
2463 tr.changes[b'bookmarks'].items()
2464 ):
2464 ):
2465 args = tr.hookargs.copy()
2465 args = tr.hookargs.copy()
2466 args.update(bookmarks.preparehookargs(name, old, new))
2466 args.update(bookmarks.preparehookargs(name, old, new))
2467 repo.hook(
2467 repo.hook(
2468 b'pretxnclose-bookmark',
2468 b'pretxnclose-bookmark',
2469 throw=True,
2469 throw=True,
2470 **pycompat.strkwargs(args)
2470 **pycompat.strkwargs(args)
2471 )
2471 )
2472 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2472 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2473 cl = repo.unfiltered().changelog
2473 cl = repo.unfiltered().changelog
2474 for revs, (old, new) in tr.changes[b'phases']:
2474 for revs, (old, new) in tr.changes[b'phases']:
2475 for rev in revs:
2475 for rev in revs:
2476 args = tr.hookargs.copy()
2476 args = tr.hookargs.copy()
2477 node = hex(cl.node(rev))
2477 node = hex(cl.node(rev))
2478 args.update(phases.preparehookargs(node, old, new))
2478 args.update(phases.preparehookargs(node, old, new))
2479 repo.hook(
2479 repo.hook(
2480 b'pretxnclose-phase',
2480 b'pretxnclose-phase',
2481 throw=True,
2481 throw=True,
2482 **pycompat.strkwargs(args)
2482 **pycompat.strkwargs(args)
2483 )
2483 )
2484
2484
2485 repo.hook(
2485 repo.hook(
2486 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2486 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2487 )
2487 )
2488
2488
2489 def releasefn(tr, success):
2489 def releasefn(tr, success):
2490 repo = reporef()
2490 repo = reporef()
2491 if repo is None:
2491 if repo is None:
2492 # If the repo has been GC'd (and this release function is being
2492 # If the repo has been GC'd (and this release function is being
2493 # called from transaction.__del__), there's not much we can do,
2493 # called from transaction.__del__), there's not much we can do,
2494 # so just leave the unfinished transaction there and let the
2494 # so just leave the unfinished transaction there and let the
2495 # user run `hg recover`.
2495 # user run `hg recover`.
2496 return
2496 return
2497 if success:
2497 if success:
2498 # this should be explicitly invoked here, because
2498 # this should be explicitly invoked here, because
2499 # in-memory changes aren't written out at closing
2499 # in-memory changes aren't written out at closing
2500 # transaction, if tr.addfilegenerator (via
2500 # transaction, if tr.addfilegenerator (via
2501 # dirstate.write or so) isn't invoked while
2501 # dirstate.write or so) isn't invoked while
2502 # transaction running
2502 # transaction running
2503 repo.dirstate.write(None)
2503 repo.dirstate.write(None)
2504 else:
2504 else:
2505 # discard all changes (including ones already written
2505 # discard all changes (including ones already written
2506 # out) in this transaction
2506 # out) in this transaction
2507 narrowspec.restorebackup(self, b'journal.narrowspec')
2507 narrowspec.restorebackup(self, b'journal.narrowspec')
2508 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2508 narrowspec.restorewcbackup(self, b'journal.narrowspec.dirstate')
2509 repo.dirstate.restorebackup(None, b'journal.dirstate')
2509 repo.dirstate.restorebackup(None, b'journal.dirstate')
2510
2510
2511 repo.invalidate(clearfilecache=True)
2511 repo.invalidate(clearfilecache=True)
2512
2512
2513 tr = transaction.transaction(
2513 tr = transaction.transaction(
2514 rp,
2514 rp,
2515 self.svfs,
2515 self.svfs,
2516 vfsmap,
2516 vfsmap,
2517 b"journal",
2517 b"journal",
2518 b"undo",
2518 b"undo",
2519 aftertrans(renames),
2519 aftertrans(renames),
2520 self.store.createmode,
2520 self.store.createmode,
2521 validator=validate,
2521 validator=validate,
2522 releasefn=releasefn,
2522 releasefn=releasefn,
2523 checkambigfiles=_cachedfiles,
2523 checkambigfiles=_cachedfiles,
2524 name=desc,
2524 name=desc,
2525 )
2525 )
2526 tr.changes[b'origrepolen'] = len(self)
2526 tr.changes[b'origrepolen'] = len(self)
2527 tr.changes[b'obsmarkers'] = set()
2527 tr.changes[b'obsmarkers'] = set()
2528 tr.changes[b'phases'] = []
2528 tr.changes[b'phases'] = []
2529 tr.changes[b'bookmarks'] = {}
2529 tr.changes[b'bookmarks'] = {}
2530
2530
2531 tr.hookargs[b'txnid'] = txnid
2531 tr.hookargs[b'txnid'] = txnid
2532 tr.hookargs[b'txnname'] = desc
2532 tr.hookargs[b'txnname'] = desc
2533 tr.hookargs[b'changes'] = tr.changes
2533 tr.hookargs[b'changes'] = tr.changes
2534 # note: writing the fncache only during finalize mean that the file is
2534 # note: writing the fncache only during finalize mean that the file is
2535 # outdated when running hooks. As fncache is used for streaming clone,
2535 # outdated when running hooks. As fncache is used for streaming clone,
2536 # this is not expected to break anything that happen during the hooks.
2536 # this is not expected to break anything that happen during the hooks.
2537 tr.addfinalize(b'flush-fncache', self.store.write)
2537 tr.addfinalize(b'flush-fncache', self.store.write)
2538
2538
2539 def txnclosehook(tr2):
2539 def txnclosehook(tr2):
2540 """To be run if transaction is successful, will schedule a hook run"""
2540 """To be run if transaction is successful, will schedule a hook run"""
2541 # Don't reference tr2 in hook() so we don't hold a reference.
2541 # Don't reference tr2 in hook() so we don't hold a reference.
2542 # This reduces memory consumption when there are multiple
2542 # This reduces memory consumption when there are multiple
2543 # transactions per lock. This can likely go away if issue5045
2543 # transactions per lock. This can likely go away if issue5045
2544 # fixes the function accumulation.
2544 # fixes the function accumulation.
2545 hookargs = tr2.hookargs
2545 hookargs = tr2.hookargs
2546
2546
2547 def hookfunc(unused_success):
2547 def hookfunc(unused_success):
2548 repo = reporef()
2548 repo = reporef()
2549 assert repo is not None # help pytype
2549 assert repo is not None # help pytype
2550
2550
2551 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2551 if hook.hashook(repo.ui, b'txnclose-bookmark'):
2552 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2552 bmchanges = sorted(tr.changes[b'bookmarks'].items())
2553 for name, (old, new) in bmchanges:
2553 for name, (old, new) in bmchanges:
2554 args = tr.hookargs.copy()
2554 args = tr.hookargs.copy()
2555 args.update(bookmarks.preparehookargs(name, old, new))
2555 args.update(bookmarks.preparehookargs(name, old, new))
2556 repo.hook(
2556 repo.hook(
2557 b'txnclose-bookmark',
2557 b'txnclose-bookmark',
2558 throw=False,
2558 throw=False,
2559 **pycompat.strkwargs(args)
2559 **pycompat.strkwargs(args)
2560 )
2560 )
2561
2561
2562 if hook.hashook(repo.ui, b'txnclose-phase'):
2562 if hook.hashook(repo.ui, b'txnclose-phase'):
2563 cl = repo.unfiltered().changelog
2563 cl = repo.unfiltered().changelog
2564 phasemv = sorted(
2564 phasemv = sorted(
2565 tr.changes[b'phases'], key=lambda r: r[0][0]
2565 tr.changes[b'phases'], key=lambda r: r[0][0]
2566 )
2566 )
2567 for revs, (old, new) in phasemv:
2567 for revs, (old, new) in phasemv:
2568 for rev in revs:
2568 for rev in revs:
2569 args = tr.hookargs.copy()
2569 args = tr.hookargs.copy()
2570 node = hex(cl.node(rev))
2570 node = hex(cl.node(rev))
2571 args.update(phases.preparehookargs(node, old, new))
2571 args.update(phases.preparehookargs(node, old, new))
2572 repo.hook(
2572 repo.hook(
2573 b'txnclose-phase',
2573 b'txnclose-phase',
2574 throw=False,
2574 throw=False,
2575 **pycompat.strkwargs(args)
2575 **pycompat.strkwargs(args)
2576 )
2576 )
2577
2577
2578 repo.hook(
2578 repo.hook(
2579 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2579 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2580 )
2580 )
2581
2581
2582 repo = reporef()
2582 repo = reporef()
2583 assert repo is not None # help pytype
2583 assert repo is not None # help pytype
2584 repo._afterlock(hookfunc)
2584 repo._afterlock(hookfunc)
2585
2585
2586 tr.addfinalize(b'txnclose-hook', txnclosehook)
2586 tr.addfinalize(b'txnclose-hook', txnclosehook)
2587 # Include a leading "-" to make it happen before the transaction summary
2587 # Include a leading "-" to make it happen before the transaction summary
2588 # reports registered via scmutil.registersummarycallback() whose names
2588 # reports registered via scmutil.registersummarycallback() whose names
2589 # are 00-txnreport etc. That way, the caches will be warm when the
2589 # are 00-txnreport etc. That way, the caches will be warm when the
2590 # callbacks run.
2590 # callbacks run.
2591 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2591 tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
2592
2592
2593 def txnaborthook(tr2):
2593 def txnaborthook(tr2):
2594 """To be run if transaction is aborted"""
2594 """To be run if transaction is aborted"""
2595 repo = reporef()
2595 repo = reporef()
2596 assert repo is not None # help pytype
2596 assert repo is not None # help pytype
2597 repo.hook(
2597 repo.hook(
2598 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2598 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
2599 )
2599 )
2600
2600
2601 tr.addabort(b'txnabort-hook', txnaborthook)
2601 tr.addabort(b'txnabort-hook', txnaborthook)
2602 # avoid eager cache invalidation. in-memory data should be identical
2602 # avoid eager cache invalidation. in-memory data should be identical
2603 # to stored data if transaction has no error.
2603 # to stored data if transaction has no error.
2604 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2604 tr.addpostclose(b'refresh-filecachestats', self._refreshfilecachestats)
2605 self._transref = weakref.ref(tr)
2605 self._transref = weakref.ref(tr)
2606 scmutil.registersummarycallback(self, tr, desc)
2606 scmutil.registersummarycallback(self, tr, desc)
2607 return tr
2607 return tr
2608
2608
2609 def _journalfiles(self):
2609 def _journalfiles(self):
2610 return (
2610 return (
2611 (self.svfs, b'journal'),
2611 (self.svfs, b'journal'),
2612 (self.svfs, b'journal.narrowspec'),
2612 (self.svfs, b'journal.narrowspec'),
2613 (self.vfs, b'journal.narrowspec.dirstate'),
2613 (self.vfs, b'journal.narrowspec.dirstate'),
2614 (self.vfs, b'journal.dirstate'),
2614 (self.vfs, b'journal.dirstate'),
2615 (self.vfs, b'journal.branch'),
2615 (self.vfs, b'journal.branch'),
2616 (self.vfs, b'journal.desc'),
2616 (self.vfs, b'journal.desc'),
2617 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2617 (bookmarks.bookmarksvfs(self), b'journal.bookmarks'),
2618 (self.svfs, b'journal.phaseroots'),
2618 (self.svfs, b'journal.phaseroots'),
2619 )
2619 )
2620
2620
2621 def undofiles(self):
2621 def undofiles(self):
2622 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2622 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
2623
2623
2624 @unfilteredmethod
2624 @unfilteredmethod
2625 def _writejournal(self, desc):
2625 def _writejournal(self, desc):
2626 self.dirstate.savebackup(None, b'journal.dirstate')
2626 self.dirstate.savebackup(None, b'journal.dirstate')
2627 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2627 narrowspec.savewcbackup(self, b'journal.narrowspec.dirstate')
2628 narrowspec.savebackup(self, b'journal.narrowspec')
2628 narrowspec.savebackup(self, b'journal.narrowspec')
2629 self.vfs.write(
2629 self.vfs.write(
2630 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2630 b"journal.branch", encoding.fromlocal(self.dirstate.branch())
2631 )
2631 )
2632 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2632 self.vfs.write(b"journal.desc", b"%d\n%s\n" % (len(self), desc))
2633 bookmarksvfs = bookmarks.bookmarksvfs(self)
2633 bookmarksvfs = bookmarks.bookmarksvfs(self)
2634 bookmarksvfs.write(
2634 bookmarksvfs.write(
2635 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2635 b"journal.bookmarks", bookmarksvfs.tryread(b"bookmarks")
2636 )
2636 )
2637 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2637 self.svfs.write(b"journal.phaseroots", self.svfs.tryread(b"phaseroots"))
2638
2638
2639 def recover(self):
2639 def recover(self):
2640 with self.lock():
2640 with self.lock():
2641 if self.svfs.exists(b"journal"):
2641 if self.svfs.exists(b"journal"):
2642 self.ui.status(_(b"rolling back interrupted transaction\n"))
2642 self.ui.status(_(b"rolling back interrupted transaction\n"))
2643 vfsmap = {
2643 vfsmap = {
2644 b'': self.svfs,
2644 b'': self.svfs,
2645 b'plain': self.vfs,
2645 b'plain': self.vfs,
2646 }
2646 }
2647 transaction.rollback(
2647 transaction.rollback(
2648 self.svfs,
2648 self.svfs,
2649 vfsmap,
2649 vfsmap,
2650 b"journal",
2650 b"journal",
2651 self.ui.warn,
2651 self.ui.warn,
2652 checkambigfiles=_cachedfiles,
2652 checkambigfiles=_cachedfiles,
2653 )
2653 )
2654 self.invalidate()
2654 self.invalidate()
2655 return True
2655 return True
2656 else:
2656 else:
2657 self.ui.warn(_(b"no interrupted transaction available\n"))
2657 self.ui.warn(_(b"no interrupted transaction available\n"))
2658 return False
2658 return False
2659
2659
2660 def rollback(self, dryrun=False, force=False):
2660 def rollback(self, dryrun=False, force=False):
2661 wlock = lock = dsguard = None
2661 wlock = lock = dsguard = None
2662 try:
2662 try:
2663 wlock = self.wlock()
2663 wlock = self.wlock()
2664 lock = self.lock()
2664 lock = self.lock()
2665 if self.svfs.exists(b"undo"):
2665 if self.svfs.exists(b"undo"):
2666 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2666 dsguard = dirstateguard.dirstateguard(self, b'rollback')
2667
2667
2668 return self._rollback(dryrun, force, dsguard)
2668 return self._rollback(dryrun, force, dsguard)
2669 else:
2669 else:
2670 self.ui.warn(_(b"no rollback information available\n"))
2670 self.ui.warn(_(b"no rollback information available\n"))
2671 return 1
2671 return 1
2672 finally:
2672 finally:
2673 release(dsguard, lock, wlock)
2673 release(dsguard, lock, wlock)
2674
2674
2675 @unfilteredmethod # Until we get smarter cache management
2675 @unfilteredmethod # Until we get smarter cache management
2676 def _rollback(self, dryrun, force, dsguard):
2676 def _rollback(self, dryrun, force, dsguard):
2677 ui = self.ui
2677 ui = self.ui
2678 try:
2678 try:
2679 args = self.vfs.read(b'undo.desc').splitlines()
2679 args = self.vfs.read(b'undo.desc').splitlines()
2680 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2680 (oldlen, desc, detail) = (int(args[0]), args[1], None)
2681 if len(args) >= 3:
2681 if len(args) >= 3:
2682 detail = args[2]
2682 detail = args[2]
2683 oldtip = oldlen - 1
2683 oldtip = oldlen - 1
2684
2684
2685 if detail and ui.verbose:
2685 if detail and ui.verbose:
2686 msg = _(
2686 msg = _(
2687 b'repository tip rolled back to revision %d'
2687 b'repository tip rolled back to revision %d'
2688 b' (undo %s: %s)\n'
2688 b' (undo %s: %s)\n'
2689 ) % (oldtip, desc, detail)
2689 ) % (oldtip, desc, detail)
2690 else:
2690 else:
2691 msg = _(
2691 msg = _(
2692 b'repository tip rolled back to revision %d (undo %s)\n'
2692 b'repository tip rolled back to revision %d (undo %s)\n'
2693 ) % (oldtip, desc)
2693 ) % (oldtip, desc)
2694 except IOError:
2694 except IOError:
2695 msg = _(b'rolling back unknown transaction\n')
2695 msg = _(b'rolling back unknown transaction\n')
2696 desc = None
2696 desc = None
2697
2697
2698 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2698 if not force and self[b'.'] != self[b'tip'] and desc == b'commit':
2699 raise error.Abort(
2699 raise error.Abort(
2700 _(
2700 _(
2701 b'rollback of last commit while not checked out '
2701 b'rollback of last commit while not checked out '
2702 b'may lose data'
2702 b'may lose data'
2703 ),
2703 ),
2704 hint=_(b'use -f to force'),
2704 hint=_(b'use -f to force'),
2705 )
2705 )
2706
2706
2707 ui.status(msg)
2707 ui.status(msg)
2708 if dryrun:
2708 if dryrun:
2709 return 0
2709 return 0
2710
2710
2711 parents = self.dirstate.parents()
2711 parents = self.dirstate.parents()
2712 self.destroying()
2712 self.destroying()
2713 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2713 vfsmap = {b'plain': self.vfs, b'': self.svfs}
2714 transaction.rollback(
2714 transaction.rollback(
2715 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2715 self.svfs, vfsmap, b'undo', ui.warn, checkambigfiles=_cachedfiles
2716 )
2716 )
2717 bookmarksvfs = bookmarks.bookmarksvfs(self)
2717 bookmarksvfs = bookmarks.bookmarksvfs(self)
2718 if bookmarksvfs.exists(b'undo.bookmarks'):
2718 if bookmarksvfs.exists(b'undo.bookmarks'):
2719 bookmarksvfs.rename(
2719 bookmarksvfs.rename(
2720 b'undo.bookmarks', b'bookmarks', checkambig=True
2720 b'undo.bookmarks', b'bookmarks', checkambig=True
2721 )
2721 )
2722 if self.svfs.exists(b'undo.phaseroots'):
2722 if self.svfs.exists(b'undo.phaseroots'):
2723 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2723 self.svfs.rename(b'undo.phaseroots', b'phaseroots', checkambig=True)
2724 self.invalidate()
2724 self.invalidate()
2725
2725
2726 has_node = self.changelog.index.has_node
2726 has_node = self.changelog.index.has_node
2727 parentgone = any(not has_node(p) for p in parents)
2727 parentgone = any(not has_node(p) for p in parents)
2728 if parentgone:
2728 if parentgone:
2729 # prevent dirstateguard from overwriting already restored one
2729 # prevent dirstateguard from overwriting already restored one
2730 dsguard.close()
2730 dsguard.close()
2731
2731
2732 narrowspec.restorebackup(self, b'undo.narrowspec')
2732 narrowspec.restorebackup(self, b'undo.narrowspec')
2733 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2733 narrowspec.restorewcbackup(self, b'undo.narrowspec.dirstate')
2734 self.dirstate.restorebackup(None, b'undo.dirstate')
2734 self.dirstate.restorebackup(None, b'undo.dirstate')
2735 try:
2735 try:
2736 branch = self.vfs.read(b'undo.branch')
2736 branch = self.vfs.read(b'undo.branch')
2737 self.dirstate.setbranch(encoding.tolocal(branch))
2737 self.dirstate.setbranch(encoding.tolocal(branch))
2738 except IOError:
2738 except IOError:
2739 ui.warn(
2739 ui.warn(
2740 _(
2740 _(
2741 b'named branch could not be reset: '
2741 b'named branch could not be reset: '
2742 b'current branch is still \'%s\'\n'
2742 b'current branch is still \'%s\'\n'
2743 )
2743 )
2744 % self.dirstate.branch()
2744 % self.dirstate.branch()
2745 )
2745 )
2746
2746
2747 parents = tuple([p.rev() for p in self[None].parents()])
2747 parents = tuple([p.rev() for p in self[None].parents()])
2748 if len(parents) > 1:
2748 if len(parents) > 1:
2749 ui.status(
2749 ui.status(
2750 _(
2750 _(
2751 b'working directory now based on '
2751 b'working directory now based on '
2752 b'revisions %d and %d\n'
2752 b'revisions %d and %d\n'
2753 )
2753 )
2754 % parents
2754 % parents
2755 )
2755 )
2756 else:
2756 else:
2757 ui.status(
2757 ui.status(
2758 _(b'working directory now based on revision %d\n') % parents
2758 _(b'working directory now based on revision %d\n') % parents
2759 )
2759 )
2760 mergestatemod.mergestate.clean(self)
2760 mergestatemod.mergestate.clean(self)
2761
2761
2762 # TODO: if we know which new heads may result from this rollback, pass
2762 # TODO: if we know which new heads may result from this rollback, pass
2763 # them to destroy(), which will prevent the branchhead cache from being
2763 # them to destroy(), which will prevent the branchhead cache from being
2764 # invalidated.
2764 # invalidated.
2765 self.destroyed()
2765 self.destroyed()
2766 return 0
2766 return 0
2767
2767
2768 def _buildcacheupdater(self, newtransaction):
2768 def _buildcacheupdater(self, newtransaction):
2769 """called during transaction to build the callback updating cache
2769 """called during transaction to build the callback updating cache
2770
2770
2771 Lives on the repository to help extension who might want to augment
2771 Lives on the repository to help extension who might want to augment
2772 this logic. For this purpose, the created transaction is passed to the
2772 this logic. For this purpose, the created transaction is passed to the
2773 method.
2773 method.
2774 """
2774 """
2775 # we must avoid cyclic reference between repo and transaction.
2775 # we must avoid cyclic reference between repo and transaction.
2776 reporef = weakref.ref(self)
2776 reporef = weakref.ref(self)
2777
2777
2778 def updater(tr):
2778 def updater(tr):
2779 repo = reporef()
2779 repo = reporef()
2780 assert repo is not None # help pytype
2780 assert repo is not None # help pytype
2781 repo.updatecaches(tr)
2781 repo.updatecaches(tr)
2782
2782
2783 return updater
2783 return updater
2784
2784
2785 @unfilteredmethod
2785 @unfilteredmethod
2786 def updatecaches(self, tr=None, full=False, caches=None):
2786 def updatecaches(self, tr=None, full=False, caches=None):
2787 """warm appropriate caches
2787 """warm appropriate caches
2788
2788
2789 If this function is called after a transaction closed. The transaction
2789 If this function is called after a transaction closed. The transaction
2790 will be available in the 'tr' argument. This can be used to selectively
2790 will be available in the 'tr' argument. This can be used to selectively
2791 update caches relevant to the changes in that transaction.
2791 update caches relevant to the changes in that transaction.
2792
2792
2793 If 'full' is set, make sure all caches the function knows about have
2793 If 'full' is set, make sure all caches the function knows about have
2794 up-to-date data. Even the ones usually loaded more lazily.
2794 up-to-date data. Even the ones usually loaded more lazily.
2795
2795
2796 The `full` argument can take a special "post-clone" value. In this case
2796 The `full` argument can take a special "post-clone" value. In this case
2797 the cache warming is made after a clone and of the slower cache might
2797 the cache warming is made after a clone and of the slower cache might
2798 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2798 be skipped, namely the `.fnodetags` one. This argument is 5.8 specific
2799 as we plan for a cleaner way to deal with this for 5.9.
2799 as we plan for a cleaner way to deal with this for 5.9.
2800 """
2800 """
2801 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2801 if tr is not None and tr.hookargs.get(b'source') == b'strip':
2802 # During strip, many caches are invalid but
2802 # During strip, many caches are invalid but
2803 # later call to `destroyed` will refresh them.
2803 # later call to `destroyed` will refresh them.
2804 return
2804 return
2805
2805
2806 unfi = self.unfiltered()
2806 unfi = self.unfiltered()
2807
2807
2808 if full:
2808 if full:
2809 msg = (
2809 msg = (
2810 "`full` argument for `repo.updatecaches` is deprecated\n"
2810 "`full` argument for `repo.updatecaches` is deprecated\n"
2811 "(use `caches=repository.CACHE_ALL` instead)"
2811 "(use `caches=repository.CACHE_ALL` instead)"
2812 )
2812 )
2813 self.ui.deprecwarn(msg, b"5.9")
2813 self.ui.deprecwarn(msg, b"5.9")
2814 caches = repository.CACHES_ALL
2814 caches = repository.CACHES_ALL
2815 if full == b"post-clone":
2815 if full == b"post-clone":
2816 caches = repository.CACHES_POST_CLONE
2816 caches = repository.CACHES_POST_CLONE
2817 caches = repository.CACHES_ALL
2817 caches = repository.CACHES_ALL
2818 elif caches is None:
2818 elif caches is None:
2819 caches = repository.CACHES_DEFAULT
2819 caches = repository.CACHES_DEFAULT
2820
2820
2821 if repository.CACHE_BRANCHMAP_SERVED in caches:
2821 if repository.CACHE_BRANCHMAP_SERVED in caches:
2822 if tr is None or tr.changes[b'origrepolen'] < len(self):
2822 if tr is None or tr.changes[b'origrepolen'] < len(self):
2823 # accessing the 'served' branchmap should refresh all the others,
2823 # accessing the 'served' branchmap should refresh all the others,
2824 self.ui.debug(b'updating the branch cache\n')
2824 self.ui.debug(b'updating the branch cache\n')
2825 self.filtered(b'served').branchmap()
2825 self.filtered(b'served').branchmap()
2826 self.filtered(b'served.hidden').branchmap()
2826 self.filtered(b'served.hidden').branchmap()
2827
2827
2828 if repository.CACHE_CHANGELOG_CACHE in caches:
2828 if repository.CACHE_CHANGELOG_CACHE in caches:
2829 self.changelog.update_caches(transaction=tr)
2829 self.changelog.update_caches(transaction=tr)
2830
2830
2831 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2831 if repository.CACHE_MANIFESTLOG_CACHE in caches:
2832 self.manifestlog.update_caches(transaction=tr)
2832 self.manifestlog.update_caches(transaction=tr)
2833
2833
2834 if repository.CACHE_REV_BRANCH in caches:
2834 if repository.CACHE_REV_BRANCH in caches:
2835 rbc = unfi.revbranchcache()
2835 rbc = unfi.revbranchcache()
2836 for r in unfi.changelog:
2836 for r in unfi.changelog:
2837 rbc.branchinfo(r)
2837 rbc.branchinfo(r)
2838 rbc.write()
2838 rbc.write()
2839
2839
2840 if repository.CACHE_FULL_MANIFEST in caches:
2840 if repository.CACHE_FULL_MANIFEST in caches:
2841 # ensure the working copy parents are in the manifestfulltextcache
2841 # ensure the working copy parents are in the manifestfulltextcache
2842 for ctx in self[b'.'].parents():
2842 for ctx in self[b'.'].parents():
2843 ctx.manifest() # accessing the manifest is enough
2843 ctx.manifest() # accessing the manifest is enough
2844
2844
2845 if repository.CACHE_FILE_NODE_TAGS in caches:
2845 if repository.CACHE_FILE_NODE_TAGS in caches:
2846 # accessing fnode cache warms the cache
2846 # accessing fnode cache warms the cache
2847 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2847 tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs())
2848
2848
2849 if repository.CACHE_TAGS_DEFAULT in caches:
2849 if repository.CACHE_TAGS_DEFAULT in caches:
2850 # accessing tags warm the cache
2850 # accessing tags warm the cache
2851 self.tags()
2851 self.tags()
2852 if repository.CACHE_TAGS_SERVED in caches:
2852 if repository.CACHE_TAGS_SERVED in caches:
2853 self.filtered(b'served').tags()
2853 self.filtered(b'served').tags()
2854
2854
2855 if repository.CACHE_BRANCHMAP_ALL in caches:
2855 if repository.CACHE_BRANCHMAP_ALL in caches:
2856 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2856 # The CACHE_BRANCHMAP_ALL updates lazily-loaded caches immediately,
2857 # so we're forcing a write to cause these caches to be warmed up
2857 # so we're forcing a write to cause these caches to be warmed up
2858 # even if they haven't explicitly been requested yet (if they've
2858 # even if they haven't explicitly been requested yet (if they've
2859 # never been used by hg, they won't ever have been written, even if
2859 # never been used by hg, they won't ever have been written, even if
2860 # they're a subset of another kind of cache that *has* been used).
2860 # they're a subset of another kind of cache that *has* been used).
2861 for filt in repoview.filtertable.keys():
2861 for filt in repoview.filtertable.keys():
2862 filtered = self.filtered(filt)
2862 filtered = self.filtered(filt)
2863 filtered.branchmap().write(filtered)
2863 filtered.branchmap().write(filtered)
2864
2864
2865 def invalidatecaches(self):
2865 def invalidatecaches(self):
2866
2866
2867 if '_tagscache' in vars(self):
2867 if '_tagscache' in vars(self):
2868 # can't use delattr on proxy
2868 # can't use delattr on proxy
2869 del self.__dict__['_tagscache']
2869 del self.__dict__['_tagscache']
2870
2870
2871 self._branchcaches.clear()
2871 self._branchcaches.clear()
2872 self.invalidatevolatilesets()
2872 self.invalidatevolatilesets()
2873 self._sparsesignaturecache.clear()
2873 self._sparsesignaturecache.clear()
2874
2874
2875 def invalidatevolatilesets(self):
2875 def invalidatevolatilesets(self):
2876 self.filteredrevcache.clear()
2876 self.filteredrevcache.clear()
2877 obsolete.clearobscaches(self)
2877 obsolete.clearobscaches(self)
2878 self._quick_access_changeid_invalidate()
2878 self._quick_access_changeid_invalidate()
2879
2879
2880 def invalidatedirstate(self):
2880 def invalidatedirstate(self):
2881 """Invalidates the dirstate, causing the next call to dirstate
2881 """Invalidates the dirstate, causing the next call to dirstate
2882 to check if it was modified since the last time it was read,
2882 to check if it was modified since the last time it was read,
2883 rereading it if it has.
2883 rereading it if it has.
2884
2884
2885 This is different to dirstate.invalidate() that it doesn't always
2885 This is different to dirstate.invalidate() that it doesn't always
2886 rereads the dirstate. Use dirstate.invalidate() if you want to
2886 rereads the dirstate. Use dirstate.invalidate() if you want to
2887 explicitly read the dirstate again (i.e. restoring it to a previous
2887 explicitly read the dirstate again (i.e. restoring it to a previous
2888 known good state)."""
2888 known good state)."""
2889 if hasunfilteredcache(self, 'dirstate'):
2889 if hasunfilteredcache(self, 'dirstate'):
2890 for k in self.dirstate._filecache:
2890 for k in self.dirstate._filecache:
2891 try:
2891 try:
2892 delattr(self.dirstate, k)
2892 delattr(self.dirstate, k)
2893 except AttributeError:
2893 except AttributeError:
2894 pass
2894 pass
2895 delattr(self.unfiltered(), 'dirstate')
2895 delattr(self.unfiltered(), 'dirstate')
2896
2896
2897 def invalidate(self, clearfilecache=False):
2897 def invalidate(self, clearfilecache=False):
2898 """Invalidates both store and non-store parts other than dirstate
2898 """Invalidates both store and non-store parts other than dirstate
2899
2899
2900 If a transaction is running, invalidation of store is omitted,
2900 If a transaction is running, invalidation of store is omitted,
2901 because discarding in-memory changes might cause inconsistency
2901 because discarding in-memory changes might cause inconsistency
2902 (e.g. incomplete fncache causes unintentional failure, but
2902 (e.g. incomplete fncache causes unintentional failure, but
2903 redundant one doesn't).
2903 redundant one doesn't).
2904 """
2904 """
2905 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2905 unfiltered = self.unfiltered() # all file caches are stored unfiltered
2906 for k in list(self._filecache.keys()):
2906 for k in list(self._filecache.keys()):
2907 # dirstate is invalidated separately in invalidatedirstate()
2907 # dirstate is invalidated separately in invalidatedirstate()
2908 if k == b'dirstate':
2908 if k == b'dirstate':
2909 continue
2909 continue
2910 if (
2910 if (
2911 k == b'changelog'
2911 k == b'changelog'
2912 and self.currenttransaction()
2912 and self.currenttransaction()
2913 and self.changelog._delayed
2913 and self.changelog._delayed
2914 ):
2914 ):
2915 # The changelog object may store unwritten revisions. We don't
2915 # The changelog object may store unwritten revisions. We don't
2916 # want to lose them.
2916 # want to lose them.
2917 # TODO: Solve the problem instead of working around it.
2917 # TODO: Solve the problem instead of working around it.
2918 continue
2918 continue
2919
2919
2920 if clearfilecache:
2920 if clearfilecache:
2921 del self._filecache[k]
2921 del self._filecache[k]
2922 try:
2922 try:
2923 delattr(unfiltered, k)
2923 delattr(unfiltered, k)
2924 except AttributeError:
2924 except AttributeError:
2925 pass
2925 pass
2926 self.invalidatecaches()
2926 self.invalidatecaches()
2927 if not self.currenttransaction():
2927 if not self.currenttransaction():
2928 # TODO: Changing contents of store outside transaction
2928 # TODO: Changing contents of store outside transaction
2929 # causes inconsistency. We should make in-memory store
2929 # causes inconsistency. We should make in-memory store
2930 # changes detectable, and abort if changed.
2930 # changes detectable, and abort if changed.
2931 self.store.invalidatecaches()
2931 self.store.invalidatecaches()
2932
2932
2933 def invalidateall(self):
2933 def invalidateall(self):
2934 """Fully invalidates both store and non-store parts, causing the
2934 """Fully invalidates both store and non-store parts, causing the
2935 subsequent operation to reread any outside changes."""
2935 subsequent operation to reread any outside changes."""
2936 # extension should hook this to invalidate its caches
2936 # extension should hook this to invalidate its caches
2937 self.invalidate()
2937 self.invalidate()
2938 self.invalidatedirstate()
2938 self.invalidatedirstate()
2939
2939
2940 @unfilteredmethod
2940 @unfilteredmethod
2941 def _refreshfilecachestats(self, tr):
2941 def _refreshfilecachestats(self, tr):
2942 """Reload stats of cached files so that they are flagged as valid"""
2942 """Reload stats of cached files so that they are flagged as valid"""
2943 for k, ce in self._filecache.items():
2943 for k, ce in self._filecache.items():
2944 k = pycompat.sysstr(k)
2944 k = pycompat.sysstr(k)
2945 if k == 'dirstate' or k not in self.__dict__:
2945 if k == 'dirstate' or k not in self.__dict__:
2946 continue
2946 continue
2947 ce.refresh()
2947 ce.refresh()
2948
2948
2949 def _lock(
2949 def _lock(
2950 self,
2950 self,
2951 vfs,
2951 vfs,
2952 lockname,
2952 lockname,
2953 wait,
2953 wait,
2954 releasefn,
2954 releasefn,
2955 acquirefn,
2955 acquirefn,
2956 desc,
2956 desc,
2957 ):
2957 ):
2958 timeout = 0
2958 timeout = 0
2959 warntimeout = 0
2959 warntimeout = 0
2960 if wait:
2960 if wait:
2961 timeout = self.ui.configint(b"ui", b"timeout")
2961 timeout = self.ui.configint(b"ui", b"timeout")
2962 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2962 warntimeout = self.ui.configint(b"ui", b"timeout.warn")
2963 # internal config: ui.signal-safe-lock
2963 # internal config: ui.signal-safe-lock
2964 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2964 signalsafe = self.ui.configbool(b'ui', b'signal-safe-lock')
2965
2965
2966 l = lockmod.trylock(
2966 l = lockmod.trylock(
2967 self.ui,
2967 self.ui,
2968 vfs,
2968 vfs,
2969 lockname,
2969 lockname,
2970 timeout,
2970 timeout,
2971 warntimeout,
2971 warntimeout,
2972 releasefn=releasefn,
2972 releasefn=releasefn,
2973 acquirefn=acquirefn,
2973 acquirefn=acquirefn,
2974 desc=desc,
2974 desc=desc,
2975 signalsafe=signalsafe,
2975 signalsafe=signalsafe,
2976 )
2976 )
2977 return l
2977 return l
2978
2978
2979 def _afterlock(self, callback):
2979 def _afterlock(self, callback):
2980 """add a callback to be run when the repository is fully unlocked
2980 """add a callback to be run when the repository is fully unlocked
2981
2981
2982 The callback will be executed when the outermost lock is released
2982 The callback will be executed when the outermost lock is released
2983 (with wlock being higher level than 'lock')."""
2983 (with wlock being higher level than 'lock')."""
2984 for ref in (self._wlockref, self._lockref):
2984 for ref in (self._wlockref, self._lockref):
2985 l = ref and ref()
2985 l = ref and ref()
2986 if l and l.held:
2986 if l and l.held:
2987 l.postrelease.append(callback)
2987 l.postrelease.append(callback)
2988 break
2988 break
2989 else: # no lock have been found.
2989 else: # no lock have been found.
2990 callback(True)
2990 callback(True)
2991
2991
2992 def lock(self, wait=True):
2992 def lock(self, wait=True):
2993 """Lock the repository store (.hg/store) and return a weak reference
2993 """Lock the repository store (.hg/store) and return a weak reference
2994 to the lock. Use this before modifying the store (e.g. committing or
2994 to the lock. Use this before modifying the store (e.g. committing or
2995 stripping). If you are opening a transaction, get a lock as well.)
2995 stripping). If you are opening a transaction, get a lock as well.)
2996
2996
2997 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2997 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
2998 'wlock' first to avoid a dead-lock hazard."""
2998 'wlock' first to avoid a dead-lock hazard."""
2999 l = self._currentlock(self._lockref)
2999 l = self._currentlock(self._lockref)
3000 if l is not None:
3000 if l is not None:
3001 l.lock()
3001 l.lock()
3002 return l
3002 return l
3003
3003
3004 l = self._lock(
3004 l = self._lock(
3005 vfs=self.svfs,
3005 vfs=self.svfs,
3006 lockname=b"lock",
3006 lockname=b"lock",
3007 wait=wait,
3007 wait=wait,
3008 releasefn=None,
3008 releasefn=None,
3009 acquirefn=self.invalidate,
3009 acquirefn=self.invalidate,
3010 desc=_(b'repository %s') % self.origroot,
3010 desc=_(b'repository %s') % self.origroot,
3011 )
3011 )
3012 self._lockref = weakref.ref(l)
3012 self._lockref = weakref.ref(l)
3013 return l
3013 return l
3014
3014
3015 def wlock(self, wait=True):
3015 def wlock(self, wait=True):
3016 """Lock the non-store parts of the repository (everything under
3016 """Lock the non-store parts of the repository (everything under
3017 .hg except .hg/store) and return a weak reference to the lock.
3017 .hg except .hg/store) and return a weak reference to the lock.
3018
3018
3019 Use this before modifying files in .hg.
3019 Use this before modifying files in .hg.
3020
3020
3021 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3021 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
3022 'wlock' first to avoid a dead-lock hazard."""
3022 'wlock' first to avoid a dead-lock hazard."""
3023 l = self._wlockref() if self._wlockref else None
3023 l = self._wlockref() if self._wlockref else None
3024 if l is not None and l.held:
3024 if l is not None and l.held:
3025 l.lock()
3025 l.lock()
3026 return l
3026 return l
3027
3027
3028 # We do not need to check for non-waiting lock acquisition. Such
3028 # We do not need to check for non-waiting lock acquisition. Such
3029 # acquisition would not cause dead-lock as they would just fail.
3029 # acquisition would not cause dead-lock as they would just fail.
3030 if wait and (
3030 if wait and (
3031 self.ui.configbool(b'devel', b'all-warnings')
3031 self.ui.configbool(b'devel', b'all-warnings')
3032 or self.ui.configbool(b'devel', b'check-locks')
3032 or self.ui.configbool(b'devel', b'check-locks')
3033 ):
3033 ):
3034 if self._currentlock(self._lockref) is not None:
3034 if self._currentlock(self._lockref) is not None:
3035 self.ui.develwarn(b'"wlock" acquired after "lock"')
3035 self.ui.develwarn(b'"wlock" acquired after "lock"')
3036
3036
3037 def unlock():
3037 def unlock():
3038 if self.dirstate.pendingparentchange():
3038 if self.dirstate.pendingparentchange():
3039 self.dirstate.invalidate()
3039 self.dirstate.invalidate()
3040 else:
3040 else:
3041 self.dirstate.write(None)
3041 self.dirstate.write(None)
3042
3042
3043 self._filecache[b'dirstate'].refresh()
3043 self._filecache[b'dirstate'].refresh()
3044
3044
3045 l = self._lock(
3045 l = self._lock(
3046 self.vfs,
3046 self.vfs,
3047 b"wlock",
3047 b"wlock",
3048 wait,
3048 wait,
3049 unlock,
3049 unlock,
3050 self.invalidatedirstate,
3050 self.invalidatedirstate,
3051 _(b'working directory of %s') % self.origroot,
3051 _(b'working directory of %s') % self.origroot,
3052 )
3052 )
3053 self._wlockref = weakref.ref(l)
3053 self._wlockref = weakref.ref(l)
3054 return l
3054 return l
3055
3055
3056 def _currentlock(self, lockref):
3056 def _currentlock(self, lockref):
3057 """Returns the lock if it's held, or None if it's not."""
3057 """Returns the lock if it's held, or None if it's not."""
3058 if lockref is None:
3058 if lockref is None:
3059 return None
3059 return None
3060 l = lockref()
3060 l = lockref()
3061 if l is None or not l.held:
3061 if l is None or not l.held:
3062 return None
3062 return None
3063 return l
3063 return l
3064
3064
3065 def currentwlock(self):
3065 def currentwlock(self):
3066 """Returns the wlock if it's held, or None if it's not."""
3066 """Returns the wlock if it's held, or None if it's not."""
3067 return self._currentlock(self._wlockref)
3067 return self._currentlock(self._wlockref)
3068
3068
3069 def checkcommitpatterns(self, wctx, match, status, fail):
3069 def checkcommitpatterns(self, wctx, match, status, fail):
3070 """check for commit arguments that aren't committable"""
3070 """check for commit arguments that aren't committable"""
3071 if match.isexact() or match.prefix():
3071 if match.isexact() or match.prefix():
3072 matched = set(status.modified + status.added + status.removed)
3072 matched = set(status.modified + status.added + status.removed)
3073
3073
3074 for f in match.files():
3074 for f in match.files():
3075 f = self.dirstate.normalize(f)
3075 f = self.dirstate.normalize(f)
3076 if f == b'.' or f in matched or f in wctx.substate:
3076 if f == b'.' or f in matched or f in wctx.substate:
3077 continue
3077 continue
3078 if f in status.deleted:
3078 if f in status.deleted:
3079 fail(f, _(b'file not found!'))
3079 fail(f, _(b'file not found!'))
3080 # Is it a directory that exists or used to exist?
3080 # Is it a directory that exists or used to exist?
3081 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3081 if self.wvfs.isdir(f) or wctx.p1().hasdir(f):
3082 d = f + b'/'
3082 d = f + b'/'
3083 for mf in matched:
3083 for mf in matched:
3084 if mf.startswith(d):
3084 if mf.startswith(d):
3085 break
3085 break
3086 else:
3086 else:
3087 fail(f, _(b"no match under directory!"))
3087 fail(f, _(b"no match under directory!"))
3088 elif f not in self.dirstate:
3088 elif f not in self.dirstate:
3089 fail(f, _(b"file not tracked!"))
3089 fail(f, _(b"file not tracked!"))
3090
3090
3091 @unfilteredmethod
3091 @unfilteredmethod
3092 def commit(
3092 def commit(
3093 self,
3093 self,
3094 text=b"",
3094 text=b"",
3095 user=None,
3095 user=None,
3096 date=None,
3096 date=None,
3097 match=None,
3097 match=None,
3098 force=False,
3098 force=False,
3099 editor=None,
3099 editor=None,
3100 extra=None,
3100 extra=None,
3101 ):
3101 ):
3102 """Add a new revision to current repository.
3102 """Add a new revision to current repository.
3103
3103
3104 Revision information is gathered from the working directory,
3104 Revision information is gathered from the working directory,
3105 match can be used to filter the committed files. If editor is
3105 match can be used to filter the committed files. If editor is
3106 supplied, it is called to get a commit message.
3106 supplied, it is called to get a commit message.
3107 """
3107 """
3108 if extra is None:
3108 if extra is None:
3109 extra = {}
3109 extra = {}
3110
3110
3111 def fail(f, msg):
3111 def fail(f, msg):
3112 raise error.InputError(b'%s: %s' % (f, msg))
3112 raise error.InputError(b'%s: %s' % (f, msg))
3113
3113
3114 if not match:
3114 if not match:
3115 match = matchmod.always()
3115 match = matchmod.always()
3116
3116
3117 if not force:
3117 if not force:
3118 match.bad = fail
3118 match.bad = fail
3119
3119
3120 # lock() for recent changelog (see issue4368)
3120 # lock() for recent changelog (see issue4368)
3121 with self.wlock(), self.lock():
3121 with self.wlock(), self.lock():
3122 wctx = self[None]
3122 wctx = self[None]
3123 merge = len(wctx.parents()) > 1
3123 merge = len(wctx.parents()) > 1
3124
3124
3125 if not force and merge and not match.always():
3125 if not force and merge and not match.always():
3126 raise error.Abort(
3126 raise error.Abort(
3127 _(
3127 _(
3128 b'cannot partially commit a merge '
3128 b'cannot partially commit a merge '
3129 b'(do not specify files or patterns)'
3129 b'(do not specify files or patterns)'
3130 )
3130 )
3131 )
3131 )
3132
3132
3133 status = self.status(match=match, clean=force)
3133 status = self.status(match=match, clean=force)
3134 if force:
3134 if force:
3135 status.modified.extend(
3135 status.modified.extend(
3136 status.clean
3136 status.clean
3137 ) # mq may commit clean files
3137 ) # mq may commit clean files
3138
3138
3139 # check subrepos
3139 # check subrepos
3140 subs, commitsubs, newstate = subrepoutil.precommit(
3140 subs, commitsubs, newstate = subrepoutil.precommit(
3141 self.ui, wctx, status, match, force=force
3141 self.ui, wctx, status, match, force=force
3142 )
3142 )
3143
3143
3144 # make sure all explicit patterns are matched
3144 # make sure all explicit patterns are matched
3145 if not force:
3145 if not force:
3146 self.checkcommitpatterns(wctx, match, status, fail)
3146 self.checkcommitpatterns(wctx, match, status, fail)
3147
3147
3148 cctx = context.workingcommitctx(
3148 cctx = context.workingcommitctx(
3149 self, status, text, user, date, extra
3149 self, status, text, user, date, extra
3150 )
3150 )
3151
3151
3152 ms = mergestatemod.mergestate.read(self)
3152 ms = mergestatemod.mergestate.read(self)
3153 mergeutil.checkunresolved(ms)
3153 mergeutil.checkunresolved(ms)
3154
3154
3155 # internal config: ui.allowemptycommit
3155 # internal config: ui.allowemptycommit
3156 if cctx.isempty() and not self.ui.configbool(
3156 if cctx.isempty() and not self.ui.configbool(
3157 b'ui', b'allowemptycommit'
3157 b'ui', b'allowemptycommit'
3158 ):
3158 ):
3159 self.ui.debug(b'nothing to commit, clearing merge state\n')
3159 self.ui.debug(b'nothing to commit, clearing merge state\n')
3160 ms.reset()
3160 ms.reset()
3161 return None
3161 return None
3162
3162
3163 if merge and cctx.deleted():
3163 if merge and cctx.deleted():
3164 raise error.Abort(_(b"cannot commit merge with missing files"))
3164 raise error.Abort(_(b"cannot commit merge with missing files"))
3165
3165
3166 if editor:
3166 if editor:
3167 cctx._text = editor(self, cctx, subs)
3167 cctx._text = editor(self, cctx, subs)
3168 edited = text != cctx._text
3168 edited = text != cctx._text
3169
3169
3170 # Save commit message in case this transaction gets rolled back
3170 # Save commit message in case this transaction gets rolled back
3171 # (e.g. by a pretxncommit hook). Leave the content alone on
3171 # (e.g. by a pretxncommit hook). Leave the content alone on
3172 # the assumption that the user will use the same editor again.
3172 # the assumption that the user will use the same editor again.
3173 msgfn = self.savecommitmessage(cctx._text)
3173 msgfn = self.savecommitmessage(cctx._text)
3174
3174
3175 # commit subs and write new state
3175 # commit subs and write new state
3176 if subs:
3176 if subs:
3177 uipathfn = scmutil.getuipathfn(self)
3177 uipathfn = scmutil.getuipathfn(self)
3178 for s in sorted(commitsubs):
3178 for s in sorted(commitsubs):
3179 sub = wctx.sub(s)
3179 sub = wctx.sub(s)
3180 self.ui.status(
3180 self.ui.status(
3181 _(b'committing subrepository %s\n')
3181 _(b'committing subrepository %s\n')
3182 % uipathfn(subrepoutil.subrelpath(sub))
3182 % uipathfn(subrepoutil.subrelpath(sub))
3183 )
3183 )
3184 sr = sub.commit(cctx._text, user, date)
3184 sr = sub.commit(cctx._text, user, date)
3185 newstate[s] = (newstate[s][0], sr)
3185 newstate[s] = (newstate[s][0], sr)
3186 subrepoutil.writestate(self, newstate)
3186 subrepoutil.writestate(self, newstate)
3187
3187
3188 p1, p2 = self.dirstate.parents()
3188 p1, p2 = self.dirstate.parents()
3189 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3189 hookp1, hookp2 = hex(p1), (p2 != self.nullid and hex(p2) or b'')
3190 try:
3190 try:
3191 self.hook(
3191 self.hook(
3192 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3192 b"precommit", throw=True, parent1=hookp1, parent2=hookp2
3193 )
3193 )
3194 with self.transaction(b'commit'):
3194 with self.transaction(b'commit'):
3195 ret = self.commitctx(cctx, True)
3195 ret = self.commitctx(cctx, True)
3196 # update bookmarks, dirstate and mergestate
3196 # update bookmarks, dirstate and mergestate
3197 bookmarks.update(self, [p1, p2], ret)
3197 bookmarks.update(self, [p1, p2], ret)
3198 cctx.markcommitted(ret)
3198 cctx.markcommitted(ret)
3199 ms.reset()
3199 ms.reset()
3200 except: # re-raises
3200 except: # re-raises
3201 if edited:
3201 if edited:
3202 self.ui.write(
3202 self.ui.write(
3203 _(b'note: commit message saved in %s\n') % msgfn
3203 _(b'note: commit message saved in %s\n') % msgfn
3204 )
3204 )
3205 self.ui.write(
3205 self.ui.write(
3206 _(
3206 _(
3207 b"note: use 'hg commit --logfile "
3207 b"note: use 'hg commit --logfile "
3208 b".hg/last-message.txt --edit' to reuse it\n"
3208 b".hg/last-message.txt --edit' to reuse it\n"
3209 )
3209 )
3210 )
3210 )
3211 raise
3211 raise
3212
3212
3213 def commithook(unused_success):
3213 def commithook(unused_success):
3214 # hack for command that use a temporary commit (eg: histedit)
3214 # hack for command that use a temporary commit (eg: histedit)
3215 # temporary commit got stripped before hook release
3215 # temporary commit got stripped before hook release
3216 if self.changelog.hasnode(ret):
3216 if self.changelog.hasnode(ret):
3217 self.hook(
3217 self.hook(
3218 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3218 b"commit", node=hex(ret), parent1=hookp1, parent2=hookp2
3219 )
3219 )
3220
3220
3221 self._afterlock(commithook)
3221 self._afterlock(commithook)
3222 return ret
3222 return ret
3223
3223
3224 @unfilteredmethod
3224 @unfilteredmethod
3225 def commitctx(self, ctx, error=False, origctx=None):
3225 def commitctx(self, ctx, error=False, origctx=None):
3226 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3226 return commit.commitctx(self, ctx, error=error, origctx=origctx)
3227
3227
3228 @unfilteredmethod
3228 @unfilteredmethod
3229 def destroying(self):
3229 def destroying(self):
3230 """Inform the repository that nodes are about to be destroyed.
3230 """Inform the repository that nodes are about to be destroyed.
3231 Intended for use by strip and rollback, so there's a common
3231 Intended for use by strip and rollback, so there's a common
3232 place for anything that has to be done before destroying history.
3232 place for anything that has to be done before destroying history.
3233
3233
3234 This is mostly useful for saving state that is in memory and waiting
3234 This is mostly useful for saving state that is in memory and waiting
3235 to be flushed when the current lock is released. Because a call to
3235 to be flushed when the current lock is released. Because a call to
3236 destroyed is imminent, the repo will be invalidated causing those
3236 destroyed is imminent, the repo will be invalidated causing those
3237 changes to stay in memory (waiting for the next unlock), or vanish
3237 changes to stay in memory (waiting for the next unlock), or vanish
3238 completely.
3238 completely.
3239 """
3239 """
3240 # When using the same lock to commit and strip, the phasecache is left
3240 # When using the same lock to commit and strip, the phasecache is left
3241 # dirty after committing. Then when we strip, the repo is invalidated,
3241 # dirty after committing. Then when we strip, the repo is invalidated,
3242 # causing those changes to disappear.
3242 # causing those changes to disappear.
3243 if '_phasecache' in vars(self):
3243 if '_phasecache' in vars(self):
3244 self._phasecache.write()
3244 self._phasecache.write()
3245
3245
3246 @unfilteredmethod
3246 @unfilteredmethod
3247 def destroyed(self):
3247 def destroyed(self):
3248 """Inform the repository that nodes have been destroyed.
3248 """Inform the repository that nodes have been destroyed.
3249 Intended for use by strip and rollback, so there's a common
3249 Intended for use by strip and rollback, so there's a common
3250 place for anything that has to be done after destroying history.
3250 place for anything that has to be done after destroying history.
3251 """
3251 """
3252 # When one tries to:
3252 # When one tries to:
3253 # 1) destroy nodes thus calling this method (e.g. strip)
3253 # 1) destroy nodes thus calling this method (e.g. strip)
3254 # 2) use phasecache somewhere (e.g. commit)
3254 # 2) use phasecache somewhere (e.g. commit)
3255 #
3255 #
3256 # then 2) will fail because the phasecache contains nodes that were
3256 # then 2) will fail because the phasecache contains nodes that were
3257 # removed. We can either remove phasecache from the filecache,
3257 # removed. We can either remove phasecache from the filecache,
3258 # causing it to reload next time it is accessed, or simply filter
3258 # causing it to reload next time it is accessed, or simply filter
3259 # the removed nodes now and write the updated cache.
3259 # the removed nodes now and write the updated cache.
3260 self._phasecache.filterunknown(self)
3260 self._phasecache.filterunknown(self)
3261 self._phasecache.write()
3261 self._phasecache.write()
3262
3262
3263 # refresh all repository caches
3263 # refresh all repository caches
3264 self.updatecaches()
3264 self.updatecaches()
3265
3265
3266 # Ensure the persistent tag cache is updated. Doing it now
3266 # Ensure the persistent tag cache is updated. Doing it now
3267 # means that the tag cache only has to worry about destroyed
3267 # means that the tag cache only has to worry about destroyed
3268 # heads immediately after a strip/rollback. That in turn
3268 # heads immediately after a strip/rollback. That in turn
3269 # guarantees that "cachetip == currenttip" (comparing both rev
3269 # guarantees that "cachetip == currenttip" (comparing both rev
3270 # and node) always means no nodes have been added or destroyed.
3270 # and node) always means no nodes have been added or destroyed.
3271
3271
3272 # XXX this is suboptimal when qrefresh'ing: we strip the current
3272 # XXX this is suboptimal when qrefresh'ing: we strip the current
3273 # head, refresh the tag cache, then immediately add a new head.
3273 # head, refresh the tag cache, then immediately add a new head.
3274 # But I think doing it this way is necessary for the "instant
3274 # But I think doing it this way is necessary for the "instant
3275 # tag cache retrieval" case to work.
3275 # tag cache retrieval" case to work.
3276 self.invalidate()
3276 self.invalidate()
3277
3277
3278 def status(
3278 def status(
3279 self,
3279 self,
3280 node1=b'.',
3280 node1=b'.',
3281 node2=None,
3281 node2=None,
3282 match=None,
3282 match=None,
3283 ignored=False,
3283 ignored=False,
3284 clean=False,
3284 clean=False,
3285 unknown=False,
3285 unknown=False,
3286 listsubrepos=False,
3286 listsubrepos=False,
3287 ):
3287 ):
3288 '''a convenience method that calls node1.status(node2)'''
3288 '''a convenience method that calls node1.status(node2)'''
3289 return self[node1].status(
3289 return self[node1].status(
3290 node2, match, ignored, clean, unknown, listsubrepos
3290 node2, match, ignored, clean, unknown, listsubrepos
3291 )
3291 )
3292
3292
3293 def addpostdsstatus(self, ps):
3293 def addpostdsstatus(self, ps):
3294 """Add a callback to run within the wlock, at the point at which status
3294 """Add a callback to run within the wlock, at the point at which status
3295 fixups happen.
3295 fixups happen.
3296
3296
3297 On status completion, callback(wctx, status) will be called with the
3297 On status completion, callback(wctx, status) will be called with the
3298 wlock held, unless the dirstate has changed from underneath or the wlock
3298 wlock held, unless the dirstate has changed from underneath or the wlock
3299 couldn't be grabbed.
3299 couldn't be grabbed.
3300
3300
3301 Callbacks should not capture and use a cached copy of the dirstate --
3301 Callbacks should not capture and use a cached copy of the dirstate --
3302 it might change in the meanwhile. Instead, they should access the
3302 it might change in the meanwhile. Instead, they should access the
3303 dirstate via wctx.repo().dirstate.
3303 dirstate via wctx.repo().dirstate.
3304
3304
3305 This list is emptied out after each status run -- extensions should
3305 This list is emptied out after each status run -- extensions should
3306 make sure it adds to this list each time dirstate.status is called.
3306 make sure it adds to this list each time dirstate.status is called.
3307 Extensions should also make sure they don't call this for statuses
3307 Extensions should also make sure they don't call this for statuses
3308 that don't involve the dirstate.
3308 that don't involve the dirstate.
3309 """
3309 """
3310
3310
3311 # The list is located here for uniqueness reasons -- it is actually
3311 # The list is located here for uniqueness reasons -- it is actually
3312 # managed by the workingctx, but that isn't unique per-repo.
3312 # managed by the workingctx, but that isn't unique per-repo.
3313 self._postdsstatus.append(ps)
3313 self._postdsstatus.append(ps)
3314
3314
3315 def postdsstatus(self):
3315 def postdsstatus(self):
3316 """Used by workingctx to get the list of post-dirstate-status hooks."""
3316 """Used by workingctx to get the list of post-dirstate-status hooks."""
3317 return self._postdsstatus
3317 return self._postdsstatus
3318
3318
3319 def clearpostdsstatus(self):
3319 def clearpostdsstatus(self):
3320 """Used by workingctx to clear post-dirstate-status hooks."""
3320 """Used by workingctx to clear post-dirstate-status hooks."""
3321 del self._postdsstatus[:]
3321 del self._postdsstatus[:]
3322
3322
3323 def heads(self, start=None):
3323 def heads(self, start=None):
3324 if start is None:
3324 if start is None:
3325 cl = self.changelog
3325 cl = self.changelog
3326 headrevs = reversed(cl.headrevs())
3326 headrevs = reversed(cl.headrevs())
3327 return [cl.node(rev) for rev in headrevs]
3327 return [cl.node(rev) for rev in headrevs]
3328
3328
3329 heads = self.changelog.heads(start)
3329 heads = self.changelog.heads(start)
3330 # sort the output in rev descending order
3330 # sort the output in rev descending order
3331 return sorted(heads, key=self.changelog.rev, reverse=True)
3331 return sorted(heads, key=self.changelog.rev, reverse=True)
3332
3332
3333 def branchheads(self, branch=None, start=None, closed=False):
3333 def branchheads(self, branch=None, start=None, closed=False):
3334 """return a (possibly filtered) list of heads for the given branch
3334 """return a (possibly filtered) list of heads for the given branch
3335
3335
3336 Heads are returned in topological order, from newest to oldest.
3336 Heads are returned in topological order, from newest to oldest.
3337 If branch is None, use the dirstate branch.
3337 If branch is None, use the dirstate branch.
3338 If start is not None, return only heads reachable from start.
3338 If start is not None, return only heads reachable from start.
3339 If closed is True, return heads that are marked as closed as well.
3339 If closed is True, return heads that are marked as closed as well.
3340 """
3340 """
3341 if branch is None:
3341 if branch is None:
3342 branch = self[None].branch()
3342 branch = self[None].branch()
3343 branches = self.branchmap()
3343 branches = self.branchmap()
3344 if not branches.hasbranch(branch):
3344 if not branches.hasbranch(branch):
3345 return []
3345 return []
3346 # the cache returns heads ordered lowest to highest
3346 # the cache returns heads ordered lowest to highest
3347 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3347 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
3348 if start is not None:
3348 if start is not None:
3349 # filter out the heads that cannot be reached from startrev
3349 # filter out the heads that cannot be reached from startrev
3350 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3350 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
3351 bheads = [h for h in bheads if h in fbheads]
3351 bheads = [h for h in bheads if h in fbheads]
3352 return bheads
3352 return bheads
3353
3353
3354 def branches(self, nodes):
3354 def branches(self, nodes):
3355 if not nodes:
3355 if not nodes:
3356 nodes = [self.changelog.tip()]
3356 nodes = [self.changelog.tip()]
3357 b = []
3357 b = []
3358 for n in nodes:
3358 for n in nodes:
3359 t = n
3359 t = n
3360 while True:
3360 while True:
3361 p = self.changelog.parents(n)
3361 p = self.changelog.parents(n)
3362 if p[1] != self.nullid or p[0] == self.nullid:
3362 if p[1] != self.nullid or p[0] == self.nullid:
3363 b.append((t, n, p[0], p[1]))
3363 b.append((t, n, p[0], p[1]))
3364 break
3364 break
3365 n = p[0]
3365 n = p[0]
3366 return b
3366 return b
3367
3367
3368 def between(self, pairs):
3368 def between(self, pairs):
3369 r = []
3369 r = []
3370
3370
3371 for top, bottom in pairs:
3371 for top, bottom in pairs:
3372 n, l, i = top, [], 0
3372 n, l, i = top, [], 0
3373 f = 1
3373 f = 1
3374
3374
3375 while n != bottom and n != self.nullid:
3375 while n != bottom and n != self.nullid:
3376 p = self.changelog.parents(n)[0]
3376 p = self.changelog.parents(n)[0]
3377 if i == f:
3377 if i == f:
3378 l.append(n)
3378 l.append(n)
3379 f = f * 2
3379 f = f * 2
3380 n = p
3380 n = p
3381 i += 1
3381 i += 1
3382
3382
3383 r.append(l)
3383 r.append(l)
3384
3384
3385 return r
3385 return r
3386
3386
3387 def checkpush(self, pushop):
3387 def checkpush(self, pushop):
3388 """Extensions can override this function if additional checks have
3388 """Extensions can override this function if additional checks have
3389 to be performed before pushing, or call it if they override push
3389 to be performed before pushing, or call it if they override push
3390 command.
3390 command.
3391 """
3391 """
3392
3392
3393 @unfilteredpropertycache
3393 @unfilteredpropertycache
3394 def prepushoutgoinghooks(self):
3394 def prepushoutgoinghooks(self):
3395 """Return util.hooks consists of a pushop with repo, remote, outgoing
3395 """Return util.hooks consists of a pushop with repo, remote, outgoing
3396 methods, which are called before pushing changesets.
3396 methods, which are called before pushing changesets.
3397 """
3397 """
3398 return util.hooks()
3398 return util.hooks()
3399
3399
3400 def pushkey(self, namespace, key, old, new):
3400 def pushkey(self, namespace, key, old, new):
3401 try:
3401 try:
3402 tr = self.currenttransaction()
3402 tr = self.currenttransaction()
3403 hookargs = {}
3403 hookargs = {}
3404 if tr is not None:
3404 if tr is not None:
3405 hookargs.update(tr.hookargs)
3405 hookargs.update(tr.hookargs)
3406 hookargs = pycompat.strkwargs(hookargs)
3406 hookargs = pycompat.strkwargs(hookargs)
3407 hookargs['namespace'] = namespace
3407 hookargs['namespace'] = namespace
3408 hookargs['key'] = key
3408 hookargs['key'] = key
3409 hookargs['old'] = old
3409 hookargs['old'] = old
3410 hookargs['new'] = new
3410 hookargs['new'] = new
3411 self.hook(b'prepushkey', throw=True, **hookargs)
3411 self.hook(b'prepushkey', throw=True, **hookargs)
3412 except error.HookAbort as exc:
3412 except error.HookAbort as exc:
3413 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3413 self.ui.write_err(_(b"pushkey-abort: %s\n") % exc)
3414 if exc.hint:
3414 if exc.hint:
3415 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3415 self.ui.write_err(_(b"(%s)\n") % exc.hint)
3416 return False
3416 return False
3417 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3417 self.ui.debug(b'pushing key for "%s:%s"\n' % (namespace, key))
3418 ret = pushkey.push(self, namespace, key, old, new)
3418 ret = pushkey.push(self, namespace, key, old, new)
3419
3419
3420 def runhook(unused_success):
3420 def runhook(unused_success):
3421 self.hook(
3421 self.hook(
3422 b'pushkey',
3422 b'pushkey',
3423 namespace=namespace,
3423 namespace=namespace,
3424 key=key,
3424 key=key,
3425 old=old,
3425 old=old,
3426 new=new,
3426 new=new,
3427 ret=ret,
3427 ret=ret,
3428 )
3428 )
3429
3429
3430 self._afterlock(runhook)
3430 self._afterlock(runhook)
3431 return ret
3431 return ret
3432
3432
3433 def listkeys(self, namespace):
3433 def listkeys(self, namespace):
3434 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3434 self.hook(b'prelistkeys', throw=True, namespace=namespace)
3435 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3435 self.ui.debug(b'listing keys for "%s"\n' % namespace)
3436 values = pushkey.list(self, namespace)
3436 values = pushkey.list(self, namespace)
3437 self.hook(b'listkeys', namespace=namespace, values=values)
3437 self.hook(b'listkeys', namespace=namespace, values=values)
3438 return values
3438 return values
3439
3439
3440 def debugwireargs(self, one, two, three=None, four=None, five=None):
3440 def debugwireargs(self, one, two, three=None, four=None, five=None):
3441 '''used to test argument passing over the wire'''
3441 '''used to test argument passing over the wire'''
3442 return b"%s %s %s %s %s" % (
3442 return b"%s %s %s %s %s" % (
3443 one,
3443 one,
3444 two,
3444 two,
3445 pycompat.bytestr(three),
3445 pycompat.bytestr(three),
3446 pycompat.bytestr(four),
3446 pycompat.bytestr(four),
3447 pycompat.bytestr(five),
3447 pycompat.bytestr(five),
3448 )
3448 )
3449
3449
3450 def savecommitmessage(self, text):
3450 def savecommitmessage(self, text):
3451 fp = self.vfs(b'last-message.txt', b'wb')
3451 fp = self.vfs(b'last-message.txt', b'wb')
3452 try:
3452 try:
3453 fp.write(text)
3453 fp.write(text)
3454 finally:
3454 finally:
3455 fp.close()
3455 fp.close()
3456 return self.pathto(fp.name[len(self.root) + 1 :])
3456 return self.pathto(fp.name[len(self.root) + 1 :])
3457
3457
3458 def register_wanted_sidedata(self, category):
3458 def register_wanted_sidedata(self, category):
3459 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3459 if repository.REPO_FEATURE_SIDE_DATA not in self.features:
3460 # Only revlogv2 repos can want sidedata.
3460 # Only revlogv2 repos can want sidedata.
3461 return
3461 return
3462 self._wanted_sidedata.add(pycompat.bytestr(category))
3462 self._wanted_sidedata.add(pycompat.bytestr(category))
3463
3463
3464 def register_sidedata_computer(
3464 def register_sidedata_computer(
3465 self, kind, category, keys, computer, flags, replace=False
3465 self, kind, category, keys, computer, flags, replace=False
3466 ):
3466 ):
3467 if kind not in revlogconst.ALL_KINDS:
3467 if kind not in revlogconst.ALL_KINDS:
3468 msg = _(b"unexpected revlog kind '%s'.")
3468 msg = _(b"unexpected revlog kind '%s'.")
3469 raise error.ProgrammingError(msg % kind)
3469 raise error.ProgrammingError(msg % kind)
3470 category = pycompat.bytestr(category)
3470 category = pycompat.bytestr(category)
3471 already_registered = category in self._sidedata_computers.get(kind, [])
3471 already_registered = category in self._sidedata_computers.get(kind, [])
3472 if already_registered and not replace:
3472 if already_registered and not replace:
3473 msg = _(
3473 msg = _(
3474 b"cannot register a sidedata computer twice for category '%s'."
3474 b"cannot register a sidedata computer twice for category '%s'."
3475 )
3475 )
3476 raise error.ProgrammingError(msg % category)
3476 raise error.ProgrammingError(msg % category)
3477 if replace and not already_registered:
3477 if replace and not already_registered:
3478 msg = _(
3478 msg = _(
3479 b"cannot replace a sidedata computer that isn't registered "
3479 b"cannot replace a sidedata computer that isn't registered "
3480 b"for category '%s'."
3480 b"for category '%s'."
3481 )
3481 )
3482 raise error.ProgrammingError(msg % category)
3482 raise error.ProgrammingError(msg % category)
3483 self._sidedata_computers.setdefault(kind, {})
3483 self._sidedata_computers.setdefault(kind, {})
3484 self._sidedata_computers[kind][category] = (keys, computer, flags)
3484 self._sidedata_computers[kind][category] = (keys, computer, flags)
3485
3485
3486
3486
3487 # used to avoid circular references so destructors work
3487 # used to avoid circular references so destructors work
3488 def aftertrans(files):
3488 def aftertrans(files):
3489 renamefiles = [tuple(t) for t in files]
3489 renamefiles = [tuple(t) for t in files]
3490
3490
3491 def a():
3491 def a():
3492 for vfs, src, dest in renamefiles:
3492 for vfs, src, dest in renamefiles:
3493 # if src and dest refer to a same file, vfs.rename is a no-op,
3493 # if src and dest refer to a same file, vfs.rename is a no-op,
3494 # leaving both src and dest on disk. delete dest to make sure
3494 # leaving both src and dest on disk. delete dest to make sure
3495 # the rename couldn't be such a no-op.
3495 # the rename couldn't be such a no-op.
3496 vfs.tryunlink(dest)
3496 vfs.tryunlink(dest)
3497 try:
3497 try:
3498 vfs.rename(src, dest)
3498 vfs.rename(src, dest)
3499 except OSError as exc: # journal file does not yet exist
3499 except OSError as exc: # journal file does not yet exist
3500 if exc.errno != errno.ENOENT:
3500 if exc.errno != errno.ENOENT:
3501 raise
3501 raise
3502
3502
3503 return a
3503 return a
3504
3504
3505
3505
3506 def undoname(fn):
3506 def undoname(fn):
3507 base, name = os.path.split(fn)
3507 base, name = os.path.split(fn)
3508 assert name.startswith(b'journal')
3508 assert name.startswith(b'journal')
3509 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3509 return os.path.join(base, name.replace(b'journal', b'undo', 1))
3510
3510
3511
3511
3512 def instance(ui, path, create, intents=None, createopts=None):
3512 def instance(ui, path, create, intents=None, createopts=None):
3513 localpath = urlutil.urllocalpath(path)
3513 localpath = urlutil.urllocalpath(path)
3514 if create:
3514 if create:
3515 createrepository(ui, localpath, createopts=createopts)
3515 createrepository(ui, localpath, createopts=createopts)
3516
3516
3517 return makelocalrepository(ui, localpath, intents=intents)
3517 return makelocalrepository(ui, localpath, intents=intents)
3518
3518
3519
3519
3520 def islocal(path):
3520 def islocal(path):
3521 return True
3521 return True
3522
3522
3523
3523
3524 def defaultcreateopts(ui, createopts=None):
3524 def defaultcreateopts(ui, createopts=None):
3525 """Populate the default creation options for a repository.
3525 """Populate the default creation options for a repository.
3526
3526
3527 A dictionary of explicitly requested creation options can be passed
3527 A dictionary of explicitly requested creation options can be passed
3528 in. Missing keys will be populated.
3528 in. Missing keys will be populated.
3529 """
3529 """
3530 createopts = dict(createopts or {})
3530 createopts = dict(createopts or {})
3531
3531
3532 if b'backend' not in createopts:
3532 if b'backend' not in createopts:
3533 # experimental config: storage.new-repo-backend
3533 # experimental config: storage.new-repo-backend
3534 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3534 createopts[b'backend'] = ui.config(b'storage', b'new-repo-backend')
3535
3535
3536 return createopts
3536 return createopts
3537
3537
3538
3538
3539 def clone_requirements(ui, createopts, srcrepo):
3539 def clone_requirements(ui, createopts, srcrepo):
3540 """clone the requirements of a local repo for a local clone
3540 """clone the requirements of a local repo for a local clone
3541
3541
3542 The store requirements are unchanged while the working copy requirements
3542 The store requirements are unchanged while the working copy requirements
3543 depends on the configuration
3543 depends on the configuration
3544 """
3544 """
3545 target_requirements = set()
3545 target_requirements = set()
3546 createopts = defaultcreateopts(ui, createopts=createopts)
3546 createopts = defaultcreateopts(ui, createopts=createopts)
3547 for r in newreporequirements(ui, createopts):
3547 for r in newreporequirements(ui, createopts):
3548 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3548 if r in requirementsmod.WORKING_DIR_REQUIREMENTS:
3549 target_requirements.add(r)
3549 target_requirements.add(r)
3550
3550
3551 for r in srcrepo.requirements:
3551 for r in srcrepo.requirements:
3552 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3552 if r not in requirementsmod.WORKING_DIR_REQUIREMENTS:
3553 target_requirements.add(r)
3553 target_requirements.add(r)
3554 return target_requirements
3554 return target_requirements
3555
3555
3556
3556
3557 def newreporequirements(ui, createopts):
3557 def newreporequirements(ui, createopts):
3558 """Determine the set of requirements for a new local repository.
3558 """Determine the set of requirements for a new local repository.
3559
3559
3560 Extensions can wrap this function to specify custom requirements for
3560 Extensions can wrap this function to specify custom requirements for
3561 new repositories.
3561 new repositories.
3562 """
3562 """
3563
3563
3564 if b'backend' not in createopts:
3564 if b'backend' not in createopts:
3565 raise error.ProgrammingError(
3565 raise error.ProgrammingError(
3566 b'backend key not present in createopts; '
3566 b'backend key not present in createopts; '
3567 b'was defaultcreateopts() called?'
3567 b'was defaultcreateopts() called?'
3568 )
3568 )
3569
3569
3570 if createopts[b'backend'] != b'revlogv1':
3570 if createopts[b'backend'] != b'revlogv1':
3571 raise error.Abort(
3571 raise error.Abort(
3572 _(
3572 _(
3573 b'unable to determine repository requirements for '
3573 b'unable to determine repository requirements for '
3574 b'storage backend: %s'
3574 b'storage backend: %s'
3575 )
3575 )
3576 % createopts[b'backend']
3576 % createopts[b'backend']
3577 )
3577 )
3578
3578
3579 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3579 requirements = {requirementsmod.REVLOGV1_REQUIREMENT}
3580 if ui.configbool(b'format', b'usestore'):
3580 if ui.configbool(b'format', b'usestore'):
3581 requirements.add(requirementsmod.STORE_REQUIREMENT)
3581 requirements.add(requirementsmod.STORE_REQUIREMENT)
3582 if ui.configbool(b'format', b'usefncache'):
3582 if ui.configbool(b'format', b'usefncache'):
3583 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3583 requirements.add(requirementsmod.FNCACHE_REQUIREMENT)
3584 if ui.configbool(b'format', b'dotencode'):
3584 if ui.configbool(b'format', b'dotencode'):
3585 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3585 requirements.add(requirementsmod.DOTENCODE_REQUIREMENT)
3586
3586
3587 compengines = ui.configlist(b'format', b'revlog-compression')
3587 compengines = ui.configlist(b'format', b'revlog-compression')
3588 for compengine in compengines:
3588 for compengine in compengines:
3589 if compengine in util.compengines:
3589 if compengine in util.compengines:
3590 engine = util.compengines[compengine]
3590 engine = util.compengines[compengine]
3591 if engine.available() and engine.revlogheader():
3591 if engine.available() and engine.revlogheader():
3592 break
3592 break
3593 else:
3593 else:
3594 raise error.Abort(
3594 raise error.Abort(
3595 _(
3595 _(
3596 b'compression engines %s defined by '
3596 b'compression engines %s defined by '
3597 b'format.revlog-compression not available'
3597 b'format.revlog-compression not available'
3598 )
3598 )
3599 % b', '.join(b'"%s"' % e for e in compengines),
3599 % b', '.join(b'"%s"' % e for e in compengines),
3600 hint=_(
3600 hint=_(
3601 b'run "hg debuginstall" to list available '
3601 b'run "hg debuginstall" to list available '
3602 b'compression engines'
3602 b'compression engines'
3603 ),
3603 ),
3604 )
3604 )
3605
3605
3606 # zlib is the historical default and doesn't need an explicit requirement.
3606 # zlib is the historical default and doesn't need an explicit requirement.
3607 if compengine == b'zstd':
3607 if compengine == b'zstd':
3608 requirements.add(b'revlog-compression-zstd')
3608 requirements.add(b'revlog-compression-zstd')
3609 elif compengine != b'zlib':
3609 elif compengine != b'zlib':
3610 requirements.add(b'exp-compression-%s' % compengine)
3610 requirements.add(b'exp-compression-%s' % compengine)
3611
3611
3612 if scmutil.gdinitconfig(ui):
3612 if scmutil.gdinitconfig(ui):
3613 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3613 requirements.add(requirementsmod.GENERALDELTA_REQUIREMENT)
3614 if ui.configbool(b'format', b'sparse-revlog'):
3614 if ui.configbool(b'format', b'sparse-revlog'):
3615 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3615 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT)
3616
3616
3617 # experimental config: format.exp-rc-dirstate-v2
3617 # experimental config: format.exp-rc-dirstate-v2
3618 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3618 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3619 if ui.configbool(b'format', b'exp-rc-dirstate-v2'):
3619 if ui.configbool(b'format', b'exp-rc-dirstate-v2'):
3620 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3620 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3621
3621
3622 # experimental config: format.exp-use-copies-side-data-changeset
3622 # experimental config: format.exp-use-copies-side-data-changeset
3623 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3623 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3624 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3624 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3625 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3625 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT)
3626 if ui.configbool(b'experimental', b'treemanifest'):
3626 if ui.configbool(b'experimental', b'treemanifest'):
3627 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3627 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT)
3628
3628
3629 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3629 changelogv2 = ui.config(b'format', b'exp-use-changelog-v2')
3630 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3630 if changelogv2 == b'enable-unstable-format-and-corrupt-my-data':
3631 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3631 requirements.add(requirementsmod.CHANGELOGV2_REQUIREMENT)
3632
3632
3633 revlogv2 = ui.config(b'experimental', b'revlogv2')
3633 revlogv2 = ui.config(b'experimental', b'revlogv2')
3634 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3634 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data':
3635 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3635 requirements.discard(requirementsmod.REVLOGV1_REQUIREMENT)
3636 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3636 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT)
3637 # experimental config: format.internal-phase
3637 # experimental config: format.internal-phase
3638 if ui.configbool(b'format', b'internal-phase'):
3638 if ui.configbool(b'format', b'internal-phase'):
3639 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3639 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT)
3640
3640
3641 if createopts.get(b'narrowfiles'):
3641 if createopts.get(b'narrowfiles'):
3642 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3642 requirements.add(requirementsmod.NARROW_REQUIREMENT)
3643
3643
3644 if createopts.get(b'lfs'):
3644 if createopts.get(b'lfs'):
3645 requirements.add(b'lfs')
3645 requirements.add(b'lfs')
3646
3646
3647 if ui.configbool(b'format', b'bookmarks-in-store'):
3647 if ui.configbool(b'format', b'bookmarks-in-store'):
3648 requirements.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT)
3648 requirements.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT)
3649
3649
3650 if ui.configbool(b'format', b'use-persistent-nodemap'):
3650 if ui.configbool(b'format', b'use-persistent-nodemap'):
3651 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3651 requirements.add(requirementsmod.NODEMAP_REQUIREMENT)
3652
3652
3653 # if share-safe is enabled, let's create the new repository with the new
3653 # if share-safe is enabled, let's create the new repository with the new
3654 # requirement
3654 # requirement
3655 if ui.configbool(b'format', b'use-share-safe'):
3655 if ui.configbool(b'format', b'use-share-safe'):
3656 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3656 requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
3657
3657
3658 # if we are creating a share-repoΒΉ we have to handle requirement
3658 # if we are creating a share-repoΒΉ we have to handle requirement
3659 # differently.
3659 # differently.
3660 #
3660 #
3661 # [1] (i.e. reusing the store from another repository, just having a
3661 # [1] (i.e. reusing the store from another repository, just having a
3662 # working copy)
3662 # working copy)
3663 if b'sharedrepo' in createopts:
3663 if b'sharedrepo' in createopts:
3664 source_requirements = set(createopts[b'sharedrepo'].requirements)
3664 source_requirements = set(createopts[b'sharedrepo'].requirements)
3665
3665
3666 if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements:
3666 if requirementsmod.SHARESAFE_REQUIREMENT not in source_requirements:
3667 # share to an old school repository, we have to copy the
3667 # share to an old school repository, we have to copy the
3668 # requirements and hope for the best.
3668 # requirements and hope for the best.
3669 requirements = source_requirements
3669 requirements = source_requirements
3670 else:
3670 else:
3671 # We have control on the working copy only, so "copy" the non
3671 # We have control on the working copy only, so "copy" the non
3672 # working copy part over, ignoring previous logic.
3672 # working copy part over, ignoring previous logic.
3673 to_drop = set()
3673 to_drop = set()
3674 for req in requirements:
3674 for req in requirements:
3675 if req in requirementsmod.WORKING_DIR_REQUIREMENTS:
3675 if req in requirementsmod.WORKING_DIR_REQUIREMENTS:
3676 continue
3676 continue
3677 if req in source_requirements:
3677 if req in source_requirements:
3678 continue
3678 continue
3679 to_drop.add(req)
3679 to_drop.add(req)
3680 requirements -= to_drop
3680 requirements -= to_drop
3681 requirements |= source_requirements
3681 requirements |= source_requirements
3682
3682
3683 if createopts.get(b'sharedrelative'):
3683 if createopts.get(b'sharedrelative'):
3684 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3684 requirements.add(requirementsmod.RELATIVE_SHARED_REQUIREMENT)
3685 else:
3685 else:
3686 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3686 requirements.add(requirementsmod.SHARED_REQUIREMENT)
3687
3687
3688 return requirements
3688 return requirements
3689
3689
3690
3690
3691 def checkrequirementscompat(ui, requirements):
3691 def checkrequirementscompat(ui, requirements):
3692 """Checks compatibility of repository requirements enabled and disabled.
3692 """Checks compatibility of repository requirements enabled and disabled.
3693
3693
3694 Returns a set of requirements which needs to be dropped because dependend
3694 Returns a set of requirements which needs to be dropped because dependend
3695 requirements are not enabled. Also warns users about it"""
3695 requirements are not enabled. Also warns users about it"""
3696
3696
3697 dropped = set()
3697 dropped = set()
3698
3698
3699 if requirementsmod.STORE_REQUIREMENT not in requirements:
3699 if requirementsmod.STORE_REQUIREMENT not in requirements:
3700 if requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3700 if requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT in requirements:
3701 ui.warn(
3701 ui.warn(
3702 _(
3702 _(
3703 b'ignoring enabled \'format.bookmarks-in-store\' config '
3703 b'ignoring enabled \'format.bookmarks-in-store\' config '
3704 b'beacuse it is incompatible with disabled '
3704 b'beacuse it is incompatible with disabled '
3705 b'\'format.usestore\' config\n'
3705 b'\'format.usestore\' config\n'
3706 )
3706 )
3707 )
3707 )
3708 dropped.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT)
3708 dropped.add(requirementsmod.BOOKMARKS_IN_STORE_REQUIREMENT)
3709
3709
3710 if (
3710 if (
3711 requirementsmod.SHARED_REQUIREMENT in requirements
3711 requirementsmod.SHARED_REQUIREMENT in requirements
3712 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3712 or requirementsmod.RELATIVE_SHARED_REQUIREMENT in requirements
3713 ):
3713 ):
3714 raise error.Abort(
3714 raise error.Abort(
3715 _(
3715 _(
3716 b"cannot create shared repository as source was created"
3716 b"cannot create shared repository as source was created"
3717 b" with 'format.usestore' config disabled"
3717 b" with 'format.usestore' config disabled"
3718 )
3718 )
3719 )
3719 )
3720
3720
3721 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3721 if requirementsmod.SHARESAFE_REQUIREMENT in requirements:
3722 ui.warn(
3722 ui.warn(
3723 _(
3723 _(
3724 b"ignoring enabled 'format.use-share-safe' config because "
3724 b"ignoring enabled 'format.use-share-safe' config because "
3725 b"it is incompatible with disabled 'format.usestore'"
3725 b"it is incompatible with disabled 'format.usestore'"
3726 b" config\n"
3726 b" config\n"
3727 )
3727 )
3728 )
3728 )
3729 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3729 dropped.add(requirementsmod.SHARESAFE_REQUIREMENT)
3730
3730
3731 return dropped
3731 return dropped
3732
3732
3733
3733
3734 def filterknowncreateopts(ui, createopts):
3734 def filterknowncreateopts(ui, createopts):
3735 """Filters a dict of repo creation options against options that are known.
3735 """Filters a dict of repo creation options against options that are known.
3736
3736
3737 Receives a dict of repo creation options and returns a dict of those
3737 Receives a dict of repo creation options and returns a dict of those
3738 options that we don't know how to handle.
3738 options that we don't know how to handle.
3739
3739
3740 This function is called as part of repository creation. If the
3740 This function is called as part of repository creation. If the
3741 returned dict contains any items, repository creation will not
3741 returned dict contains any items, repository creation will not
3742 be allowed, as it means there was a request to create a repository
3742 be allowed, as it means there was a request to create a repository
3743 with options not recognized by loaded code.
3743 with options not recognized by loaded code.
3744
3744
3745 Extensions can wrap this function to filter out creation options
3745 Extensions can wrap this function to filter out creation options
3746 they know how to handle.
3746 they know how to handle.
3747 """
3747 """
3748 known = {
3748 known = {
3749 b'backend',
3749 b'backend',
3750 b'lfs',
3750 b'lfs',
3751 b'narrowfiles',
3751 b'narrowfiles',
3752 b'sharedrepo',
3752 b'sharedrepo',
3753 b'sharedrelative',
3753 b'sharedrelative',
3754 b'shareditems',
3754 b'shareditems',
3755 b'shallowfilestore',
3755 b'shallowfilestore',
3756 }
3756 }
3757
3757
3758 return {k: v for k, v in createopts.items() if k not in known}
3758 return {k: v for k, v in createopts.items() if k not in known}
3759
3759
3760
3760
3761 def createrepository(ui, path, createopts=None, requirements=None):
3761 def createrepository(ui, path, createopts=None, requirements=None):
3762 """Create a new repository in a vfs.
3762 """Create a new repository in a vfs.
3763
3763
3764 ``path`` path to the new repo's working directory.
3764 ``path`` path to the new repo's working directory.
3765 ``createopts`` options for the new repository.
3765 ``createopts`` options for the new repository.
3766 ``requirement`` predefined set of requirements.
3766 ``requirement`` predefined set of requirements.
3767 (incompatible with ``createopts``)
3767 (incompatible with ``createopts``)
3768
3768
3769 The following keys for ``createopts`` are recognized:
3769 The following keys for ``createopts`` are recognized:
3770
3770
3771 backend
3771 backend
3772 The storage backend to use.
3772 The storage backend to use.
3773 lfs
3773 lfs
3774 Repository will be created with ``lfs`` requirement. The lfs extension
3774 Repository will be created with ``lfs`` requirement. The lfs extension
3775 will automatically be loaded when the repository is accessed.
3775 will automatically be loaded when the repository is accessed.
3776 narrowfiles
3776 narrowfiles
3777 Set up repository to support narrow file storage.
3777 Set up repository to support narrow file storage.
3778 sharedrepo
3778 sharedrepo
3779 Repository object from which storage should be shared.
3779 Repository object from which storage should be shared.
3780 sharedrelative
3780 sharedrelative
3781 Boolean indicating if the path to the shared repo should be
3781 Boolean indicating if the path to the shared repo should be
3782 stored as relative. By default, the pointer to the "parent" repo
3782 stored as relative. By default, the pointer to the "parent" repo
3783 is stored as an absolute path.
3783 is stored as an absolute path.
3784 shareditems
3784 shareditems
3785 Set of items to share to the new repository (in addition to storage).
3785 Set of items to share to the new repository (in addition to storage).
3786 shallowfilestore
3786 shallowfilestore
3787 Indicates that storage for files should be shallow (not all ancestor
3787 Indicates that storage for files should be shallow (not all ancestor
3788 revisions are known).
3788 revisions are known).
3789 """
3789 """
3790
3790
3791 if requirements is not None:
3791 if requirements is not None:
3792 if createopts is not None:
3792 if createopts is not None:
3793 msg = b'cannot specify both createopts and requirements'
3793 msg = b'cannot specify both createopts and requirements'
3794 raise error.ProgrammingError(msg)
3794 raise error.ProgrammingError(msg)
3795 createopts = {}
3795 createopts = {}
3796 else:
3796 else:
3797 createopts = defaultcreateopts(ui, createopts=createopts)
3797 createopts = defaultcreateopts(ui, createopts=createopts)
3798
3798
3799 unknownopts = filterknowncreateopts(ui, createopts)
3799 unknownopts = filterknowncreateopts(ui, createopts)
3800
3800
3801 if not isinstance(unknownopts, dict):
3801 if not isinstance(unknownopts, dict):
3802 raise error.ProgrammingError(
3802 raise error.ProgrammingError(
3803 b'filterknowncreateopts() did not return a dict'
3803 b'filterknowncreateopts() did not return a dict'
3804 )
3804 )
3805
3805
3806 if unknownopts:
3806 if unknownopts:
3807 raise error.Abort(
3807 raise error.Abort(
3808 _(
3808 _(
3809 b'unable to create repository because of unknown '
3809 b'unable to create repository because of unknown '
3810 b'creation option: %s'
3810 b'creation option: %s'
3811 )
3811 )
3812 % b', '.join(sorted(unknownopts)),
3812 % b', '.join(sorted(unknownopts)),
3813 hint=_(b'is a required extension not loaded?'),
3813 hint=_(b'is a required extension not loaded?'),
3814 )
3814 )
3815
3815
3816 requirements = newreporequirements(ui, createopts=createopts)
3816 requirements = newreporequirements(ui, createopts=createopts)
3817 requirements -= checkrequirementscompat(ui, requirements)
3817 requirements -= checkrequirementscompat(ui, requirements)
3818
3818
3819 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3819 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
3820
3820
3821 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3821 hgvfs = vfsmod.vfs(wdirvfs.join(b'.hg'))
3822 if hgvfs.exists():
3822 if hgvfs.exists():
3823 raise error.RepoError(_(b'repository %s already exists') % path)
3823 raise error.RepoError(_(b'repository %s already exists') % path)
3824
3824
3825 if b'sharedrepo' in createopts:
3825 if b'sharedrepo' in createopts:
3826 sharedpath = createopts[b'sharedrepo'].sharedpath
3826 sharedpath = createopts[b'sharedrepo'].sharedpath
3827
3827
3828 if createopts.get(b'sharedrelative'):
3828 if createopts.get(b'sharedrelative'):
3829 try:
3829 try:
3830 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3830 sharedpath = os.path.relpath(sharedpath, hgvfs.base)
3831 sharedpath = util.pconvert(sharedpath)
3831 sharedpath = util.pconvert(sharedpath)
3832 except (IOError, ValueError) as e:
3832 except (IOError, ValueError) as e:
3833 # ValueError is raised on Windows if the drive letters differ
3833 # ValueError is raised on Windows if the drive letters differ
3834 # on each path.
3834 # on each path.
3835 raise error.Abort(
3835 raise error.Abort(
3836 _(b'cannot calculate relative path'),
3836 _(b'cannot calculate relative path'),
3837 hint=stringutil.forcebytestr(e),
3837 hint=stringutil.forcebytestr(e),
3838 )
3838 )
3839
3839
3840 if not wdirvfs.exists():
3840 if not wdirvfs.exists():
3841 wdirvfs.makedirs()
3841 wdirvfs.makedirs()
3842
3842
3843 hgvfs.makedir(notindexed=True)
3843 hgvfs.makedir(notindexed=True)
3844 if b'sharedrepo' not in createopts:
3844 if b'sharedrepo' not in createopts:
3845 hgvfs.mkdir(b'cache')
3845 hgvfs.mkdir(b'cache')
3846 hgvfs.mkdir(b'wcache')
3846 hgvfs.mkdir(b'wcache')
3847
3847
3848 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3848 has_store = requirementsmod.STORE_REQUIREMENT in requirements
3849 if has_store and b'sharedrepo' not in createopts:
3849 if has_store and b'sharedrepo' not in createopts:
3850 hgvfs.mkdir(b'store')
3850 hgvfs.mkdir(b'store')
3851
3851
3852 # We create an invalid changelog outside the store so very old
3852 # We create an invalid changelog outside the store so very old
3853 # Mercurial versions (which didn't know about the requirements
3853 # Mercurial versions (which didn't know about the requirements
3854 # file) encounter an error on reading the changelog. This
3854 # file) encounter an error on reading the changelog. This
3855 # effectively locks out old clients and prevents them from
3855 # effectively locks out old clients and prevents them from
3856 # mucking with a repo in an unknown format.
3856 # mucking with a repo in an unknown format.
3857 #
3857 #
3858 # The revlog header has version 65535, which won't be recognized by
3858 # The revlog header has version 65535, which won't be recognized by
3859 # such old clients.
3859 # such old clients.
3860 hgvfs.append(
3860 hgvfs.append(
3861 b'00changelog.i',
3861 b'00changelog.i',
3862 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3862 b'\0\0\xFF\xFF dummy changelog to prevent using the old repo '
3863 b'layout',
3863 b'layout',
3864 )
3864 )
3865
3865
3866 # Filter the requirements into working copy and store ones
3866 # Filter the requirements into working copy and store ones
3867 wcreq, storereq = scmutil.filterrequirements(requirements)
3867 wcreq, storereq = scmutil.filterrequirements(requirements)
3868 # write working copy ones
3868 # write working copy ones
3869 scmutil.writerequires(hgvfs, wcreq)
3869 scmutil.writerequires(hgvfs, wcreq)
3870 # If there are store requirements and the current repository
3870 # If there are store requirements and the current repository
3871 # is not a shared one, write stored requirements
3871 # is not a shared one, write stored requirements
3872 # For new shared repository, we don't need to write the store
3872 # For new shared repository, we don't need to write the store
3873 # requirements as they are already present in store requires
3873 # requirements as they are already present in store requires
3874 if storereq and b'sharedrepo' not in createopts:
3874 if storereq and b'sharedrepo' not in createopts:
3875 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3875 storevfs = vfsmod.vfs(hgvfs.join(b'store'), cacheaudited=True)
3876 scmutil.writerequires(storevfs, storereq)
3876 scmutil.writerequires(storevfs, storereq)
3877
3877
3878 # Write out file telling readers where to find the shared store.
3878 # Write out file telling readers where to find the shared store.
3879 if b'sharedrepo' in createopts:
3879 if b'sharedrepo' in createopts:
3880 hgvfs.write(b'sharedpath', sharedpath)
3880 hgvfs.write(b'sharedpath', sharedpath)
3881
3881
3882 if createopts.get(b'shareditems'):
3882 if createopts.get(b'shareditems'):
3883 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3883 shared = b'\n'.join(sorted(createopts[b'shareditems'])) + b'\n'
3884 hgvfs.write(b'shared', shared)
3884 hgvfs.write(b'shared', shared)
3885
3885
3886
3886
3887 def poisonrepository(repo):
3887 def poisonrepository(repo):
3888 """Poison a repository instance so it can no longer be used."""
3888 """Poison a repository instance so it can no longer be used."""
3889 # Perform any cleanup on the instance.
3889 # Perform any cleanup on the instance.
3890 repo.close()
3890 repo.close()
3891
3891
3892 # Our strategy is to replace the type of the object with one that
3892 # Our strategy is to replace the type of the object with one that
3893 # has all attribute lookups result in error.
3893 # has all attribute lookups result in error.
3894 #
3894 #
3895 # But we have to allow the close() method because some constructors
3895 # But we have to allow the close() method because some constructors
3896 # of repos call close() on repo references.
3896 # of repos call close() on repo references.
3897 class poisonedrepository(object):
3897 class poisonedrepository(object):
3898 def __getattribute__(self, item):
3898 def __getattribute__(self, item):
3899 if item == 'close':
3899 if item == 'close':
3900 return object.__getattribute__(self, item)
3900 return object.__getattribute__(self, item)
3901
3901
3902 raise error.ProgrammingError(
3902 raise error.ProgrammingError(
3903 b'repo instances should not be used after unshare'
3903 b'repo instances should not be used after unshare'
3904 )
3904 )
3905
3905
3906 def close(self):
3906 def close(self):
3907 pass
3907 pass
3908
3908
3909 # We may have a repoview, which intercepts __setattr__. So be sure
3909 # We may have a repoview, which intercepts __setattr__. So be sure
3910 # we operate at the lowest level possible.
3910 # we operate at the lowest level possible.
3911 object.__setattr__(repo, '__class__', poisonedrepository)
3911 object.__setattr__(repo, '__class__', poisonedrepository)
@@ -1,117 +1,121 b''
1 # requirements.py - objects and functions related to repository requirements
1 # requirements.py - objects and functions related to repository requirements
2 #
2 #
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 # obsolete experimental requirements:
10 # obsolete experimental requirements:
11 # - manifestv2: An experimental new manifest format that allowed
11 # - manifestv2: An experimental new manifest format that allowed
12 # for stem compression of long paths. Experiment ended up not
12 # for stem compression of long paths. Experiment ended up not
13 # being successful (repository sizes went up due to worse delta
13 # being successful (repository sizes went up due to worse delta
14 # chains), and the code was deleted in 4.6.
14 # chains), and the code was deleted in 4.6.
15
15
16 GENERALDELTA_REQUIREMENT = b'generaldelta'
16 GENERALDELTA_REQUIREMENT = b'generaldelta'
17 DOTENCODE_REQUIREMENT = b'dotencode'
17 DOTENCODE_REQUIREMENT = b'dotencode'
18 STORE_REQUIREMENT = b'store'
18 STORE_REQUIREMENT = b'store'
19 FNCACHE_REQUIREMENT = b'fncache'
19 FNCACHE_REQUIREMENT = b'fncache'
20
20
21 DIRSTATE_V2_REQUIREMENT = b'dirstate-v2'
21 DIRSTATE_V2_REQUIREMENT = b'dirstate-v2'
22
22
23 # When narrowing is finalized and no longer subject to format changes,
23 # When narrowing is finalized and no longer subject to format changes,
24 # we should move this to just "narrow" or similar.
24 # we should move this to just "narrow" or similar.
25 NARROW_REQUIREMENT = b'narrowhg-experimental'
25 NARROW_REQUIREMENT = b'narrowhg-experimental'
26
26
27 # Enables sparse working directory usage
27 # Enables sparse working directory usage
28 SPARSE_REQUIREMENT = b'exp-sparse'
28 SPARSE_REQUIREMENT = b'exp-sparse'
29
29
30 # Enables the internal phase which is used to hide changesets instead
30 # Enables the internal phase which is used to hide changesets instead
31 # of stripping them
31 # of stripping them
32 INTERNAL_PHASE_REQUIREMENT = b'internal-phase'
32 INTERNAL_PHASE_REQUIREMENT = b'internal-phase'
33
33
34 # Stores manifest in Tree structure
34 # Stores manifest in Tree structure
35 TREEMANIFEST_REQUIREMENT = b'treemanifest'
35 TREEMANIFEST_REQUIREMENT = b'treemanifest'
36
36
37 REVLOGV1_REQUIREMENT = b'revlogv1'
37 REVLOGV1_REQUIREMENT = b'revlogv1'
38
38
39 # allow using ZSTD as compression engine for revlog content
40 REVLOG_COMPRESSION_ZSTD = b'revlog-compression-zstd'
41
39 # Increment the sub-version when the revlog v2 format changes to lock out old
42 # Increment the sub-version when the revlog v2 format changes to lock out old
40 # clients.
43 # clients.
41 CHANGELOGV2_REQUIREMENT = b'exp-changelog-v2'
44 CHANGELOGV2_REQUIREMENT = b'exp-changelog-v2'
42
45
43 # Increment the sub-version when the revlog v2 format changes to lock out old
46 # Increment the sub-version when the revlog v2 format changes to lock out old
44 # clients.
47 # clients.
45 REVLOGV2_REQUIREMENT = b'exp-revlogv2.2'
48 REVLOGV2_REQUIREMENT = b'exp-revlogv2.2'
46
49
47 # A repository with the sparserevlog feature will have delta chains that
50 # A repository with the sparserevlog feature will have delta chains that
48 # can spread over a larger span. Sparse reading cuts these large spans into
51 # can spread over a larger span. Sparse reading cuts these large spans into
49 # pieces, so that each piece isn't too big.
52 # pieces, so that each piece isn't too big.
50 # Without the sparserevlog capability, reading from the repository could use
53 # Without the sparserevlog capability, reading from the repository could use
51 # huge amounts of memory, because the whole span would be read at once,
54 # huge amounts of memory, because the whole span would be read at once,
52 # including all the intermediate revisions that aren't pertinent for the chain.
55 # including all the intermediate revisions that aren't pertinent for the chain.
53 # This is why once a repository has enabled sparse-read, it becomes required.
56 # This is why once a repository has enabled sparse-read, it becomes required.
54 SPARSEREVLOG_REQUIREMENT = b'sparserevlog'
57 SPARSEREVLOG_REQUIREMENT = b'sparserevlog'
55
58
56 # A repository with the the copies-sidedata-changeset requirement will store
59 # A repository with the the copies-sidedata-changeset requirement will store
57 # copies related information in changeset's sidedata.
60 # copies related information in changeset's sidedata.
58 COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset'
61 COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset'
59
62
60 # The repository use persistent nodemap for the changelog and the manifest.
63 # The repository use persistent nodemap for the changelog and the manifest.
61 NODEMAP_REQUIREMENT = b'persistent-nodemap'
64 NODEMAP_REQUIREMENT = b'persistent-nodemap'
62
65
63 # Denotes that the current repository is a share
66 # Denotes that the current repository is a share
64 SHARED_REQUIREMENT = b'shared'
67 SHARED_REQUIREMENT = b'shared'
65
68
66 # Denotes that current repository is a share and the shared source path is
69 # Denotes that current repository is a share and the shared source path is
67 # relative to the current repository root path
70 # relative to the current repository root path
68 RELATIVE_SHARED_REQUIREMENT = b'relshared'
71 RELATIVE_SHARED_REQUIREMENT = b'relshared'
69
72
70 # A repository with share implemented safely. The repository has different
73 # A repository with share implemented safely. The repository has different
71 # store and working copy requirements i.e. both `.hg/requires` and
74 # store and working copy requirements i.e. both `.hg/requires` and
72 # `.hg/store/requires` are present.
75 # `.hg/store/requires` are present.
73 SHARESAFE_REQUIREMENT = b'share-safe'
76 SHARESAFE_REQUIREMENT = b'share-safe'
74
77
75 # Bookmarks must be stored in the `store` part of the repository and will be
78 # Bookmarks must be stored in the `store` part of the repository and will be
76 # share accross shares
79 # share accross shares
77 BOOKMARKS_IN_STORE_REQUIREMENT = b'bookmarksinstore'
80 BOOKMARKS_IN_STORE_REQUIREMENT = b'bookmarksinstore'
78
81
79 # List of requirements which are working directory specific
82 # List of requirements which are working directory specific
80 # These requirements cannot be shared between repositories if they
83 # These requirements cannot be shared between repositories if they
81 # share the same store
84 # share the same store
82 # * sparse is a working directory specific functionality and hence working
85 # * sparse is a working directory specific functionality and hence working
83 # directory specific requirement
86 # directory specific requirement
84 # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which
87 # * SHARED_REQUIREMENT and RELATIVE_SHARED_REQUIREMENT are requirements which
85 # represents that the current working copy/repository shares store of another
88 # represents that the current working copy/repository shares store of another
86 # repo. Hence both of them should be stored in working copy
89 # repo. Hence both of them should be stored in working copy
87 # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of
90 # * SHARESAFE_REQUIREMENT needs to be stored in working dir to mark that rest of
88 # the requirements are stored in store's requires
91 # the requirements are stored in store's requires
89 # * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per
92 # * DIRSTATE_V2_REQUIREMENT affects .hg/dirstate, of which there is one per
90 # working directory.
93 # working directory.
91 WORKING_DIR_REQUIREMENTS = {
94 WORKING_DIR_REQUIREMENTS = {
92 SPARSE_REQUIREMENT,
95 SPARSE_REQUIREMENT,
93 SHARED_REQUIREMENT,
96 SHARED_REQUIREMENT,
94 RELATIVE_SHARED_REQUIREMENT,
97 RELATIVE_SHARED_REQUIREMENT,
95 SHARESAFE_REQUIREMENT,
98 SHARESAFE_REQUIREMENT,
96 DIRSTATE_V2_REQUIREMENT,
99 DIRSTATE_V2_REQUIREMENT,
97 }
100 }
98
101
99 # List of requirement that impact "stream-clone" (and hardlink clone) and
102 # List of requirement that impact "stream-clone" (and hardlink clone) and
100 # cannot be changed in such cases.
103 # cannot be changed in such cases.
101 #
104 #
102 # requirements not in this list are safe to be altered during stream-clone.
105 # requirements not in this list are safe to be altered during stream-clone.
103 #
106 #
104 # note: the list is currently inherited from previous code and miss some relevant requirement while containing some irrelevant ones.
107 # note: the list is currently inherited from previous code and miss some relevant requirement while containing some irrelevant ones.
105 STREAM_FIXED_REQUIREMENTS = {
108 STREAM_FIXED_REQUIREMENTS = {
106 BOOKMARKS_IN_STORE_REQUIREMENT,
109 BOOKMARKS_IN_STORE_REQUIREMENT,
107 CHANGELOGV2_REQUIREMENT,
110 CHANGELOGV2_REQUIREMENT,
108 COPIESSDC_REQUIREMENT,
111 COPIESSDC_REQUIREMENT,
109 DIRSTATE_V2_REQUIREMENT,
112 DIRSTATE_V2_REQUIREMENT,
110 GENERALDELTA_REQUIREMENT,
113 GENERALDELTA_REQUIREMENT,
111 NODEMAP_REQUIREMENT,
114 NODEMAP_REQUIREMENT,
115 REVLOG_COMPRESSION_ZSTD,
112 REVLOGV1_REQUIREMENT,
116 REVLOGV1_REQUIREMENT,
113 REVLOGV2_REQUIREMENT,
117 REVLOGV2_REQUIREMENT,
114 SHARESAFE_REQUIREMENT,
118 SHARESAFE_REQUIREMENT,
115 SPARSEREVLOG_REQUIREMENT,
119 SPARSEREVLOG_REQUIREMENT,
116 TREEMANIFEST_REQUIREMENT,
120 TREEMANIFEST_REQUIREMENT,
117 }
121 }
@@ -1,1041 +1,1041 b''
1 Setting up test
1 Setting up test
2
2
3 $ hg init test
3 $ hg init test
4 $ cd test
4 $ cd test
5 $ echo 0 > afile
5 $ echo 0 > afile
6 $ hg add afile
6 $ hg add afile
7 $ hg commit -m "0.0"
7 $ hg commit -m "0.0"
8 $ echo 1 >> afile
8 $ echo 1 >> afile
9 $ hg commit -m "0.1"
9 $ hg commit -m "0.1"
10 $ echo 2 >> afile
10 $ echo 2 >> afile
11 $ hg commit -m "0.2"
11 $ hg commit -m "0.2"
12 $ echo 3 >> afile
12 $ echo 3 >> afile
13 $ hg commit -m "0.3"
13 $ hg commit -m "0.3"
14 $ hg update -C 0
14 $ hg update -C 0
15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
16 $ echo 1 >> afile
16 $ echo 1 >> afile
17 $ hg commit -m "1.1"
17 $ hg commit -m "1.1"
18 created new head
18 created new head
19 $ echo 2 >> afile
19 $ echo 2 >> afile
20 $ hg commit -m "1.2"
20 $ hg commit -m "1.2"
21 $ echo "a line" > fred
21 $ echo "a line" > fred
22 $ echo 3 >> afile
22 $ echo 3 >> afile
23 $ hg add fred
23 $ hg add fred
24 $ hg commit -m "1.3"
24 $ hg commit -m "1.3"
25 $ hg mv afile adifferentfile
25 $ hg mv afile adifferentfile
26 $ hg commit -m "1.3m"
26 $ hg commit -m "1.3m"
27 $ hg update -C 3
27 $ hg update -C 3
28 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
28 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
29 $ hg mv afile anotherfile
29 $ hg mv afile anotherfile
30 $ hg commit -m "0.3m"
30 $ hg commit -m "0.3m"
31 $ hg verify
31 $ hg verify
32 checking changesets
32 checking changesets
33 checking manifests
33 checking manifests
34 crosschecking files in changesets and manifests
34 crosschecking files in changesets and manifests
35 checking files
35 checking files
36 checked 9 changesets with 7 changes to 4 files
36 checked 9 changesets with 7 changes to 4 files
37 $ cd ..
37 $ cd ..
38 $ hg init empty
38 $ hg init empty
39
39
40 Bundle and phase
40 Bundle and phase
41
41
42 $ hg -R test phase --force --secret 0
42 $ hg -R test phase --force --secret 0
43 $ hg -R test bundle phase.hg empty
43 $ hg -R test bundle phase.hg empty
44 searching for changes
44 searching for changes
45 no changes found (ignored 9 secret changesets)
45 no changes found (ignored 9 secret changesets)
46 [1]
46 [1]
47 $ hg -R test phase --draft -r 'head()'
47 $ hg -R test phase --draft -r 'head()'
48
48
49 Bundle --all
49 Bundle --all
50
50
51 $ hg -R test bundle --all all.hg
51 $ hg -R test bundle --all all.hg
52 9 changesets found
52 9 changesets found
53
53
54 Bundle test to full.hg
54 Bundle test to full.hg
55
55
56 $ hg -R test bundle full.hg empty
56 $ hg -R test bundle full.hg empty
57 searching for changes
57 searching for changes
58 9 changesets found
58 9 changesets found
59
59
60 Unbundle full.hg in test
60 Unbundle full.hg in test
61
61
62 $ hg -R test unbundle full.hg
62 $ hg -R test unbundle full.hg
63 adding changesets
63 adding changesets
64 adding manifests
64 adding manifests
65 adding file changes
65 adding file changes
66 added 0 changesets with 0 changes to 4 files
66 added 0 changesets with 0 changes to 4 files
67 (run 'hg update' to get a working copy)
67 (run 'hg update' to get a working copy)
68
68
69 Verify empty
69 Verify empty
70
70
71 $ hg -R empty heads
71 $ hg -R empty heads
72 [1]
72 [1]
73 $ hg -R empty verify
73 $ hg -R empty verify
74 checking changesets
74 checking changesets
75 checking manifests
75 checking manifests
76 crosschecking files in changesets and manifests
76 crosschecking files in changesets and manifests
77 checking files
77 checking files
78 checked 0 changesets with 0 changes to 0 files
78 checked 0 changesets with 0 changes to 0 files
79
79
80 #if repobundlerepo
80 #if repobundlerepo
81
81
82 Pull full.hg into test (using --cwd)
82 Pull full.hg into test (using --cwd)
83
83
84 $ hg --cwd test pull ../full.hg
84 $ hg --cwd test pull ../full.hg
85 pulling from ../full.hg
85 pulling from ../full.hg
86 searching for changes
86 searching for changes
87 no changes found
87 no changes found
88
88
89 Verify that there are no leaked temporary files after pull (issue2797)
89 Verify that there are no leaked temporary files after pull (issue2797)
90
90
91 $ ls test/.hg | grep .hg10un
91 $ ls test/.hg | grep .hg10un
92 [1]
92 [1]
93
93
94 Pull full.hg into empty (using --cwd)
94 Pull full.hg into empty (using --cwd)
95
95
96 $ hg --cwd empty pull ../full.hg
96 $ hg --cwd empty pull ../full.hg
97 pulling from ../full.hg
97 pulling from ../full.hg
98 requesting all changes
98 requesting all changes
99 adding changesets
99 adding changesets
100 adding manifests
100 adding manifests
101 adding file changes
101 adding file changes
102 added 9 changesets with 7 changes to 4 files (+1 heads)
102 added 9 changesets with 7 changes to 4 files (+1 heads)
103 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
103 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
104 (run 'hg heads' to see heads, 'hg merge' to merge)
104 (run 'hg heads' to see heads, 'hg merge' to merge)
105
105
106 Rollback empty
106 Rollback empty
107
107
108 $ hg -R empty rollback
108 $ hg -R empty rollback
109 repository tip rolled back to revision -1 (undo pull)
109 repository tip rolled back to revision -1 (undo pull)
110
110
111 Pull full.hg into empty again (using --cwd)
111 Pull full.hg into empty again (using --cwd)
112
112
113 $ hg --cwd empty pull ../full.hg
113 $ hg --cwd empty pull ../full.hg
114 pulling from ../full.hg
114 pulling from ../full.hg
115 requesting all changes
115 requesting all changes
116 adding changesets
116 adding changesets
117 adding manifests
117 adding manifests
118 adding file changes
118 adding file changes
119 added 9 changesets with 7 changes to 4 files (+1 heads)
119 added 9 changesets with 7 changes to 4 files (+1 heads)
120 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
120 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
121 (run 'hg heads' to see heads, 'hg merge' to merge)
121 (run 'hg heads' to see heads, 'hg merge' to merge)
122
122
123 Pull full.hg into test (using -R)
123 Pull full.hg into test (using -R)
124
124
125 $ hg -R test pull full.hg
125 $ hg -R test pull full.hg
126 pulling from full.hg
126 pulling from full.hg
127 searching for changes
127 searching for changes
128 no changes found
128 no changes found
129
129
130 Pull full.hg into empty (using -R)
130 Pull full.hg into empty (using -R)
131
131
132 $ hg -R empty pull full.hg
132 $ hg -R empty pull full.hg
133 pulling from full.hg
133 pulling from full.hg
134 searching for changes
134 searching for changes
135 no changes found
135 no changes found
136
136
137 Rollback empty
137 Rollback empty
138
138
139 $ hg -R empty rollback
139 $ hg -R empty rollback
140 repository tip rolled back to revision -1 (undo pull)
140 repository tip rolled back to revision -1 (undo pull)
141
141
142 Pull full.hg into empty again (using -R)
142 Pull full.hg into empty again (using -R)
143
143
144 $ hg -R empty pull full.hg
144 $ hg -R empty pull full.hg
145 pulling from full.hg
145 pulling from full.hg
146 requesting all changes
146 requesting all changes
147 adding changesets
147 adding changesets
148 adding manifests
148 adding manifests
149 adding file changes
149 adding file changes
150 added 9 changesets with 7 changes to 4 files (+1 heads)
150 added 9 changesets with 7 changes to 4 files (+1 heads)
151 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
151 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
152 (run 'hg heads' to see heads, 'hg merge' to merge)
152 (run 'hg heads' to see heads, 'hg merge' to merge)
153
153
154 Log -R full.hg in fresh empty
154 Log -R full.hg in fresh empty
155
155
156 $ rm -r empty
156 $ rm -r empty
157 $ hg init empty
157 $ hg init empty
158 $ cd empty
158 $ cd empty
159 $ hg -R bundle://../full.hg log
159 $ hg -R bundle://../full.hg log
160 changeset: 8:aa35859c02ea
160 changeset: 8:aa35859c02ea
161 tag: tip
161 tag: tip
162 parent: 3:eebf5a27f8ca
162 parent: 3:eebf5a27f8ca
163 user: test
163 user: test
164 date: Thu Jan 01 00:00:00 1970 +0000
164 date: Thu Jan 01 00:00:00 1970 +0000
165 summary: 0.3m
165 summary: 0.3m
166
166
167 changeset: 7:a6a34bfa0076
167 changeset: 7:a6a34bfa0076
168 user: test
168 user: test
169 date: Thu Jan 01 00:00:00 1970 +0000
169 date: Thu Jan 01 00:00:00 1970 +0000
170 summary: 1.3m
170 summary: 1.3m
171
171
172 changeset: 6:7373c1169842
172 changeset: 6:7373c1169842
173 user: test
173 user: test
174 date: Thu Jan 01 00:00:00 1970 +0000
174 date: Thu Jan 01 00:00:00 1970 +0000
175 summary: 1.3
175 summary: 1.3
176
176
177 changeset: 5:1bb50a9436a7
177 changeset: 5:1bb50a9436a7
178 user: test
178 user: test
179 date: Thu Jan 01 00:00:00 1970 +0000
179 date: Thu Jan 01 00:00:00 1970 +0000
180 summary: 1.2
180 summary: 1.2
181
181
182 changeset: 4:095197eb4973
182 changeset: 4:095197eb4973
183 parent: 0:f9ee2f85a263
183 parent: 0:f9ee2f85a263
184 user: test
184 user: test
185 date: Thu Jan 01 00:00:00 1970 +0000
185 date: Thu Jan 01 00:00:00 1970 +0000
186 summary: 1.1
186 summary: 1.1
187
187
188 changeset: 3:eebf5a27f8ca
188 changeset: 3:eebf5a27f8ca
189 user: test
189 user: test
190 date: Thu Jan 01 00:00:00 1970 +0000
190 date: Thu Jan 01 00:00:00 1970 +0000
191 summary: 0.3
191 summary: 0.3
192
192
193 changeset: 2:e38ba6f5b7e0
193 changeset: 2:e38ba6f5b7e0
194 user: test
194 user: test
195 date: Thu Jan 01 00:00:00 1970 +0000
195 date: Thu Jan 01 00:00:00 1970 +0000
196 summary: 0.2
196 summary: 0.2
197
197
198 changeset: 1:34c2bf6b0626
198 changeset: 1:34c2bf6b0626
199 user: test
199 user: test
200 date: Thu Jan 01 00:00:00 1970 +0000
200 date: Thu Jan 01 00:00:00 1970 +0000
201 summary: 0.1
201 summary: 0.1
202
202
203 changeset: 0:f9ee2f85a263
203 changeset: 0:f9ee2f85a263
204 user: test
204 user: test
205 date: Thu Jan 01 00:00:00 1970 +0000
205 date: Thu Jan 01 00:00:00 1970 +0000
206 summary: 0.0
206 summary: 0.0
207
207
208 Make sure bundlerepo doesn't leak tempfiles (issue2491)
208 Make sure bundlerepo doesn't leak tempfiles (issue2491)
209
209
210 $ ls .hg
210 $ ls .hg
211 00changelog.i
211 00changelog.i
212 cache
212 cache
213 requires
213 requires
214 store
214 store
215 wcache
215 wcache
216
216
217 Pull ../full.hg into empty (with hook)
217 Pull ../full.hg into empty (with hook)
218
218
219 $ cat >> .hg/hgrc <<EOF
219 $ cat >> .hg/hgrc <<EOF
220 > [hooks]
220 > [hooks]
221 > changegroup = sh -c "printenv.py --line changegroup"
221 > changegroup = sh -c "printenv.py --line changegroup"
222 > EOF
222 > EOF
223
223
224 doesn't work (yet ?)
224 doesn't work (yet ?)
225 NOTE: msys is mangling the URL below
225 NOTE: msys is mangling the URL below
226
226
227 hg -R bundle://../full.hg verify
227 hg -R bundle://../full.hg verify
228
228
229 $ hg pull bundle://../full.hg
229 $ hg pull bundle://../full.hg
230 pulling from bundle:../full.hg
230 pulling from bundle:../full.hg
231 requesting all changes
231 requesting all changes
232 adding changesets
232 adding changesets
233 adding manifests
233 adding manifests
234 adding file changes
234 adding file changes
235 added 9 changesets with 7 changes to 4 files (+1 heads)
235 added 9 changesets with 7 changes to 4 files (+1 heads)
236 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
236 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
237 changegroup hook: HG_HOOKNAME=changegroup
237 changegroup hook: HG_HOOKNAME=changegroup
238 HG_HOOKTYPE=changegroup
238 HG_HOOKTYPE=changegroup
239 HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735
239 HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735
240 HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
240 HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
241 HG_SOURCE=pull
241 HG_SOURCE=pull
242 HG_TXNID=TXN:$ID$
242 HG_TXNID=TXN:$ID$
243 HG_TXNNAME=pull
243 HG_TXNNAME=pull
244 bundle:../full.hg (no-msys !)
244 bundle:../full.hg (no-msys !)
245 bundle;../full.hg (msys !)
245 bundle;../full.hg (msys !)
246 HG_URL=bundle:../full.hg (no-msys !)
246 HG_URL=bundle:../full.hg (no-msys !)
247 HG_URL=bundle;../full.hg (msys !)
247 HG_URL=bundle;../full.hg (msys !)
248
248
249 (run 'hg heads' to see heads, 'hg merge' to merge)
249 (run 'hg heads' to see heads, 'hg merge' to merge)
250
250
251 Rollback empty
251 Rollback empty
252
252
253 $ hg rollback
253 $ hg rollback
254 repository tip rolled back to revision -1 (undo pull)
254 repository tip rolled back to revision -1 (undo pull)
255 $ cd ..
255 $ cd ..
256
256
257 Log -R bundle:empty+full.hg
257 Log -R bundle:empty+full.hg
258
258
259 $ hg -R bundle:empty+full.hg log --template="{rev} "; echo ""
259 $ hg -R bundle:empty+full.hg log --template="{rev} "; echo ""
260 8 7 6 5 4 3 2 1 0
260 8 7 6 5 4 3 2 1 0
261
261
262 Pull full.hg into empty again (using -R; with hook)
262 Pull full.hg into empty again (using -R; with hook)
263
263
264 $ hg -R empty pull full.hg
264 $ hg -R empty pull full.hg
265 pulling from full.hg
265 pulling from full.hg
266 requesting all changes
266 requesting all changes
267 adding changesets
267 adding changesets
268 adding manifests
268 adding manifests
269 adding file changes
269 adding file changes
270 added 9 changesets with 7 changes to 4 files (+1 heads)
270 added 9 changesets with 7 changes to 4 files (+1 heads)
271 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
271 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
272 changegroup hook: HG_HOOKNAME=changegroup
272 changegroup hook: HG_HOOKNAME=changegroup
273 HG_HOOKTYPE=changegroup
273 HG_HOOKTYPE=changegroup
274 HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735
274 HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735
275 HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
275 HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
276 HG_SOURCE=pull
276 HG_SOURCE=pull
277 HG_TXNID=TXN:$ID$
277 HG_TXNID=TXN:$ID$
278 HG_TXNNAME=pull
278 HG_TXNNAME=pull
279 bundle:empty+full.hg
279 bundle:empty+full.hg
280 HG_URL=bundle:empty+full.hg
280 HG_URL=bundle:empty+full.hg
281
281
282 (run 'hg heads' to see heads, 'hg merge' to merge)
282 (run 'hg heads' to see heads, 'hg merge' to merge)
283
283
284 #endif
284 #endif
285
285
286 Cannot produce streaming clone bundles with "hg bundle"
286 Cannot produce streaming clone bundles with "hg bundle"
287
287
288 $ hg -R test bundle -t packed1 packed.hg
288 $ hg -R test bundle -t packed1 packed.hg
289 abort: packed bundles cannot be produced by "hg bundle"
289 abort: packed bundles cannot be produced by "hg bundle"
290 (use 'hg debugcreatestreamclonebundle')
290 (use 'hg debugcreatestreamclonebundle')
291 [10]
291 [10]
292
292
293 packed1 is produced properly
293 packed1 is produced properly
294
294
295
295
296 #if reporevlogstore rust
296 #if reporevlogstore rust
297
297
298 $ hg -R test debugcreatestreamclonebundle packed.hg
298 $ hg -R test debugcreatestreamclonebundle packed.hg
299 writing 2665 bytes for 6 files
299 writing 2665 bytes for 6 files
300 bundle requirements: generaldelta, persistent-nodemap, revlogv1, sparserevlog
300 bundle requirements: generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog
301
301
302 $ f -B 64 --size --sha1 --hexdump packed.hg
302 $ f -B 64 --size --sha1 --hexdump packed.hg
303 packed.hg: size=2860, sha1=81d7a2e535892cda51e82c200f818de2cca828d3
303 packed.hg: size=2884, sha1=b0c868701f8a9fe44daf094b2f5bf661cf90c789
304 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
304 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
305 0010: 00 00 00 00 0a 69 00 36 67 65 6e 65 72 61 6c 64 |.....i.6generald|
305 0010: 00 00 00 00 0a 69 00 4e 67 65 6e 65 72 61 6c 64 |.....i.Ngenerald|
306 0020: 65 6c 74 61 2c 70 65 72 73 69 73 74 65 6e 74 2d |elta,persistent-|
306 0020: 65 6c 74 61 2c 70 65 72 73 69 73 74 65 6e 74 2d |elta,persistent-|
307 0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 76 31 |nodemap,revlogv1|
307 0030: 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f 67 2d 63 |nodemap,revlog-c|
308 $ hg debugbundle --spec packed.hg
308 $ hg debugbundle --spec packed.hg
309 none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlogv1%2Csparserevlog
309 none-packed1;requirements%3Dgeneraldelta%2Cpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
310 #endif
310 #endif
311
311
312 #if reporevlogstore no-rust zstd
312 #if reporevlogstore no-rust zstd
313
313
314 $ hg -R test debugcreatestreamclonebundle packed.hg
314 $ hg -R test debugcreatestreamclonebundle packed.hg
315 writing 2665 bytes for 6 files
315 writing 2665 bytes for 6 files
316 bundle requirements: generaldelta, revlogv1, sparserevlog
316 bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, sparserevlog
317
317
318 $ f -B 64 --size --sha1 --hexdump packed.hg
318 $ f -B 64 --size --sha1 --hexdump packed.hg
319 packed.hg: size=2841, sha1=8b645a65f49b0ae43042a9f3da56d4bfdf1c7f99
319 packed.hg: size=2865, sha1=353d10311f4befa195d9a1ca4b8e26518115c702
320 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
320 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
321 0010: 00 00 00 00 0a 69 00 23 67 65 6e 65 72 61 6c 64 |.....i.#generald|
321 0010: 00 00 00 00 0a 69 00 3b 67 65 6e 65 72 61 6c 64 |.....i.;generald|
322 0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp|
322 0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 2d 63 6f 6d 70 |elta,revlog-comp|
323 0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/|
323 0030: 72 65 73 73 69 6f 6e 2d 7a 73 74 64 2c 72 65 76 |ression-zstd,rev|
324 $ hg debugbundle --spec packed.hg
324 $ hg debugbundle --spec packed.hg
325 none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog
325 none-packed1;requirements%3Dgeneraldelta%2Crevlog-compression-zstd%2Crevlogv1%2Csparserevlog
326 #endif
326 #endif
327
327
328 #if reporevlogstore no-rust no-zstd
328 #if reporevlogstore no-rust no-zstd
329
329
330 $ hg -R test debugcreatestreamclonebundle packed.hg
330 $ hg -R test debugcreatestreamclonebundle packed.hg
331 writing 2664 bytes for 6 files
331 writing 2664 bytes for 6 files
332 bundle requirements: generaldelta, revlogv1, sparserevlog
332 bundle requirements: generaldelta, revlogv1, sparserevlog
333
333
334 $ f -B 64 --size --sha1 --hexdump packed.hg
334 $ f -B 64 --size --sha1 --hexdump packed.hg
335 packed.hg: size=2840, sha1=12bf3eee3eb8a04c503ce2d29b48f0135c7edff5
335 packed.hg: size=2840, sha1=12bf3eee3eb8a04c503ce2d29b48f0135c7edff5
336 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
336 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
337 0010: 00 00 00 00 0a 68 00 23 67 65 6e 65 72 61 6c 64 |.....h.#generald|
337 0010: 00 00 00 00 0a 68 00 23 67 65 6e 65 72 61 6c 64 |.....h.#generald|
338 0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp|
338 0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 2c 73 70 |elta,revlogv1,sp|
339 0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/|
339 0030: 61 72 73 65 72 65 76 6c 6f 67 00 64 61 74 61 2f |arserevlog.data/|
340 $ hg debugbundle --spec packed.hg
340 $ hg debugbundle --spec packed.hg
341 none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog
341 none-packed1;requirements%3Dgeneraldelta%2Crevlogv1%2Csparserevlog
342 #endif
342 #endif
343
343
344 #if reporevlogstore
344 #if reporevlogstore
345
345
346 generaldelta requirement is not listed in stream clone bundles unless used
346 generaldelta requirement is not listed in stream clone bundles unless used
347
347
348 $ hg --config format.usegeneraldelta=false init testnongd
348 $ hg --config format.usegeneraldelta=false init testnongd
349 $ cd testnongd
349 $ cd testnongd
350 $ touch foo
350 $ touch foo
351 $ hg -q commit -A -m initial
351 $ hg -q commit -A -m initial
352 $ cd ..
352 $ cd ..
353
353
354 #endif
354 #endif
355
355
356 #if reporevlogstore rust
356 #if reporevlogstore rust
357
357
358 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
358 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
359 writing 301 bytes for 3 files
359 writing 301 bytes for 3 files
360 bundle requirements: persistent-nodemap, revlogv1
360 bundle requirements: persistent-nodemap, revlog-compression-zstd, revlogv1
361
361
362 $ f -B 64 --size --sha1 --hexdump packednongd.hg
362 $ f -B 64 --size --sha1 --hexdump packednongd.hg
363 packednongd.hg: size=402, sha1=d3cc1417f0e8142cf9340aaaa520b660ad3ec3ea
363 packednongd.hg: size=426, sha1=79563ccd6ef779bcfe62a4da64f89a1b308e92e0
364 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
364 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
365 0010: 00 00 00 00 01 2d 00 1c 70 65 72 73 69 73 74 65 |.....-..persiste|
365 0010: 00 00 00 00 01 2d 00 34 70 65 72 73 69 73 74 65 |.....-.4persiste|
366 0020: 6e 74 2d 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f |nt-nodemap,revlo|
366 0020: 6e 74 2d 6e 6f 64 65 6d 61 70 2c 72 65 76 6c 6f |nt-nodemap,revlo|
367 0030: 67 76 31 00 64 61 74 61 2f 66 6f 6f 2e 69 00 36 |gv1.data/foo.i.6|
367 0030: 67 2d 63 6f 6d 70 72 65 73 73 69 6f 6e 2d 7a 73 |g-compression-zs|
368
368
369 $ hg debugbundle --spec packednongd.hg
369 $ hg debugbundle --spec packednongd.hg
370 none-packed1;requirements%3Dpersistent-nodemap%2Crevlogv1
370 none-packed1;requirements%3Dpersistent-nodemap%2Crevlog-compression-zstd%2Crevlogv1
371
371
372 #endif
372 #endif
373
373
374 #if reporevlogstore no-rust zstd
374 #if reporevlogstore no-rust zstd
375
375
376 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
376 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
377 writing 301 bytes for 3 files
377 writing 301 bytes for 3 files
378 bundle requirements: revlogv1
378 bundle requirements: revlog-compression-zstd, revlogv1
379
379
380 $ f -B 64 --size --sha1 --hexdump packednongd.hg
380 $ f -B 64 --size --sha1 --hexdump packednongd.hg
381 packednongd.hg: size=383, sha1=1d9c230238edd5d38907100b729ba72b1831fe6f
381 packednongd.hg: size=407, sha1=0b8714422b785ba8eb98c916b41ffd5fb994c9b5
382 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
382 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
383 0010: 00 00 00 00 01 2d 00 09 72 65 76 6c 6f 67 76 31 |.....-..revlogv1|
383 0010: 00 00 00 00 01 2d 00 21 72 65 76 6c 6f 67 2d 63 |.....-.!revlog-c|
384 0020: 00 64 61 74 61 2f 66 6f 6f 2e 69 00 36 34 0a 00 |.data/foo.i.64..|
384 0020: 6f 6d 70 72 65 73 73 69 6f 6e 2d 7a 73 74 64 2c |ompression-zstd,|
385 0030: 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
385 0030: 72 65 76 6c 6f 67 76 31 00 64 61 74 61 2f 66 6f |revlogv1.data/fo|
386
386
387 $ hg debugbundle --spec packednongd.hg
387 $ hg debugbundle --spec packednongd.hg
388 none-packed1;requirements%3Drevlogv1
388 none-packed1;requirements%3Drevlog-compression-zstd%2Crevlogv1
389
389
390
390
391 #endif
391 #endif
392
392
393 #if reporevlogstore no-rust no-zstd
393 #if reporevlogstore no-rust no-zstd
394
394
395 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
395 $ hg -R testnongd debugcreatestreamclonebundle packednongd.hg
396 writing 301 bytes for 3 files
396 writing 301 bytes for 3 files
397 bundle requirements: revlogv1
397 bundle requirements: revlogv1
398
398
399 $ f -B 64 --size --sha1 --hexdump packednongd.hg
399 $ f -B 64 --size --sha1 --hexdump packednongd.hg
400 packednongd.hg: size=383, sha1=1d9c230238edd5d38907100b729ba72b1831fe6f
400 packednongd.hg: size=383, sha1=1d9c230238edd5d38907100b729ba72b1831fe6f
401 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
401 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
402 0010: 00 00 00 00 01 2d 00 09 72 65 76 6c 6f 67 76 31 |.....-..revlogv1|
402 0010: 00 00 00 00 01 2d 00 09 72 65 76 6c 6f 67 76 31 |.....-..revlogv1|
403 0020: 00 64 61 74 61 2f 66 6f 6f 2e 69 00 36 34 0a 00 |.data/foo.i.64..|
403 0020: 00 64 61 74 61 2f 66 6f 6f 2e 69 00 36 34 0a 00 |.data/foo.i.64..|
404 0030: 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
404 0030: 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
405
405
406 $ hg debugbundle --spec packednongd.hg
406 $ hg debugbundle --spec packednongd.hg
407 none-packed1;requirements%3Drevlogv1
407 none-packed1;requirements%3Drevlogv1
408
408
409
409
410 #endif
410 #endif
411
411
412 #if reporevlogstore
412 #if reporevlogstore
413
413
414 Warning emitted when packed bundles contain secret changesets
414 Warning emitted when packed bundles contain secret changesets
415
415
416 $ hg init testsecret
416 $ hg init testsecret
417 $ cd testsecret
417 $ cd testsecret
418 $ touch foo
418 $ touch foo
419 $ hg -q commit -A -m initial
419 $ hg -q commit -A -m initial
420 $ hg phase --force --secret -r .
420 $ hg phase --force --secret -r .
421 $ cd ..
421 $ cd ..
422
422
423 #endif
423 #endif
424
424
425 #if reporevlogstore rust
425 #if reporevlogstore rust
426
426
427 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
427 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
428 (warning: stream clone bundle will contain secret revisions)
428 (warning: stream clone bundle will contain secret revisions)
429 writing 301 bytes for 3 files
429 writing 301 bytes for 3 files
430 bundle requirements: generaldelta, persistent-nodemap, revlogv1, sparserevlog
430 bundle requirements: generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog
431
431
432 #endif
432 #endif
433
433
434 #if reporevlogstore no-rust zstd
434 #if reporevlogstore no-rust zstd
435
435
436 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
436 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
437 (warning: stream clone bundle will contain secret revisions)
437 (warning: stream clone bundle will contain secret revisions)
438 writing 301 bytes for 3 files
438 writing 301 bytes for 3 files
439 bundle requirements: generaldelta, revlogv1, sparserevlog
439 bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, sparserevlog
440
440
441 #endif
441 #endif
442
442
443 #if reporevlogstore no-rust no-zstd
443 #if reporevlogstore no-rust no-zstd
444
444
445 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
445 $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
446 (warning: stream clone bundle will contain secret revisions)
446 (warning: stream clone bundle will contain secret revisions)
447 writing 301 bytes for 3 files
447 writing 301 bytes for 3 files
448 bundle requirements: generaldelta, revlogv1, sparserevlog
448 bundle requirements: generaldelta, revlogv1, sparserevlog
449
449
450 #endif
450 #endif
451
451
452 #if reporevlogstore
452 #if reporevlogstore
453
453
454 Unpacking packed1 bundles with "hg unbundle" isn't allowed
454 Unpacking packed1 bundles with "hg unbundle" isn't allowed
455
455
456 $ hg init packed
456 $ hg init packed
457 $ hg -R packed unbundle packed.hg
457 $ hg -R packed unbundle packed.hg
458 abort: packed bundles cannot be applied with "hg unbundle"
458 abort: packed bundles cannot be applied with "hg unbundle"
459 (use "hg debugapplystreamclonebundle")
459 (use "hg debugapplystreamclonebundle")
460 [10]
460 [10]
461
461
462 packed1 can be consumed from debug command
462 packed1 can be consumed from debug command
463
463
464 (this also confirms that streamclone-ed changes are visible via
464 (this also confirms that streamclone-ed changes are visible via
465 @filecache properties to in-process procedures before closing
465 @filecache properties to in-process procedures before closing
466 transaction)
466 transaction)
467
467
468 $ cat > $TESTTMP/showtip.py <<EOF
468 $ cat > $TESTTMP/showtip.py <<EOF
469 > from __future__ import absolute_import
469 > from __future__ import absolute_import
470 >
470 >
471 > def showtip(ui, repo, hooktype, **kwargs):
471 > def showtip(ui, repo, hooktype, **kwargs):
472 > ui.warn(b'%s: %s\n' % (hooktype, repo[b'tip'].hex()[:12]))
472 > ui.warn(b'%s: %s\n' % (hooktype, repo[b'tip'].hex()[:12]))
473 >
473 >
474 > def reposetup(ui, repo):
474 > def reposetup(ui, repo):
475 > # this confirms (and ensures) that (empty) 00changelog.i
475 > # this confirms (and ensures) that (empty) 00changelog.i
476 > # before streamclone is already cached as repo.changelog
476 > # before streamclone is already cached as repo.changelog
477 > ui.setconfig(b'hooks', b'pretxnopen.showtip', showtip)
477 > ui.setconfig(b'hooks', b'pretxnopen.showtip', showtip)
478 >
478 >
479 > # this confirms that streamclone-ed changes are visible to
479 > # this confirms that streamclone-ed changes are visible to
480 > # in-process procedures before closing transaction
480 > # in-process procedures before closing transaction
481 > ui.setconfig(b'hooks', b'pretxnclose.showtip', showtip)
481 > ui.setconfig(b'hooks', b'pretxnclose.showtip', showtip)
482 >
482 >
483 > # this confirms that streamclone-ed changes are still visible
483 > # this confirms that streamclone-ed changes are still visible
484 > # after closing transaction
484 > # after closing transaction
485 > ui.setconfig(b'hooks', b'txnclose.showtip', showtip)
485 > ui.setconfig(b'hooks', b'txnclose.showtip', showtip)
486 > EOF
486 > EOF
487 $ cat >> $HGRCPATH <<EOF
487 $ cat >> $HGRCPATH <<EOF
488 > [extensions]
488 > [extensions]
489 > showtip = $TESTTMP/showtip.py
489 > showtip = $TESTTMP/showtip.py
490 > EOF
490 > EOF
491
491
492 $ hg -R packed debugapplystreamclonebundle packed.hg
492 $ hg -R packed debugapplystreamclonebundle packed.hg
493 6 files to transfer, 2.60 KB of data
493 6 files to transfer, 2.60 KB of data
494 pretxnopen: 000000000000
494 pretxnopen: 000000000000
495 pretxnclose: aa35859c02ea
495 pretxnclose: aa35859c02ea
496 transferred 2.60 KB in * seconds (* */sec) (glob)
496 transferred 2.60 KB in * seconds (* */sec) (glob)
497 txnclose: aa35859c02ea
497 txnclose: aa35859c02ea
498
498
499 (for safety, confirm visibility of streamclone-ed changes by another
499 (for safety, confirm visibility of streamclone-ed changes by another
500 process, too)
500 process, too)
501
501
502 $ hg -R packed tip -T "{node|short}\n"
502 $ hg -R packed tip -T "{node|short}\n"
503 aa35859c02ea
503 aa35859c02ea
504
504
505 $ cat >> $HGRCPATH <<EOF
505 $ cat >> $HGRCPATH <<EOF
506 > [extensions]
506 > [extensions]
507 > showtip = !
507 > showtip = !
508 > EOF
508 > EOF
509
509
510 Does not work on non-empty repo
510 Does not work on non-empty repo
511
511
512 $ hg -R packed debugapplystreamclonebundle packed.hg
512 $ hg -R packed debugapplystreamclonebundle packed.hg
513 abort: cannot apply stream clone bundle on non-empty repo
513 abort: cannot apply stream clone bundle on non-empty repo
514 [255]
514 [255]
515
515
516 #endif
516 #endif
517
517
518 Create partial clones
518 Create partial clones
519
519
520 $ rm -r empty
520 $ rm -r empty
521 $ hg init empty
521 $ hg init empty
522 $ hg clone -r 3 test partial
522 $ hg clone -r 3 test partial
523 adding changesets
523 adding changesets
524 adding manifests
524 adding manifests
525 adding file changes
525 adding file changes
526 added 4 changesets with 4 changes to 1 files
526 added 4 changesets with 4 changes to 1 files
527 new changesets f9ee2f85a263:eebf5a27f8ca
527 new changesets f9ee2f85a263:eebf5a27f8ca
528 updating to branch default
528 updating to branch default
529 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
529 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
530 $ hg clone partial partial2
530 $ hg clone partial partial2
531 updating to branch default
531 updating to branch default
532 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
532 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
533 $ cd partial
533 $ cd partial
534
534
535 #if repobundlerepo
535 #if repobundlerepo
536
536
537 Log -R full.hg in partial
537 Log -R full.hg in partial
538
538
539 $ hg -R bundle://../full.hg log -T phases
539 $ hg -R bundle://../full.hg log -T phases
540 changeset: 8:aa35859c02ea
540 changeset: 8:aa35859c02ea
541 tag: tip
541 tag: tip
542 phase: draft
542 phase: draft
543 parent: 3:eebf5a27f8ca
543 parent: 3:eebf5a27f8ca
544 user: test
544 user: test
545 date: Thu Jan 01 00:00:00 1970 +0000
545 date: Thu Jan 01 00:00:00 1970 +0000
546 summary: 0.3m
546 summary: 0.3m
547
547
548 changeset: 7:a6a34bfa0076
548 changeset: 7:a6a34bfa0076
549 phase: draft
549 phase: draft
550 user: test
550 user: test
551 date: Thu Jan 01 00:00:00 1970 +0000
551 date: Thu Jan 01 00:00:00 1970 +0000
552 summary: 1.3m
552 summary: 1.3m
553
553
554 changeset: 6:7373c1169842
554 changeset: 6:7373c1169842
555 phase: draft
555 phase: draft
556 user: test
556 user: test
557 date: Thu Jan 01 00:00:00 1970 +0000
557 date: Thu Jan 01 00:00:00 1970 +0000
558 summary: 1.3
558 summary: 1.3
559
559
560 changeset: 5:1bb50a9436a7
560 changeset: 5:1bb50a9436a7
561 phase: draft
561 phase: draft
562 user: test
562 user: test
563 date: Thu Jan 01 00:00:00 1970 +0000
563 date: Thu Jan 01 00:00:00 1970 +0000
564 summary: 1.2
564 summary: 1.2
565
565
566 changeset: 4:095197eb4973
566 changeset: 4:095197eb4973
567 phase: draft
567 phase: draft
568 parent: 0:f9ee2f85a263
568 parent: 0:f9ee2f85a263
569 user: test
569 user: test
570 date: Thu Jan 01 00:00:00 1970 +0000
570 date: Thu Jan 01 00:00:00 1970 +0000
571 summary: 1.1
571 summary: 1.1
572
572
573 changeset: 3:eebf5a27f8ca
573 changeset: 3:eebf5a27f8ca
574 phase: public
574 phase: public
575 user: test
575 user: test
576 date: Thu Jan 01 00:00:00 1970 +0000
576 date: Thu Jan 01 00:00:00 1970 +0000
577 summary: 0.3
577 summary: 0.3
578
578
579 changeset: 2:e38ba6f5b7e0
579 changeset: 2:e38ba6f5b7e0
580 phase: public
580 phase: public
581 user: test
581 user: test
582 date: Thu Jan 01 00:00:00 1970 +0000
582 date: Thu Jan 01 00:00:00 1970 +0000
583 summary: 0.2
583 summary: 0.2
584
584
585 changeset: 1:34c2bf6b0626
585 changeset: 1:34c2bf6b0626
586 phase: public
586 phase: public
587 user: test
587 user: test
588 date: Thu Jan 01 00:00:00 1970 +0000
588 date: Thu Jan 01 00:00:00 1970 +0000
589 summary: 0.1
589 summary: 0.1
590
590
591 changeset: 0:f9ee2f85a263
591 changeset: 0:f9ee2f85a263
592 phase: public
592 phase: public
593 user: test
593 user: test
594 date: Thu Jan 01 00:00:00 1970 +0000
594 date: Thu Jan 01 00:00:00 1970 +0000
595 summary: 0.0
595 summary: 0.0
596
596
597
597
598 Incoming full.hg in partial
598 Incoming full.hg in partial
599
599
600 $ hg incoming bundle://../full.hg
600 $ hg incoming bundle://../full.hg
601 comparing with bundle:../full.hg
601 comparing with bundle:../full.hg
602 searching for changes
602 searching for changes
603 changeset: 4:095197eb4973
603 changeset: 4:095197eb4973
604 parent: 0:f9ee2f85a263
604 parent: 0:f9ee2f85a263
605 user: test
605 user: test
606 date: Thu Jan 01 00:00:00 1970 +0000
606 date: Thu Jan 01 00:00:00 1970 +0000
607 summary: 1.1
607 summary: 1.1
608
608
609 changeset: 5:1bb50a9436a7
609 changeset: 5:1bb50a9436a7
610 user: test
610 user: test
611 date: Thu Jan 01 00:00:00 1970 +0000
611 date: Thu Jan 01 00:00:00 1970 +0000
612 summary: 1.2
612 summary: 1.2
613
613
614 changeset: 6:7373c1169842
614 changeset: 6:7373c1169842
615 user: test
615 user: test
616 date: Thu Jan 01 00:00:00 1970 +0000
616 date: Thu Jan 01 00:00:00 1970 +0000
617 summary: 1.3
617 summary: 1.3
618
618
619 changeset: 7:a6a34bfa0076
619 changeset: 7:a6a34bfa0076
620 user: test
620 user: test
621 date: Thu Jan 01 00:00:00 1970 +0000
621 date: Thu Jan 01 00:00:00 1970 +0000
622 summary: 1.3m
622 summary: 1.3m
623
623
624 changeset: 8:aa35859c02ea
624 changeset: 8:aa35859c02ea
625 tag: tip
625 tag: tip
626 parent: 3:eebf5a27f8ca
626 parent: 3:eebf5a27f8ca
627 user: test
627 user: test
628 date: Thu Jan 01 00:00:00 1970 +0000
628 date: Thu Jan 01 00:00:00 1970 +0000
629 summary: 0.3m
629 summary: 0.3m
630
630
631
631
632 Outgoing -R full.hg vs partial2 in partial
632 Outgoing -R full.hg vs partial2 in partial
633
633
634 $ hg -R bundle://../full.hg outgoing ../partial2
634 $ hg -R bundle://../full.hg outgoing ../partial2
635 comparing with ../partial2
635 comparing with ../partial2
636 searching for changes
636 searching for changes
637 changeset: 4:095197eb4973
637 changeset: 4:095197eb4973
638 parent: 0:f9ee2f85a263
638 parent: 0:f9ee2f85a263
639 user: test
639 user: test
640 date: Thu Jan 01 00:00:00 1970 +0000
640 date: Thu Jan 01 00:00:00 1970 +0000
641 summary: 1.1
641 summary: 1.1
642
642
643 changeset: 5:1bb50a9436a7
643 changeset: 5:1bb50a9436a7
644 user: test
644 user: test
645 date: Thu Jan 01 00:00:00 1970 +0000
645 date: Thu Jan 01 00:00:00 1970 +0000
646 summary: 1.2
646 summary: 1.2
647
647
648 changeset: 6:7373c1169842
648 changeset: 6:7373c1169842
649 user: test
649 user: test
650 date: Thu Jan 01 00:00:00 1970 +0000
650 date: Thu Jan 01 00:00:00 1970 +0000
651 summary: 1.3
651 summary: 1.3
652
652
653 changeset: 7:a6a34bfa0076
653 changeset: 7:a6a34bfa0076
654 user: test
654 user: test
655 date: Thu Jan 01 00:00:00 1970 +0000
655 date: Thu Jan 01 00:00:00 1970 +0000
656 summary: 1.3m
656 summary: 1.3m
657
657
658 changeset: 8:aa35859c02ea
658 changeset: 8:aa35859c02ea
659 tag: tip
659 tag: tip
660 parent: 3:eebf5a27f8ca
660 parent: 3:eebf5a27f8ca
661 user: test
661 user: test
662 date: Thu Jan 01 00:00:00 1970 +0000
662 date: Thu Jan 01 00:00:00 1970 +0000
663 summary: 0.3m
663 summary: 0.3m
664
664
665
665
666 Outgoing -R does-not-exist.hg vs partial2 in partial
666 Outgoing -R does-not-exist.hg vs partial2 in partial
667
667
668 $ hg -R bundle://../does-not-exist.hg outgoing ../partial2
668 $ hg -R bundle://../does-not-exist.hg outgoing ../partial2
669 abort: *../does-not-exist.hg* (glob)
669 abort: *../does-not-exist.hg* (glob)
670 [255]
670 [255]
671
671
672 #endif
672 #endif
673
673
674 $ cd ..
674 $ cd ..
675
675
676 hide outer repo
676 hide outer repo
677 $ hg init
677 $ hg init
678
678
679 Direct clone from bundle (all-history)
679 Direct clone from bundle (all-history)
680
680
681 #if repobundlerepo
681 #if repobundlerepo
682
682
683 $ hg clone full.hg full-clone
683 $ hg clone full.hg full-clone
684 requesting all changes
684 requesting all changes
685 adding changesets
685 adding changesets
686 adding manifests
686 adding manifests
687 adding file changes
687 adding file changes
688 added 9 changesets with 7 changes to 4 files (+1 heads)
688 added 9 changesets with 7 changes to 4 files (+1 heads)
689 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
689 new changesets f9ee2f85a263:aa35859c02ea (9 drafts)
690 updating to branch default
690 updating to branch default
691 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
691 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
692 $ hg -R full-clone heads
692 $ hg -R full-clone heads
693 changeset: 8:aa35859c02ea
693 changeset: 8:aa35859c02ea
694 tag: tip
694 tag: tip
695 parent: 3:eebf5a27f8ca
695 parent: 3:eebf5a27f8ca
696 user: test
696 user: test
697 date: Thu Jan 01 00:00:00 1970 +0000
697 date: Thu Jan 01 00:00:00 1970 +0000
698 summary: 0.3m
698 summary: 0.3m
699
699
700 changeset: 7:a6a34bfa0076
700 changeset: 7:a6a34bfa0076
701 user: test
701 user: test
702 date: Thu Jan 01 00:00:00 1970 +0000
702 date: Thu Jan 01 00:00:00 1970 +0000
703 summary: 1.3m
703 summary: 1.3m
704
704
705 $ rm -r full-clone
705 $ rm -r full-clone
706
706
707 When cloning from a non-copiable repository into '', do not
707 When cloning from a non-copiable repository into '', do not
708 recurse infinitely (issue2528)
708 recurse infinitely (issue2528)
709
709
710 $ hg clone full.hg ''
710 $ hg clone full.hg ''
711 abort: empty destination path is not valid
711 abort: empty destination path is not valid
712 [10]
712 [10]
713
713
714 test for https://bz.mercurial-scm.org/216
714 test for https://bz.mercurial-scm.org/216
715
715
716 Unbundle incremental bundles into fresh empty in one go
716 Unbundle incremental bundles into fresh empty in one go
717
717
718 $ rm -r empty
718 $ rm -r empty
719 $ hg init empty
719 $ hg init empty
720 $ hg -R test bundle --base null -r 0 ../0.hg
720 $ hg -R test bundle --base null -r 0 ../0.hg
721 1 changesets found
721 1 changesets found
722 $ hg -R test bundle --base 0 -r 1 ../1.hg
722 $ hg -R test bundle --base 0 -r 1 ../1.hg
723 1 changesets found
723 1 changesets found
724 $ hg -R empty unbundle -u ../0.hg ../1.hg
724 $ hg -R empty unbundle -u ../0.hg ../1.hg
725 adding changesets
725 adding changesets
726 adding manifests
726 adding manifests
727 adding file changes
727 adding file changes
728 added 1 changesets with 1 changes to 1 files
728 added 1 changesets with 1 changes to 1 files
729 new changesets f9ee2f85a263 (1 drafts)
729 new changesets f9ee2f85a263 (1 drafts)
730 adding changesets
730 adding changesets
731 adding manifests
731 adding manifests
732 adding file changes
732 adding file changes
733 added 1 changesets with 1 changes to 1 files
733 added 1 changesets with 1 changes to 1 files
734 new changesets 34c2bf6b0626 (1 drafts)
734 new changesets 34c2bf6b0626 (1 drafts)
735 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
735 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
736
736
737 View full contents of the bundle
737 View full contents of the bundle
738 $ hg -R test bundle --base null -r 3 ../partial.hg
738 $ hg -R test bundle --base null -r 3 ../partial.hg
739 4 changesets found
739 4 changesets found
740 $ cd test
740 $ cd test
741 $ hg -R ../../partial.hg log -r "bundle()"
741 $ hg -R ../../partial.hg log -r "bundle()"
742 changeset: 0:f9ee2f85a263
742 changeset: 0:f9ee2f85a263
743 user: test
743 user: test
744 date: Thu Jan 01 00:00:00 1970 +0000
744 date: Thu Jan 01 00:00:00 1970 +0000
745 summary: 0.0
745 summary: 0.0
746
746
747 changeset: 1:34c2bf6b0626
747 changeset: 1:34c2bf6b0626
748 user: test
748 user: test
749 date: Thu Jan 01 00:00:00 1970 +0000
749 date: Thu Jan 01 00:00:00 1970 +0000
750 summary: 0.1
750 summary: 0.1
751
751
752 changeset: 2:e38ba6f5b7e0
752 changeset: 2:e38ba6f5b7e0
753 user: test
753 user: test
754 date: Thu Jan 01 00:00:00 1970 +0000
754 date: Thu Jan 01 00:00:00 1970 +0000
755 summary: 0.2
755 summary: 0.2
756
756
757 changeset: 3:eebf5a27f8ca
757 changeset: 3:eebf5a27f8ca
758 user: test
758 user: test
759 date: Thu Jan 01 00:00:00 1970 +0000
759 date: Thu Jan 01 00:00:00 1970 +0000
760 summary: 0.3
760 summary: 0.3
761
761
762 $ cd ..
762 $ cd ..
763
763
764 #endif
764 #endif
765
765
766 test for 540d1059c802
766 test for 540d1059c802
767
767
768 $ hg init orig
768 $ hg init orig
769 $ cd orig
769 $ cd orig
770 $ echo foo > foo
770 $ echo foo > foo
771 $ hg add foo
771 $ hg add foo
772 $ hg ci -m 'add foo'
772 $ hg ci -m 'add foo'
773
773
774 $ hg clone . ../copy
774 $ hg clone . ../copy
775 updating to branch default
775 updating to branch default
776 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
776 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
777 $ hg tag foo
777 $ hg tag foo
778
778
779 $ cd ../copy
779 $ cd ../copy
780 $ echo >> foo
780 $ echo >> foo
781 $ hg ci -m 'change foo'
781 $ hg ci -m 'change foo'
782 $ hg bundle ../bundle.hg ../orig
782 $ hg bundle ../bundle.hg ../orig
783 searching for changes
783 searching for changes
784 1 changesets found
784 1 changesets found
785
785
786 $ cd ..
786 $ cd ..
787
787
788 #if repobundlerepo
788 #if repobundlerepo
789 $ cd orig
789 $ cd orig
790 $ hg incoming ../bundle.hg
790 $ hg incoming ../bundle.hg
791 comparing with ../bundle.hg
791 comparing with ../bundle.hg
792 searching for changes
792 searching for changes
793 changeset: 2:ed1b79f46b9a
793 changeset: 2:ed1b79f46b9a
794 tag: tip
794 tag: tip
795 parent: 0:bbd179dfa0a7
795 parent: 0:bbd179dfa0a7
796 user: test
796 user: test
797 date: Thu Jan 01 00:00:00 1970 +0000
797 date: Thu Jan 01 00:00:00 1970 +0000
798 summary: change foo
798 summary: change foo
799
799
800 $ cd ..
800 $ cd ..
801
801
802 test bundle with # in the filename (issue2154):
802 test bundle with # in the filename (issue2154):
803
803
804 $ cp bundle.hg 'test#bundle.hg'
804 $ cp bundle.hg 'test#bundle.hg'
805 $ cd orig
805 $ cd orig
806 $ hg incoming '../test#bundle.hg'
806 $ hg incoming '../test#bundle.hg'
807 comparing with ../test
807 comparing with ../test
808 abort: unknown revision 'bundle.hg'
808 abort: unknown revision 'bundle.hg'
809 [10]
809 [10]
810
810
811 note that percent encoding is not handled:
811 note that percent encoding is not handled:
812
812
813 $ hg incoming ../test%23bundle.hg
813 $ hg incoming ../test%23bundle.hg
814 abort: repository ../test%23bundle.hg not found
814 abort: repository ../test%23bundle.hg not found
815 [255]
815 [255]
816 $ cd ..
816 $ cd ..
817
817
818 #endif
818 #endif
819
819
820 test to bundle revisions on the newly created branch (issue3828):
820 test to bundle revisions on the newly created branch (issue3828):
821
821
822 $ hg -q clone -U test test-clone
822 $ hg -q clone -U test test-clone
823 $ cd test
823 $ cd test
824
824
825 $ hg -q branch foo
825 $ hg -q branch foo
826 $ hg commit -m "create foo branch"
826 $ hg commit -m "create foo branch"
827 $ hg -q outgoing ../test-clone
827 $ hg -q outgoing ../test-clone
828 9:b4f5acb1ee27
828 9:b4f5acb1ee27
829 $ hg -q bundle --branch foo foo.hg ../test-clone
829 $ hg -q bundle --branch foo foo.hg ../test-clone
830 #if repobundlerepo
830 #if repobundlerepo
831 $ hg -R foo.hg -q log -r "bundle()"
831 $ hg -R foo.hg -q log -r "bundle()"
832 9:b4f5acb1ee27
832 9:b4f5acb1ee27
833 #endif
833 #endif
834
834
835 $ cd ..
835 $ cd ..
836
836
837 test for https://bz.mercurial-scm.org/1144
837 test for https://bz.mercurial-scm.org/1144
838
838
839 test that verify bundle does not traceback
839 test that verify bundle does not traceback
840
840
841 partial history bundle, fails w/ unknown parent
841 partial history bundle, fails w/ unknown parent
842
842
843 $ hg -R bundle.hg verify
843 $ hg -R bundle.hg verify
844 abort: 00changelog@bbd179dfa0a71671c253b3ae0aa1513b60d199fa: unknown parent
844 abort: 00changelog@bbd179dfa0a71671c253b3ae0aa1513b60d199fa: unknown parent
845 [50]
845 [50]
846
846
847 full history bundle, refuses to verify non-local repo
847 full history bundle, refuses to verify non-local repo
848
848
849 #if repobundlerepo
849 #if repobundlerepo
850 $ hg -R all.hg verify
850 $ hg -R all.hg verify
851 abort: cannot verify bundle or remote repos
851 abort: cannot verify bundle or remote repos
852 [255]
852 [255]
853 #endif
853 #endif
854
854
855 but, regular verify must continue to work
855 but, regular verify must continue to work
856
856
857 $ hg -R orig verify
857 $ hg -R orig verify
858 checking changesets
858 checking changesets
859 checking manifests
859 checking manifests
860 crosschecking files in changesets and manifests
860 crosschecking files in changesets and manifests
861 checking files
861 checking files
862 checked 2 changesets with 2 changes to 2 files
862 checked 2 changesets with 2 changes to 2 files
863
863
864 #if repobundlerepo
864 #if repobundlerepo
865 diff against bundle
865 diff against bundle
866
866
867 $ hg init b
867 $ hg init b
868 $ cd b
868 $ cd b
869 $ hg -R ../all.hg diff -r tip
869 $ hg -R ../all.hg diff -r tip
870 diff -r aa35859c02ea anotherfile
870 diff -r aa35859c02ea anotherfile
871 --- a/anotherfile Thu Jan 01 00:00:00 1970 +0000
871 --- a/anotherfile Thu Jan 01 00:00:00 1970 +0000
872 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
872 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
873 @@ -1,4 +0,0 @@
873 @@ -1,4 +0,0 @@
874 -0
874 -0
875 -1
875 -1
876 -2
876 -2
877 -3
877 -3
878 $ cd ..
878 $ cd ..
879 #endif
879 #endif
880
880
881 bundle single branch
881 bundle single branch
882
882
883 $ hg init branchy
883 $ hg init branchy
884 $ cd branchy
884 $ cd branchy
885 $ echo a >a
885 $ echo a >a
886 $ echo x >x
886 $ echo x >x
887 $ hg ci -Ama
887 $ hg ci -Ama
888 adding a
888 adding a
889 adding x
889 adding x
890 $ echo c >c
890 $ echo c >c
891 $ echo xx >x
891 $ echo xx >x
892 $ hg ci -Amc
892 $ hg ci -Amc
893 adding c
893 adding c
894 $ echo c1 >c1
894 $ echo c1 >c1
895 $ hg ci -Amc1
895 $ hg ci -Amc1
896 adding c1
896 adding c1
897 $ hg up 0
897 $ hg up 0
898 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
898 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
899 $ echo b >b
899 $ echo b >b
900 $ hg ci -Amb
900 $ hg ci -Amb
901 adding b
901 adding b
902 created new head
902 created new head
903 $ echo b1 >b1
903 $ echo b1 >b1
904 $ echo xx >x
904 $ echo xx >x
905 $ hg ci -Amb1
905 $ hg ci -Amb1
906 adding b1
906 adding b1
907 $ hg clone -q -r2 . part
907 $ hg clone -q -r2 . part
908
908
909 == bundling via incoming
909 == bundling via incoming
910
910
911 $ hg in -R part --bundle incoming.hg --template "{node}\n" .
911 $ hg in -R part --bundle incoming.hg --template "{node}\n" .
912 comparing with .
912 comparing with .
913 searching for changes
913 searching for changes
914 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
914 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
915 057f4db07f61970e1c11e83be79e9d08adc4dc31
915 057f4db07f61970e1c11e83be79e9d08adc4dc31
916
916
917 == bundling
917 == bundling
918
918
919 $ hg bundle bundle.hg part --debug --config progress.debug=true
919 $ hg bundle bundle.hg part --debug --config progress.debug=true
920 query 1; heads
920 query 1; heads
921 searching for changes
921 searching for changes
922 all remote heads known locally
922 all remote heads known locally
923 2 changesets found
923 2 changesets found
924 list of changesets:
924 list of changesets:
925 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
925 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
926 057f4db07f61970e1c11e83be79e9d08adc4dc31
926 057f4db07f61970e1c11e83be79e9d08adc4dc31
927 bundle2-output-bundle: "HG20", (1 params) 2 parts total
927 bundle2-output-bundle: "HG20", (1 params) 2 parts total
928 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
928 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
929 changesets: 1/2 chunks (50.00%)
929 changesets: 1/2 chunks (50.00%)
930 changesets: 2/2 chunks (100.00%)
930 changesets: 2/2 chunks (100.00%)
931 manifests: 1/2 chunks (50.00%)
931 manifests: 1/2 chunks (50.00%)
932 manifests: 2/2 chunks (100.00%)
932 manifests: 2/2 chunks (100.00%)
933 files: b 1/3 files (33.33%)
933 files: b 1/3 files (33.33%)
934 files: b1 2/3 files (66.67%)
934 files: b1 2/3 files (66.67%)
935 files: x 3/3 files (100.00%)
935 files: x 3/3 files (100.00%)
936 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
936 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
937
937
938 #if repobundlerepo
938 #if repobundlerepo
939 == Test for issue3441
939 == Test for issue3441
940
940
941 $ hg clone -q -r0 . part2
941 $ hg clone -q -r0 . part2
942 $ hg -q -R part2 pull bundle.hg
942 $ hg -q -R part2 pull bundle.hg
943 $ hg -R part2 verify
943 $ hg -R part2 verify
944 checking changesets
944 checking changesets
945 checking manifests
945 checking manifests
946 crosschecking files in changesets and manifests
946 crosschecking files in changesets and manifests
947 checking files
947 checking files
948 checked 3 changesets with 5 changes to 4 files
948 checked 3 changesets with 5 changes to 4 files
949 #endif
949 #endif
950
950
951 == Test bundling no commits
951 == Test bundling no commits
952
952
953 $ hg bundle -r 'public()' no-output.hg
953 $ hg bundle -r 'public()' no-output.hg
954 abort: no commits to bundle
954 abort: no commits to bundle
955 [10]
955 [10]
956
956
957 $ cd ..
957 $ cd ..
958
958
959 When user merges to the revision existing only in the bundle,
959 When user merges to the revision existing only in the bundle,
960 it should show warning that second parent of the working
960 it should show warning that second parent of the working
961 directory does not exist
961 directory does not exist
962
962
963 $ hg init update2bundled
963 $ hg init update2bundled
964 $ cd update2bundled
964 $ cd update2bundled
965 $ cat <<EOF >> .hg/hgrc
965 $ cat <<EOF >> .hg/hgrc
966 > [extensions]
966 > [extensions]
967 > strip =
967 > strip =
968 > EOF
968 > EOF
969 $ echo "aaa" >> a
969 $ echo "aaa" >> a
970 $ hg commit -A -m 0
970 $ hg commit -A -m 0
971 adding a
971 adding a
972 $ echo "bbb" >> b
972 $ echo "bbb" >> b
973 $ hg commit -A -m 1
973 $ hg commit -A -m 1
974 adding b
974 adding b
975 $ echo "ccc" >> c
975 $ echo "ccc" >> c
976 $ hg commit -A -m 2
976 $ hg commit -A -m 2
977 adding c
977 adding c
978 $ hg update -r 1
978 $ hg update -r 1
979 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
979 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
980 $ echo "ddd" >> d
980 $ echo "ddd" >> d
981 $ hg commit -A -m 3
981 $ hg commit -A -m 3
982 adding d
982 adding d
983 created new head
983 created new head
984 $ hg update -r 2
984 $ hg update -r 2
985 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
985 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
986 $ hg log -G
986 $ hg log -G
987 o changeset: 3:8bd3e1f196af
987 o changeset: 3:8bd3e1f196af
988 | tag: tip
988 | tag: tip
989 | parent: 1:a01eca7af26d
989 | parent: 1:a01eca7af26d
990 | user: test
990 | user: test
991 | date: Thu Jan 01 00:00:00 1970 +0000
991 | date: Thu Jan 01 00:00:00 1970 +0000
992 | summary: 3
992 | summary: 3
993 |
993 |
994 | @ changeset: 2:4652c276ac4f
994 | @ changeset: 2:4652c276ac4f
995 |/ user: test
995 |/ user: test
996 | date: Thu Jan 01 00:00:00 1970 +0000
996 | date: Thu Jan 01 00:00:00 1970 +0000
997 | summary: 2
997 | summary: 2
998 |
998 |
999 o changeset: 1:a01eca7af26d
999 o changeset: 1:a01eca7af26d
1000 | user: test
1000 | user: test
1001 | date: Thu Jan 01 00:00:00 1970 +0000
1001 | date: Thu Jan 01 00:00:00 1970 +0000
1002 | summary: 1
1002 | summary: 1
1003 |
1003 |
1004 o changeset: 0:4fe08cd4693e
1004 o changeset: 0:4fe08cd4693e
1005 user: test
1005 user: test
1006 date: Thu Jan 01 00:00:00 1970 +0000
1006 date: Thu Jan 01 00:00:00 1970 +0000
1007 summary: 0
1007 summary: 0
1008
1008
1009
1009
1010 #if repobundlerepo
1010 #if repobundlerepo
1011 $ hg bundle --base 1 -r 3 ../update2bundled.hg
1011 $ hg bundle --base 1 -r 3 ../update2bundled.hg
1012 1 changesets found
1012 1 changesets found
1013 $ hg strip -r 3
1013 $ hg strip -r 3
1014 saved backup bundle to $TESTTMP/update2bundled/.hg/strip-backup/8bd3e1f196af-017e56d8-backup.hg
1014 saved backup bundle to $TESTTMP/update2bundled/.hg/strip-backup/8bd3e1f196af-017e56d8-backup.hg
1015 $ hg merge -R ../update2bundled.hg -r 3
1015 $ hg merge -R ../update2bundled.hg -r 3
1016 setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
1016 setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
1017 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1017 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1018 (branch merge, don't forget to commit)
1018 (branch merge, don't forget to commit)
1019
1019
1020 When user updates to the revision existing only in the bundle,
1020 When user updates to the revision existing only in the bundle,
1021 it should show warning
1021 it should show warning
1022
1022
1023 $ hg update -R ../update2bundled.hg --clean -r 3
1023 $ hg update -R ../update2bundled.hg --clean -r 3
1024 setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
1024 setting parent to node 8bd3e1f196af289b2b121be08031e76d7ae92098 that only exists in the bundle
1025 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1025 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1026
1026
1027 When user updates to the revision existing in the local repository
1027 When user updates to the revision existing in the local repository
1028 the warning shouldn't be emitted
1028 the warning shouldn't be emitted
1029
1029
1030 $ hg update -R ../update2bundled.hg -r 0
1030 $ hg update -R ../update2bundled.hg -r 0
1031 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1031 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1032 #endif
1032 #endif
1033
1033
1034 Test the option that create slim bundle
1034 Test the option that create slim bundle
1035
1035
1036 $ hg bundle -a --config devel.bundle.delta=p1 ./slim.hg
1036 $ hg bundle -a --config devel.bundle.delta=p1 ./slim.hg
1037 3 changesets found
1037 3 changesets found
1038
1038
1039 Test the option that create and no-delta's bundle
1039 Test the option that create and no-delta's bundle
1040 $ hg bundle -a --config devel.bundle.delta=full ./full.hg
1040 $ hg bundle -a --config devel.bundle.delta=full ./full.hg
1041 3 changesets found
1041 3 changesets found
@@ -1,639 +1,640 b''
1 #require no-reposimplestore no-chg
1 #require no-reposimplestore no-chg
2
2
3 Set up a server
3 Set up a server
4
4
5 $ hg init server
5 $ hg init server
6 $ cd server
6 $ cd server
7 $ cat >> .hg/hgrc << EOF
7 $ cat >> .hg/hgrc << EOF
8 > [extensions]
8 > [extensions]
9 > clonebundles =
9 > clonebundles =
10 > EOF
10 > EOF
11
11
12 $ touch foo
12 $ touch foo
13 $ hg -q commit -A -m 'add foo'
13 $ hg -q commit -A -m 'add foo'
14 $ touch bar
14 $ touch bar
15 $ hg -q commit -A -m 'add bar'
15 $ hg -q commit -A -m 'add bar'
16
16
17 $ hg serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
17 $ hg serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
18 $ cat hg.pid >> $DAEMON_PIDS
18 $ cat hg.pid >> $DAEMON_PIDS
19 $ cd ..
19 $ cd ..
20
20
21 Missing manifest should not result in server lookup
21 Missing manifest should not result in server lookup
22
22
23 $ hg --verbose clone -U http://localhost:$HGPORT no-manifest
23 $ hg --verbose clone -U http://localhost:$HGPORT no-manifest
24 requesting all changes
24 requesting all changes
25 adding changesets
25 adding changesets
26 adding manifests
26 adding manifests
27 adding file changes
27 adding file changes
28 added 2 changesets with 2 changes to 2 files
28 added 2 changesets with 2 changes to 2 files
29 new changesets 53245c60e682:aaff8d2ffbbf
29 new changesets 53245c60e682:aaff8d2ffbbf
30 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
30 (sent 3 HTTP requests and * bytes; received * bytes in responses) (glob)
31
31
32 $ cat server/access.log
32 $ cat server/access.log
33 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
33 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
34 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
34 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
35 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae7877e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
35 $LOCALIP - - [$LOGDATE$] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:bookmarks=1&$USUAL_BUNDLE_CAPS$&cg=1&common=0000000000000000000000000000000000000000&heads=aaff8d2ffbbf07a46dd1f05d8ae7877e3f56e2a2&listkeys=bookmarks&phases=1 x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
36
36
37 Empty manifest file results in retrieval
37 Empty manifest file results in retrieval
38 (the extension only checks if the manifest file exists)
38 (the extension only checks if the manifest file exists)
39
39
40 $ touch server/.hg/clonebundles.manifest
40 $ touch server/.hg/clonebundles.manifest
41 $ hg --verbose clone -U http://localhost:$HGPORT empty-manifest
41 $ hg --verbose clone -U http://localhost:$HGPORT empty-manifest
42 no clone bundles available on remote; falling back to regular clone
42 no clone bundles available on remote; falling back to regular clone
43 requesting all changes
43 requesting all changes
44 adding changesets
44 adding changesets
45 adding manifests
45 adding manifests
46 adding file changes
46 adding file changes
47 added 2 changesets with 2 changes to 2 files
47 added 2 changesets with 2 changes to 2 files
48 new changesets 53245c60e682:aaff8d2ffbbf
48 new changesets 53245c60e682:aaff8d2ffbbf
49 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
49 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
50
50
51 Manifest file with invalid URL aborts
51 Manifest file with invalid URL aborts
52
52
53 $ echo 'http://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest
53 $ echo 'http://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest
54 $ hg clone http://localhost:$HGPORT 404-url
54 $ hg clone http://localhost:$HGPORT 404-url
55 applying clone bundle from http://does.not.exist/bundle.hg
55 applying clone bundle from http://does.not.exist/bundle.hg
56 error fetching bundle: (.* not known|(\[Errno -?\d+] )?([Nn]o address associated with (host)?name|Temporary failure in name resolution|Name does not resolve)) (re) (no-windows !)
56 error fetching bundle: (.* not known|(\[Errno -?\d+] )?([Nn]o address associated with (host)?name|Temporary failure in name resolution|Name does not resolve)) (re) (no-windows !)
57 error fetching bundle: [Errno 1100*] getaddrinfo failed (glob) (windows !)
57 error fetching bundle: [Errno 1100*] getaddrinfo failed (glob) (windows !)
58 abort: error applying bundle
58 abort: error applying bundle
59 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
59 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
60 [255]
60 [255]
61
61
62 Server is not running aborts
62 Server is not running aborts
63
63
64 $ echo "http://localhost:$HGPORT1/bundle.hg" > server/.hg/clonebundles.manifest
64 $ echo "http://localhost:$HGPORT1/bundle.hg" > server/.hg/clonebundles.manifest
65 $ hg clone http://localhost:$HGPORT server-not-runner
65 $ hg clone http://localhost:$HGPORT server-not-runner
66 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
66 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
67 error fetching bundle: (.* refused.*|Protocol not supported|(.* )?\$EADDRNOTAVAIL\$|.* No route to host) (re)
67 error fetching bundle: (.* refused.*|Protocol not supported|(.* )?\$EADDRNOTAVAIL\$|.* No route to host) (re)
68 abort: error applying bundle
68 abort: error applying bundle
69 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
69 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
70 [255]
70 [255]
71
71
72 Server returns 404
72 Server returns 404
73
73
74 $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
74 $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
75 $ cat http.pid >> $DAEMON_PIDS
75 $ cat http.pid >> $DAEMON_PIDS
76 $ hg clone http://localhost:$HGPORT running-404
76 $ hg clone http://localhost:$HGPORT running-404
77 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
77 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
78 HTTP error fetching bundle: HTTP Error 404: File not found
78 HTTP error fetching bundle: HTTP Error 404: File not found
79 abort: error applying bundle
79 abort: error applying bundle
80 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
80 (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false")
81 [255]
81 [255]
82
82
83 We can override failure to fall back to regular clone
83 We can override failure to fall back to regular clone
84
84
85 $ hg --config ui.clonebundlefallback=true clone -U http://localhost:$HGPORT 404-fallback
85 $ hg --config ui.clonebundlefallback=true clone -U http://localhost:$HGPORT 404-fallback
86 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
86 applying clone bundle from http://localhost:$HGPORT1/bundle.hg
87 HTTP error fetching bundle: HTTP Error 404: File not found
87 HTTP error fetching bundle: HTTP Error 404: File not found
88 falling back to normal clone
88 falling back to normal clone
89 requesting all changes
89 requesting all changes
90 adding changesets
90 adding changesets
91 adding manifests
91 adding manifests
92 adding file changes
92 adding file changes
93 added 2 changesets with 2 changes to 2 files
93 added 2 changesets with 2 changes to 2 files
94 new changesets 53245c60e682:aaff8d2ffbbf
94 new changesets 53245c60e682:aaff8d2ffbbf
95
95
96 Bundle with partial content works
96 Bundle with partial content works
97
97
98 $ hg -R server bundle --type gzip-v1 --base null -r 53245c60e682 partial.hg
98 $ hg -R server bundle --type gzip-v1 --base null -r 53245c60e682 partial.hg
99 1 changesets found
99 1 changesets found
100
100
101 We verify exact bundle content as an extra check against accidental future
101 We verify exact bundle content as an extra check against accidental future
102 changes. If this output changes, we could break old clients.
102 changes. If this output changes, we could break old clients.
103
103
104 $ f --size --hexdump partial.hg
104 $ f --size --hexdump partial.hg
105 partial.hg: size=207
105 partial.hg: size=207
106 0000: 48 47 31 30 47 5a 78 9c 63 60 60 98 17 ac 12 93 |HG10GZx.c``.....|
106 0000: 48 47 31 30 47 5a 78 9c 63 60 60 98 17 ac 12 93 |HG10GZx.c``.....|
107 0010: f0 ac a9 23 45 70 cb bf 0d 5f 59 4e 4a 7f 79 21 |...#Ep..._YNJ.y!|
107 0010: f0 ac a9 23 45 70 cb bf 0d 5f 59 4e 4a 7f 79 21 |...#Ep..._YNJ.y!|
108 0020: 9b cc 40 24 20 a0 d7 ce 2c d1 38 25 cd 24 25 d5 |..@$ ...,.8%.$%.|
108 0020: 9b cc 40 24 20 a0 d7 ce 2c d1 38 25 cd 24 25 d5 |..@$ ...,.8%.$%.|
109 0030: d8 c2 22 cd 38 d9 24 cd 22 d5 c8 22 cd 24 cd 32 |..".8.$."..".$.2|
109 0030: d8 c2 22 cd 38 d9 24 cd 22 d5 c8 22 cd 24 cd 32 |..".8.$."..".$.2|
110 0040: d1 c2 d0 c4 c8 d2 32 d1 38 39 29 c9 34 cd d4 80 |......2.89).4...|
110 0040: d1 c2 d0 c4 c8 d2 32 d1 38 39 29 c9 34 cd d4 80 |......2.89).4...|
111 0050: ab 24 b5 b8 84 cb 40 c1 80 2b 2d 3f 9f 8b 2b 31 |.$....@..+-?..+1|
111 0050: ab 24 b5 b8 84 cb 40 c1 80 2b 2d 3f 9f 8b 2b 31 |.$....@..+-?..+1|
112 0060: 25 45 01 c8 80 9a d2 9b 65 fb e5 9e 45 bf 8d 7f |%E......e...E...|
112 0060: 25 45 01 c8 80 9a d2 9b 65 fb e5 9e 45 bf 8d 7f |%E......e...E...|
113 0070: 9f c6 97 9f 2b 44 34 67 d9 ec 8e 0f a0 92 0b 75 |....+D4g.......u|
113 0070: 9f c6 97 9f 2b 44 34 67 d9 ec 8e 0f a0 92 0b 75 |....+D4g.......u|
114 0080: 41 d6 24 59 18 a4 a4 9a a6 18 1a 5b 98 9b 5a 98 |A.$Y.......[..Z.|
114 0080: 41 d6 24 59 18 a4 a4 9a a6 18 1a 5b 98 9b 5a 98 |A.$Y.......[..Z.|
115 0090: 9a 18 26 9b a6 19 98 1a 99 99 26 a6 18 9a 98 24 |..&.......&....$|
115 0090: 9a 18 26 9b a6 19 98 1a 99 99 26 a6 18 9a 98 24 |..&.......&....$|
116 00a0: 26 59 a6 25 5a 98 a5 18 a6 24 71 41 35 b1 43 dc |&Y.%Z....$qA5.C.|
116 00a0: 26 59 a6 25 5a 98 a5 18 a6 24 71 41 35 b1 43 dc |&Y.%Z....$qA5.C.|
117 00b0: 16 b2 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 d7 8a |.....E..V....R..|
117 00b0: 16 b2 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 d7 8a |.....E..V....R..|
118 00c0: 78 ed fc d5 76 f1 36 35 dc 05 00 36 ed 5e c7 |x...v.65...6.^.|
118 00c0: 78 ed fc d5 76 f1 36 35 dc 05 00 36 ed 5e c7 |x...v.65...6.^.|
119
119
120 $ echo "http://localhost:$HGPORT1/partial.hg" > server/.hg/clonebundles.manifest
120 $ echo "http://localhost:$HGPORT1/partial.hg" > server/.hg/clonebundles.manifest
121 $ hg clone -U http://localhost:$HGPORT partial-bundle
121 $ hg clone -U http://localhost:$HGPORT partial-bundle
122 applying clone bundle from http://localhost:$HGPORT1/partial.hg
122 applying clone bundle from http://localhost:$HGPORT1/partial.hg
123 adding changesets
123 adding changesets
124 adding manifests
124 adding manifests
125 adding file changes
125 adding file changes
126 added 1 changesets with 1 changes to 1 files
126 added 1 changesets with 1 changes to 1 files
127 finished applying clone bundle
127 finished applying clone bundle
128 searching for changes
128 searching for changes
129 adding changesets
129 adding changesets
130 adding manifests
130 adding manifests
131 adding file changes
131 adding file changes
132 added 1 changesets with 1 changes to 1 files
132 added 1 changesets with 1 changes to 1 files
133 new changesets aaff8d2ffbbf
133 new changesets aaff8d2ffbbf
134 1 local changesets published
134 1 local changesets published
135
135
136 Incremental pull doesn't fetch bundle
136 Incremental pull doesn't fetch bundle
137
137
138 $ hg clone -r 53245c60e682 -U http://localhost:$HGPORT partial-clone
138 $ hg clone -r 53245c60e682 -U http://localhost:$HGPORT partial-clone
139 adding changesets
139 adding changesets
140 adding manifests
140 adding manifests
141 adding file changes
141 adding file changes
142 added 1 changesets with 1 changes to 1 files
142 added 1 changesets with 1 changes to 1 files
143 new changesets 53245c60e682
143 new changesets 53245c60e682
144
144
145 $ cd partial-clone
145 $ cd partial-clone
146 $ hg pull
146 $ hg pull
147 pulling from http://localhost:$HGPORT/
147 pulling from http://localhost:$HGPORT/
148 searching for changes
148 searching for changes
149 adding changesets
149 adding changesets
150 adding manifests
150 adding manifests
151 adding file changes
151 adding file changes
152 added 1 changesets with 1 changes to 1 files
152 added 1 changesets with 1 changes to 1 files
153 new changesets aaff8d2ffbbf
153 new changesets aaff8d2ffbbf
154 (run 'hg update' to get a working copy)
154 (run 'hg update' to get a working copy)
155 $ cd ..
155 $ cd ..
156
156
157 Bundle with full content works
157 Bundle with full content works
158
158
159 $ hg -R server bundle --type gzip-v2 --base null -r tip full.hg
159 $ hg -R server bundle --type gzip-v2 --base null -r tip full.hg
160 2 changesets found
160 2 changesets found
161
161
162 Again, we perform an extra check against bundle content changes. If this content
162 Again, we perform an extra check against bundle content changes. If this content
163 changes, clone bundles produced by new Mercurial versions may not be readable
163 changes, clone bundles produced by new Mercurial versions may not be readable
164 by old clients.
164 by old clients.
165
165
166 $ f --size --hexdump full.hg
166 $ f --size --hexdump full.hg
167 full.hg: size=442
167 full.hg: size=442
168 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
168 0000: 48 47 32 30 00 00 00 0e 43 6f 6d 70 72 65 73 73 |HG20....Compress|
169 0010: 69 6f 6e 3d 47 5a 78 9c 63 60 60 d0 e4 76 f6 70 |ion=GZx.c``..v.p|
169 0010: 69 6f 6e 3d 47 5a 78 9c 63 60 60 d0 e4 76 f6 70 |ion=GZx.c``..v.p|
170 0020: f4 73 77 75 0f f2 0f 0d 60 00 02 46 46 76 26 4e |.swu....`..FFv&N|
170 0020: f4 73 77 75 0f f2 0f 0d 60 00 02 46 46 76 26 4e |.swu....`..FFv&N|
171 0030: c6 b2 d4 a2 e2 cc fc 3c 03 a3 bc a4 e4 8c c4 bc |.......<........|
171 0030: c6 b2 d4 a2 e2 cc fc 3c 03 a3 bc a4 e4 8c c4 bc |.......<........|
172 0040: f4 d4 62 23 06 06 e6 19 40 f9 4d c1 2a 31 09 cf |..b#....@.M.*1..|
172 0040: f4 d4 62 23 06 06 e6 19 40 f9 4d c1 2a 31 09 cf |..b#....@.M.*1..|
173 0050: 9a 3a 52 04 b7 fc db f0 95 e5 a4 f4 97 17 b2 c9 |.:R.............|
173 0050: 9a 3a 52 04 b7 fc db f0 95 e5 a4 f4 97 17 b2 c9 |.:R.............|
174 0060: 0c 14 00 02 e6 d9 99 25 1a a7 a4 99 a4 a4 1a 5b |.......%.......[|
174 0060: 0c 14 00 02 e6 d9 99 25 1a a7 a4 99 a4 a4 1a 5b |.......%.......[|
175 0070: 58 a4 19 27 9b a4 59 a4 1a 59 a4 99 a4 59 26 5a |X..'..Y..Y...Y&Z|
175 0070: 58 a4 19 27 9b a4 59 a4 1a 59 a4 99 a4 59 26 5a |X..'..Y..Y...Y&Z|
176 0080: 18 9a 18 59 5a 26 1a 27 27 25 99 a6 99 1a 70 95 |...YZ&.''%....p.|
176 0080: 18 9a 18 59 5a 26 1a 27 27 25 99 a6 99 1a 70 95 |...YZ&.''%....p.|
177 0090: a4 16 97 70 19 28 18 70 a5 e5 e7 73 71 25 a6 a4 |...p.(.p...sq%..|
177 0090: a4 16 97 70 19 28 18 70 a5 e5 e7 73 71 25 a6 a4 |...p.(.p...sq%..|
178 00a0: 28 00 19 20 17 af fa df ab ff 7b 3f fb 92 dc 8b |(.. ......{?....|
178 00a0: 28 00 19 20 17 af fa df ab ff 7b 3f fb 92 dc 8b |(.. ......{?....|
179 00b0: 1f 62 bb 9e b7 d7 d9 87 3d 5a 44 89 2f b0 99 87 |.b......=ZD./...|
179 00b0: 1f 62 bb 9e b7 d7 d9 87 3d 5a 44 89 2f b0 99 87 |.b......=ZD./...|
180 00c0: ec e2 54 63 43 e3 b4 64 43 73 23 33 43 53 0b 63 |..TcC..dCs#3CS.c|
180 00c0: ec e2 54 63 43 e3 b4 64 43 73 23 33 43 53 0b 63 |..TcC..dCs#3CS.c|
181 00d0: d3 14 23 03 a0 fb 2c 2c 0c d3 80 1e 30 49 49 b1 |..#...,,....0II.|
181 00d0: d3 14 23 03 a0 fb 2c 2c 0c d3 80 1e 30 49 49 b1 |..#...,,....0II.|
182 00e0: 4c 4a 32 48 33 30 b0 34 42 b8 38 29 b1 08 e2 62 |LJ2H30.4B.8)...b|
182 00e0: 4c 4a 32 48 33 30 b0 34 42 b8 38 29 b1 08 e2 62 |LJ2H30.4B.8)...b|
183 00f0: 20 03 6a ca c2 2c db 2f f7 2c fa 6d fc fb 34 be | .j..,./.,.m..4.|
183 00f0: 20 03 6a ca c2 2c db 2f f7 2c fa 6d fc fb 34 be | .j..,./.,.m..4.|
184 0100: fc 5c 21 a2 39 cb 66 77 7c 00 0d c3 59 17 14 58 |.\!.9.fw|...Y..X|
184 0100: fc 5c 21 a2 39 cb 66 77 7c 00 0d c3 59 17 14 58 |.\!.9.fw|...Y..X|
185 0110: 49 16 06 29 a9 a6 29 86 c6 16 e6 a6 16 a6 26 86 |I..)..).......&.|
185 0110: 49 16 06 29 a9 a6 29 86 c6 16 e6 a6 16 a6 26 86 |I..)..).......&.|
186 0120: c9 a6 69 06 a6 46 66 a6 89 29 86 26 26 89 49 96 |..i..Ff..).&&.I.|
186 0120: c9 a6 69 06 a6 46 66 a6 89 29 86 26 26 89 49 96 |..i..Ff..).&&.I.|
187 0130: 69 89 16 66 29 86 29 49 5c 20 07 3e 16 fe 23 ae |i..f).)I\ .>..#.|
187 0130: 69 89 16 66 29 86 29 49 5c 20 07 3e 16 fe 23 ae |i..f).)I\ .>..#.|
188 0140: 26 da 1c ab 10 1f d1 f8 e3 b3 ef cd dd fc 0c 93 |&...............|
188 0140: 26 da 1c ab 10 1f d1 f8 e3 b3 ef cd dd fc 0c 93 |&...............|
189 0150: 88 75 34 36 75 04 82 55 17 14 36 a4 38 10 04 d8 |.u46u..U..6.8...|
189 0150: 88 75 34 36 75 04 82 55 17 14 36 a4 38 10 04 d8 |.u46u..U..6.8...|
190 0160: 21 01 9a b1 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 |!......E..V....R|
190 0160: 21 01 9a b1 83 f7 e9 45 8b d2 56 c7 a3 1f 82 52 |!......E..V....R|
191 0170: d7 8a 78 ed fc d5 76 f1 36 25 81 89 c7 ad ec 90 |..x...v.6%......|
191 0170: d7 8a 78 ed fc d5 76 f1 36 25 81 89 c7 ad ec 90 |..x...v.6%......|
192 0180: 54 47 75 2b 89 48 b1 b2 62 c9 89 c9 19 a9 56 45 |TGu+.H..b.....VE|
192 0180: 54 47 75 2b 89 48 b1 b2 62 c9 89 c9 19 a9 56 45 |TGu+.H..b.....VE|
193 0190: a9 65 ba 49 45 89 79 c9 19 ba 60 01 a0 14 23 58 |.e.IE.y...`...#X|
193 0190: a9 65 ba 49 45 89 79 c9 19 ba 60 01 a0 14 23 58 |.e.IE.y...`...#X|
194 01a0: 81 35 c8 7d 40 cc 04 e2 a4 a4 a6 25 96 e6 94 60 |.5.}@......%...`|
194 01a0: 81 35 c8 7d 40 cc 04 e2 a4 a4 a6 25 96 e6 94 60 |.5.}@......%...`|
195 01b0: 33 17 5f 54 00 00 d3 1b 0d 4c |3._T.....L|
195 01b0: 33 17 5f 54 00 00 d3 1b 0d 4c |3._T.....L|
196
196
197 $ echo "http://localhost:$HGPORT1/full.hg" > server/.hg/clonebundles.manifest
197 $ echo "http://localhost:$HGPORT1/full.hg" > server/.hg/clonebundles.manifest
198 $ hg clone -U http://localhost:$HGPORT full-bundle
198 $ hg clone -U http://localhost:$HGPORT full-bundle
199 applying clone bundle from http://localhost:$HGPORT1/full.hg
199 applying clone bundle from http://localhost:$HGPORT1/full.hg
200 adding changesets
200 adding changesets
201 adding manifests
201 adding manifests
202 adding file changes
202 adding file changes
203 added 2 changesets with 2 changes to 2 files
203 added 2 changesets with 2 changes to 2 files
204 finished applying clone bundle
204 finished applying clone bundle
205 searching for changes
205 searching for changes
206 no changes found
206 no changes found
207 2 local changesets published
207 2 local changesets published
208
208
209 Feature works over SSH
209 Feature works over SSH
210
210
211 $ hg clone -U ssh://user@dummy/server ssh-full-clone
211 $ hg clone -U ssh://user@dummy/server ssh-full-clone
212 applying clone bundle from http://localhost:$HGPORT1/full.hg
212 applying clone bundle from http://localhost:$HGPORT1/full.hg
213 adding changesets
213 adding changesets
214 adding manifests
214 adding manifests
215 adding file changes
215 adding file changes
216 added 2 changesets with 2 changes to 2 files
216 added 2 changesets with 2 changes to 2 files
217 finished applying clone bundle
217 finished applying clone bundle
218 searching for changes
218 searching for changes
219 no changes found
219 no changes found
220 2 local changesets published
220 2 local changesets published
221
221
222 Entry with unknown BUNDLESPEC is filtered and not used
222 Entry with unknown BUNDLESPEC is filtered and not used
223
223
224 $ cat > server/.hg/clonebundles.manifest << EOF
224 $ cat > server/.hg/clonebundles.manifest << EOF
225 > http://bad.entry1 BUNDLESPEC=UNKNOWN
225 > http://bad.entry1 BUNDLESPEC=UNKNOWN
226 > http://bad.entry2 BUNDLESPEC=xz-v1
226 > http://bad.entry2 BUNDLESPEC=xz-v1
227 > http://bad.entry3 BUNDLESPEC=none-v100
227 > http://bad.entry3 BUNDLESPEC=none-v100
228 > http://localhost:$HGPORT1/full.hg BUNDLESPEC=gzip-v2
228 > http://localhost:$HGPORT1/full.hg BUNDLESPEC=gzip-v2
229 > EOF
229 > EOF
230
230
231 $ hg clone -U http://localhost:$HGPORT filter-unknown-type
231 $ hg clone -U http://localhost:$HGPORT filter-unknown-type
232 applying clone bundle from http://localhost:$HGPORT1/full.hg
232 applying clone bundle from http://localhost:$HGPORT1/full.hg
233 adding changesets
233 adding changesets
234 adding manifests
234 adding manifests
235 adding file changes
235 adding file changes
236 added 2 changesets with 2 changes to 2 files
236 added 2 changesets with 2 changes to 2 files
237 finished applying clone bundle
237 finished applying clone bundle
238 searching for changes
238 searching for changes
239 no changes found
239 no changes found
240 2 local changesets published
240 2 local changesets published
241
241
242 Automatic fallback when all entries are filtered
242 Automatic fallback when all entries are filtered
243
243
244 $ cat > server/.hg/clonebundles.manifest << EOF
244 $ cat > server/.hg/clonebundles.manifest << EOF
245 > http://bad.entry BUNDLESPEC=UNKNOWN
245 > http://bad.entry BUNDLESPEC=UNKNOWN
246 > EOF
246 > EOF
247
247
248 $ hg clone -U http://localhost:$HGPORT filter-all
248 $ hg clone -U http://localhost:$HGPORT filter-all
249 no compatible clone bundles available on server; falling back to regular clone
249 no compatible clone bundles available on server; falling back to regular clone
250 (you may want to report this to the server operator)
250 (you may want to report this to the server operator)
251 requesting all changes
251 requesting all changes
252 adding changesets
252 adding changesets
253 adding manifests
253 adding manifests
254 adding file changes
254 adding file changes
255 added 2 changesets with 2 changes to 2 files
255 added 2 changesets with 2 changes to 2 files
256 new changesets 53245c60e682:aaff8d2ffbbf
256 new changesets 53245c60e682:aaff8d2ffbbf
257
257
258 We require a Python version that supports SNI. Therefore, URLs requiring SNI
258 We require a Python version that supports SNI. Therefore, URLs requiring SNI
259 are not filtered.
259 are not filtered.
260
260
261 $ cp full.hg sni.hg
261 $ cp full.hg sni.hg
262 $ cat > server/.hg/clonebundles.manifest << EOF
262 $ cat > server/.hg/clonebundles.manifest << EOF
263 > http://localhost:$HGPORT1/sni.hg REQUIRESNI=true
263 > http://localhost:$HGPORT1/sni.hg REQUIRESNI=true
264 > http://localhost:$HGPORT1/full.hg
264 > http://localhost:$HGPORT1/full.hg
265 > EOF
265 > EOF
266
266
267 $ hg clone -U http://localhost:$HGPORT sni-supported
267 $ hg clone -U http://localhost:$HGPORT sni-supported
268 applying clone bundle from http://localhost:$HGPORT1/sni.hg
268 applying clone bundle from http://localhost:$HGPORT1/sni.hg
269 adding changesets
269 adding changesets
270 adding manifests
270 adding manifests
271 adding file changes
271 adding file changes
272 added 2 changesets with 2 changes to 2 files
272 added 2 changesets with 2 changes to 2 files
273 finished applying clone bundle
273 finished applying clone bundle
274 searching for changes
274 searching for changes
275 no changes found
275 no changes found
276 2 local changesets published
276 2 local changesets published
277
277
278 Stream clone bundles are supported
278 Stream clone bundles are supported
279
279
280 $ hg -R server debugcreatestreamclonebundle packed.hg
280 $ hg -R server debugcreatestreamclonebundle packed.hg
281 writing 613 bytes for 4 files
281 writing 613 bytes for 4 files
282 bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust !)
282 bundle requirements: generaldelta, revlogv1, sparserevlog (no-rust no-zstd !)
283 bundle requirements: generaldelta, persistent-nodemap, revlogv1, sparserevlog (rust !)
283 bundle requirements: generaldelta, revlog-compression-zstd, revlogv1, sparserevlog (no-rust zstd !)
284 bundle requirements: generaldelta, persistent-nodemap, revlog-compression-zstd, revlogv1, sparserevlog (rust !)
284
285
285 No bundle spec should work
286 No bundle spec should work
286
287
287 $ cat > server/.hg/clonebundles.manifest << EOF
288 $ cat > server/.hg/clonebundles.manifest << EOF
288 > http://localhost:$HGPORT1/packed.hg
289 > http://localhost:$HGPORT1/packed.hg
289 > EOF
290 > EOF
290
291
291 $ hg clone -U http://localhost:$HGPORT stream-clone-no-spec
292 $ hg clone -U http://localhost:$HGPORT stream-clone-no-spec
292 applying clone bundle from http://localhost:$HGPORT1/packed.hg
293 applying clone bundle from http://localhost:$HGPORT1/packed.hg
293 4 files to transfer, 613 bytes of data
294 4 files to transfer, 613 bytes of data
294 transferred 613 bytes in *.* seconds (*) (glob)
295 transferred 613 bytes in *.* seconds (*) (glob)
295 finished applying clone bundle
296 finished applying clone bundle
296 searching for changes
297 searching for changes
297 no changes found
298 no changes found
298
299
299 Bundle spec without parameters should work
300 Bundle spec without parameters should work
300
301
301 $ cat > server/.hg/clonebundles.manifest << EOF
302 $ cat > server/.hg/clonebundles.manifest << EOF
302 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1
303 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1
303 > EOF
304 > EOF
304
305
305 $ hg clone -U http://localhost:$HGPORT stream-clone-vanilla-spec
306 $ hg clone -U http://localhost:$HGPORT stream-clone-vanilla-spec
306 applying clone bundle from http://localhost:$HGPORT1/packed.hg
307 applying clone bundle from http://localhost:$HGPORT1/packed.hg
307 4 files to transfer, 613 bytes of data
308 4 files to transfer, 613 bytes of data
308 transferred 613 bytes in *.* seconds (*) (glob)
309 transferred 613 bytes in *.* seconds (*) (glob)
309 finished applying clone bundle
310 finished applying clone bundle
310 searching for changes
311 searching for changes
311 no changes found
312 no changes found
312
313
313 Bundle spec with format requirements should work
314 Bundle spec with format requirements should work
314
315
315 $ cat > server/.hg/clonebundles.manifest << EOF
316 $ cat > server/.hg/clonebundles.manifest << EOF
316 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1
317 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1
317 > EOF
318 > EOF
318
319
319 $ hg clone -U http://localhost:$HGPORT stream-clone-supported-requirements
320 $ hg clone -U http://localhost:$HGPORT stream-clone-supported-requirements
320 applying clone bundle from http://localhost:$HGPORT1/packed.hg
321 applying clone bundle from http://localhost:$HGPORT1/packed.hg
321 4 files to transfer, 613 bytes of data
322 4 files to transfer, 613 bytes of data
322 transferred 613 bytes in *.* seconds (*) (glob)
323 transferred 613 bytes in *.* seconds (*) (glob)
323 finished applying clone bundle
324 finished applying clone bundle
324 searching for changes
325 searching for changes
325 no changes found
326 no changes found
326
327
327 Stream bundle spec with unknown requirements should be filtered out
328 Stream bundle spec with unknown requirements should be filtered out
328
329
329 $ cat > server/.hg/clonebundles.manifest << EOF
330 $ cat > server/.hg/clonebundles.manifest << EOF
330 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42
331 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42
331 > EOF
332 > EOF
332
333
333 $ hg clone -U http://localhost:$HGPORT stream-clone-unsupported-requirements
334 $ hg clone -U http://localhost:$HGPORT stream-clone-unsupported-requirements
334 no compatible clone bundles available on server; falling back to regular clone
335 no compatible clone bundles available on server; falling back to regular clone
335 (you may want to report this to the server operator)
336 (you may want to report this to the server operator)
336 requesting all changes
337 requesting all changes
337 adding changesets
338 adding changesets
338 adding manifests
339 adding manifests
339 adding file changes
340 adding file changes
340 added 2 changesets with 2 changes to 2 files
341 added 2 changesets with 2 changes to 2 files
341 new changesets 53245c60e682:aaff8d2ffbbf
342 new changesets 53245c60e682:aaff8d2ffbbf
342
343
343 Set up manifest for testing preferences
344 Set up manifest for testing preferences
344 (Remember, the TYPE does not have to match reality - the URL is
345 (Remember, the TYPE does not have to match reality - the URL is
345 important)
346 important)
346
347
347 $ cp full.hg gz-a.hg
348 $ cp full.hg gz-a.hg
348 $ cp full.hg gz-b.hg
349 $ cp full.hg gz-b.hg
349 $ cp full.hg bz2-a.hg
350 $ cp full.hg bz2-a.hg
350 $ cp full.hg bz2-b.hg
351 $ cp full.hg bz2-b.hg
351 $ cat > server/.hg/clonebundles.manifest << EOF
352 $ cat > server/.hg/clonebundles.manifest << EOF
352 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 extra=a
353 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 extra=a
353 > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2 extra=a
354 > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2 extra=a
354 > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b
355 > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b
355 > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b
356 > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b
356 > EOF
357 > EOF
357
358
358 Preferring an undefined attribute will take first entry
359 Preferring an undefined attribute will take first entry
359
360
360 $ hg --config ui.clonebundleprefers=foo=bar clone -U http://localhost:$HGPORT prefer-foo
361 $ hg --config ui.clonebundleprefers=foo=bar clone -U http://localhost:$HGPORT prefer-foo
361 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
362 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
362 adding changesets
363 adding changesets
363 adding manifests
364 adding manifests
364 adding file changes
365 adding file changes
365 added 2 changesets with 2 changes to 2 files
366 added 2 changesets with 2 changes to 2 files
366 finished applying clone bundle
367 finished applying clone bundle
367 searching for changes
368 searching for changes
368 no changes found
369 no changes found
369 2 local changesets published
370 2 local changesets published
370
371
371 Preferring bz2 type will download first entry of that type
372 Preferring bz2 type will download first entry of that type
372
373
373 $ hg --config ui.clonebundleprefers=COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-bz
374 $ hg --config ui.clonebundleprefers=COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-bz
374 applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg
375 applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg
375 adding changesets
376 adding changesets
376 adding manifests
377 adding manifests
377 adding file changes
378 adding file changes
378 added 2 changesets with 2 changes to 2 files
379 added 2 changesets with 2 changes to 2 files
379 finished applying clone bundle
380 finished applying clone bundle
380 searching for changes
381 searching for changes
381 no changes found
382 no changes found
382 2 local changesets published
383 2 local changesets published
383
384
384 Preferring multiple values of an option works
385 Preferring multiple values of an option works
385
386
386 $ hg --config ui.clonebundleprefers=COMPRESSION=unknown,COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-multiple-bz
387 $ hg --config ui.clonebundleprefers=COMPRESSION=unknown,COMPRESSION=bzip2 clone -U http://localhost:$HGPORT prefer-multiple-bz
387 applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg
388 applying clone bundle from http://localhost:$HGPORT1/bz2-a.hg
388 adding changesets
389 adding changesets
389 adding manifests
390 adding manifests
390 adding file changes
391 adding file changes
391 added 2 changesets with 2 changes to 2 files
392 added 2 changesets with 2 changes to 2 files
392 finished applying clone bundle
393 finished applying clone bundle
393 searching for changes
394 searching for changes
394 no changes found
395 no changes found
395 2 local changesets published
396 2 local changesets published
396
397
397 Sorting multiple values should get us back to original first entry
398 Sorting multiple values should get us back to original first entry
398
399
399 $ hg --config ui.clonebundleprefers=BUNDLESPEC=unknown,BUNDLESPEC=gzip-v2,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-multiple-gz
400 $ hg --config ui.clonebundleprefers=BUNDLESPEC=unknown,BUNDLESPEC=gzip-v2,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-multiple-gz
400 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
401 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
401 adding changesets
402 adding changesets
402 adding manifests
403 adding manifests
403 adding file changes
404 adding file changes
404 added 2 changesets with 2 changes to 2 files
405 added 2 changesets with 2 changes to 2 files
405 finished applying clone bundle
406 finished applying clone bundle
406 searching for changes
407 searching for changes
407 no changes found
408 no changes found
408 2 local changesets published
409 2 local changesets published
409
410
410 Preferring multiple attributes has correct order
411 Preferring multiple attributes has correct order
411
412
412 $ hg --config ui.clonebundleprefers=extra=b,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-separate-attributes
413 $ hg --config ui.clonebundleprefers=extra=b,BUNDLESPEC=bzip2-v2 clone -U http://localhost:$HGPORT prefer-separate-attributes
413 applying clone bundle from http://localhost:$HGPORT1/bz2-b.hg
414 applying clone bundle from http://localhost:$HGPORT1/bz2-b.hg
414 adding changesets
415 adding changesets
415 adding manifests
416 adding manifests
416 adding file changes
417 adding file changes
417 added 2 changesets with 2 changes to 2 files
418 added 2 changesets with 2 changes to 2 files
418 finished applying clone bundle
419 finished applying clone bundle
419 searching for changes
420 searching for changes
420 no changes found
421 no changes found
421 2 local changesets published
422 2 local changesets published
422
423
423 Test where attribute is missing from some entries
424 Test where attribute is missing from some entries
424
425
425 $ cat > server/.hg/clonebundles.manifest << EOF
426 $ cat > server/.hg/clonebundles.manifest << EOF
426 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
427 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
427 > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2
428 > http://localhost:$HGPORT1/bz2-a.hg BUNDLESPEC=bzip2-v2
428 > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b
429 > http://localhost:$HGPORT1/gz-b.hg BUNDLESPEC=gzip-v2 extra=b
429 > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b
430 > http://localhost:$HGPORT1/bz2-b.hg BUNDLESPEC=bzip2-v2 extra=b
430 > EOF
431 > EOF
431
432
432 $ hg --config ui.clonebundleprefers=extra=b clone -U http://localhost:$HGPORT prefer-partially-defined-attribute
433 $ hg --config ui.clonebundleprefers=extra=b clone -U http://localhost:$HGPORT prefer-partially-defined-attribute
433 applying clone bundle from http://localhost:$HGPORT1/gz-b.hg
434 applying clone bundle from http://localhost:$HGPORT1/gz-b.hg
434 adding changesets
435 adding changesets
435 adding manifests
436 adding manifests
436 adding file changes
437 adding file changes
437 added 2 changesets with 2 changes to 2 files
438 added 2 changesets with 2 changes to 2 files
438 finished applying clone bundle
439 finished applying clone bundle
439 searching for changes
440 searching for changes
440 no changes found
441 no changes found
441 2 local changesets published
442 2 local changesets published
442
443
443 Test a bad attribute list
444 Test a bad attribute list
444
445
445 $ hg --config ui.clonebundleprefers=bad clone -U http://localhost:$HGPORT bad-input
446 $ hg --config ui.clonebundleprefers=bad clone -U http://localhost:$HGPORT bad-input
446 abort: invalid ui.clonebundleprefers item: bad
447 abort: invalid ui.clonebundleprefers item: bad
447 (each comma separated item should be key=value pairs)
448 (each comma separated item should be key=value pairs)
448 [255]
449 [255]
449 $ hg --config ui.clonebundleprefers=key=val,bad,key2=val2 clone \
450 $ hg --config ui.clonebundleprefers=key=val,bad,key2=val2 clone \
450 > -U http://localhost:$HGPORT bad-input
451 > -U http://localhost:$HGPORT bad-input
451 abort: invalid ui.clonebundleprefers item: bad
452 abort: invalid ui.clonebundleprefers item: bad
452 (each comma separated item should be key=value pairs)
453 (each comma separated item should be key=value pairs)
453 [255]
454 [255]
454
455
455
456
456 Test interaction between clone bundles and --stream
457 Test interaction between clone bundles and --stream
457
458
458 A manifest with just a gzip bundle
459 A manifest with just a gzip bundle
459
460
460 $ cat > server/.hg/clonebundles.manifest << EOF
461 $ cat > server/.hg/clonebundles.manifest << EOF
461 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
462 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
462 > EOF
463 > EOF
463
464
464 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip
465 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip
465 no compatible clone bundles available on server; falling back to regular clone
466 no compatible clone bundles available on server; falling back to regular clone
466 (you may want to report this to the server operator)
467 (you may want to report this to the server operator)
467 streaming all changes
468 streaming all changes
468 9 files to transfer, 816 bytes of data
469 9 files to transfer, 816 bytes of data
469 transferred 816 bytes in * seconds (*) (glob)
470 transferred 816 bytes in * seconds (*) (glob)
470
471
471 A manifest with a stream clone but no BUNDLESPEC
472 A manifest with a stream clone but no BUNDLESPEC
472
473
473 $ cat > server/.hg/clonebundles.manifest << EOF
474 $ cat > server/.hg/clonebundles.manifest << EOF
474 > http://localhost:$HGPORT1/packed.hg
475 > http://localhost:$HGPORT1/packed.hg
475 > EOF
476 > EOF
476
477
477 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-no-bundlespec
478 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-no-bundlespec
478 no compatible clone bundles available on server; falling back to regular clone
479 no compatible clone bundles available on server; falling back to regular clone
479 (you may want to report this to the server operator)
480 (you may want to report this to the server operator)
480 streaming all changes
481 streaming all changes
481 9 files to transfer, 816 bytes of data
482 9 files to transfer, 816 bytes of data
482 transferred 816 bytes in * seconds (*) (glob)
483 transferred 816 bytes in * seconds (*) (glob)
483
484
484 A manifest with a gzip bundle and a stream clone
485 A manifest with a gzip bundle and a stream clone
485
486
486 $ cat > server/.hg/clonebundles.manifest << EOF
487 $ cat > server/.hg/clonebundles.manifest << EOF
487 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
488 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
488 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1
489 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1
489 > EOF
490 > EOF
490
491
491 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed
492 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed
492 applying clone bundle from http://localhost:$HGPORT1/packed.hg
493 applying clone bundle from http://localhost:$HGPORT1/packed.hg
493 4 files to transfer, 613 bytes of data
494 4 files to transfer, 613 bytes of data
494 transferred 613 bytes in * seconds (*) (glob)
495 transferred 613 bytes in * seconds (*) (glob)
495 finished applying clone bundle
496 finished applying clone bundle
496 searching for changes
497 searching for changes
497 no changes found
498 no changes found
498
499
499 A manifest with a gzip bundle and stream clone with supported requirements
500 A manifest with a gzip bundle and stream clone with supported requirements
500
501
501 $ cat > server/.hg/clonebundles.manifest << EOF
502 $ cat > server/.hg/clonebundles.manifest << EOF
502 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
503 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
503 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1
504 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv1
504 > EOF
505 > EOF
505
506
506 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-requirements
507 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-requirements
507 applying clone bundle from http://localhost:$HGPORT1/packed.hg
508 applying clone bundle from http://localhost:$HGPORT1/packed.hg
508 4 files to transfer, 613 bytes of data
509 4 files to transfer, 613 bytes of data
509 transferred 613 bytes in * seconds (*) (glob)
510 transferred 613 bytes in * seconds (*) (glob)
510 finished applying clone bundle
511 finished applying clone bundle
511 searching for changes
512 searching for changes
512 no changes found
513 no changes found
513
514
514 A manifest with a gzip bundle and a stream clone with unsupported requirements
515 A manifest with a gzip bundle and a stream clone with unsupported requirements
515
516
516 $ cat > server/.hg/clonebundles.manifest << EOF
517 $ cat > server/.hg/clonebundles.manifest << EOF
517 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
518 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2
518 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42
519 > http://localhost:$HGPORT1/packed.hg BUNDLESPEC=none-packed1;requirements%3Drevlogv42
519 > EOF
520 > EOF
520
521
521 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-unsupported-requirements
522 $ hg clone -U --stream http://localhost:$HGPORT uncompressed-gzip-packed-unsupported-requirements
522 no compatible clone bundles available on server; falling back to regular clone
523 no compatible clone bundles available on server; falling back to regular clone
523 (you may want to report this to the server operator)
524 (you may want to report this to the server operator)
524 streaming all changes
525 streaming all changes
525 9 files to transfer, 816 bytes of data
526 9 files to transfer, 816 bytes of data
526 transferred 816 bytes in * seconds (*) (glob)
527 transferred 816 bytes in * seconds (*) (glob)
527
528
528 Test clone bundle retrieved through bundle2
529 Test clone bundle retrieved through bundle2
529
530
530 $ cat << EOF >> $HGRCPATH
531 $ cat << EOF >> $HGRCPATH
531 > [extensions]
532 > [extensions]
532 > largefiles=
533 > largefiles=
533 > EOF
534 > EOF
534 $ killdaemons.py
535 $ killdaemons.py
535 $ hg -R server serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
536 $ hg -R server serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
536 $ cat hg.pid >> $DAEMON_PIDS
537 $ cat hg.pid >> $DAEMON_PIDS
537
538
538 $ hg -R server debuglfput gz-a.hg
539 $ hg -R server debuglfput gz-a.hg
539 1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae
540 1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae
540
541
541 $ cat > server/.hg/clonebundles.manifest << EOF
542 $ cat > server/.hg/clonebundles.manifest << EOF
542 > largefile://1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae BUNDLESPEC=gzip-v2
543 > largefile://1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae BUNDLESPEC=gzip-v2
543 > EOF
544 > EOF
544
545
545 $ hg clone -U http://localhost:$HGPORT largefile-provided --traceback
546 $ hg clone -U http://localhost:$HGPORT largefile-provided --traceback
546 applying clone bundle from largefile://1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae
547 applying clone bundle from largefile://1f74b3d08286b9b3a16fb3fa185dd29219cbc6ae
547 adding changesets
548 adding changesets
548 adding manifests
549 adding manifests
549 adding file changes
550 adding file changes
550 added 2 changesets with 2 changes to 2 files
551 added 2 changesets with 2 changes to 2 files
551 finished applying clone bundle
552 finished applying clone bundle
552 searching for changes
553 searching for changes
553 no changes found
554 no changes found
554 2 local changesets published
555 2 local changesets published
555 $ killdaemons.py
556 $ killdaemons.py
556
557
557 A manifest with a gzip bundle requiring too much memory for a 16MB system and working
558 A manifest with a gzip bundle requiring too much memory for a 16MB system and working
558 on a 32MB system.
559 on a 32MB system.
559
560
560 $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
561 $ "$PYTHON" $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
561 $ cat http.pid >> $DAEMON_PIDS
562 $ cat http.pid >> $DAEMON_PIDS
562 $ hg -R server serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
563 $ hg -R server serve -d -p $HGPORT --pid-file hg.pid --accesslog access.log
563 $ cat hg.pid >> $DAEMON_PIDS
564 $ cat hg.pid >> $DAEMON_PIDS
564
565
565 $ cat > server/.hg/clonebundles.manifest << EOF
566 $ cat > server/.hg/clonebundles.manifest << EOF
566 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 REQUIREDRAM=12MB
567 > http://localhost:$HGPORT1/gz-a.hg BUNDLESPEC=gzip-v2 REQUIREDRAM=12MB
567 > EOF
568 > EOF
568
569
569 $ hg clone -U --debug --config ui.available-memory=16MB http://localhost:$HGPORT gzip-too-large
570 $ hg clone -U --debug --config ui.available-memory=16MB http://localhost:$HGPORT gzip-too-large
570 using http://localhost:$HGPORT/
571 using http://localhost:$HGPORT/
571 sending capabilities command
572 sending capabilities command
572 sending clonebundles command
573 sending clonebundles command
573 filtering http://localhost:$HGPORT1/gz-a.hg as it needs more than 2/3 of system memory
574 filtering http://localhost:$HGPORT1/gz-a.hg as it needs more than 2/3 of system memory
574 no compatible clone bundles available on server; falling back to regular clone
575 no compatible clone bundles available on server; falling back to regular clone
575 (you may want to report this to the server operator)
576 (you may want to report this to the server operator)
576 query 1; heads
577 query 1; heads
577 sending batch command
578 sending batch command
578 requesting all changes
579 requesting all changes
579 sending getbundle command
580 sending getbundle command
580 bundle2-input-bundle: with-transaction
581 bundle2-input-bundle: with-transaction
581 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
582 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
582 adding changesets
583 adding changesets
583 add changeset 53245c60e682
584 add changeset 53245c60e682
584 add changeset aaff8d2ffbbf
585 add changeset aaff8d2ffbbf
585 adding manifests
586 adding manifests
586 adding file changes
587 adding file changes
587 adding bar revisions
588 adding bar revisions
588 adding foo revisions
589 adding foo revisions
589 bundle2-input-part: total payload size 920
590 bundle2-input-part: total payload size 920
590 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
591 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
591 bundle2-input-part: "phase-heads" supported
592 bundle2-input-part: "phase-heads" supported
592 bundle2-input-part: total payload size 24
593 bundle2-input-part: total payload size 24
593 bundle2-input-bundle: 3 parts total
594 bundle2-input-bundle: 3 parts total
594 checking for updated bookmarks
595 checking for updated bookmarks
595 updating the branch cache
596 updating the branch cache
596 added 2 changesets with 2 changes to 2 files
597 added 2 changesets with 2 changes to 2 files
597 new changesets 53245c60e682:aaff8d2ffbbf
598 new changesets 53245c60e682:aaff8d2ffbbf
598 calling hook changegroup.lfiles: hgext.largefiles.reposetup.checkrequireslfiles
599 calling hook changegroup.lfiles: hgext.largefiles.reposetup.checkrequireslfiles
599 updating the branch cache
600 updating the branch cache
600 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
601 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
601
602
602 $ hg clone -U --debug --config ui.available-memory=32MB http://localhost:$HGPORT gzip-too-large2
603 $ hg clone -U --debug --config ui.available-memory=32MB http://localhost:$HGPORT gzip-too-large2
603 using http://localhost:$HGPORT/
604 using http://localhost:$HGPORT/
604 sending capabilities command
605 sending capabilities command
605 sending clonebundles command
606 sending clonebundles command
606 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
607 applying clone bundle from http://localhost:$HGPORT1/gz-a.hg
607 bundle2-input-bundle: 1 params with-transaction
608 bundle2-input-bundle: 1 params with-transaction
608 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
609 bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
609 adding changesets
610 adding changesets
610 add changeset 53245c60e682
611 add changeset 53245c60e682
611 add changeset aaff8d2ffbbf
612 add changeset aaff8d2ffbbf
612 adding manifests
613 adding manifests
613 adding file changes
614 adding file changes
614 adding bar revisions
615 adding bar revisions
615 adding foo revisions
616 adding foo revisions
616 bundle2-input-part: total payload size 920
617 bundle2-input-part: total payload size 920
617 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported
618 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported
618 bundle2-input-part: total payload size 59
619 bundle2-input-part: total payload size 59
619 bundle2-input-bundle: 2 parts total
620 bundle2-input-bundle: 2 parts total
620 updating the branch cache
621 updating the branch cache
621 added 2 changesets with 2 changes to 2 files
622 added 2 changesets with 2 changes to 2 files
622 finished applying clone bundle
623 finished applying clone bundle
623 query 1; heads
624 query 1; heads
624 sending batch command
625 sending batch command
625 searching for changes
626 searching for changes
626 all remote heads known locally
627 all remote heads known locally
627 no changes found
628 no changes found
628 sending getbundle command
629 sending getbundle command
629 bundle2-input-bundle: with-transaction
630 bundle2-input-bundle: with-transaction
630 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
631 bundle2-input-part: "listkeys" (params: 1 mandatory) supported
631 bundle2-input-part: "phase-heads" supported
632 bundle2-input-part: "phase-heads" supported
632 bundle2-input-part: total payload size 24
633 bundle2-input-part: total payload size 24
633 bundle2-input-bundle: 2 parts total
634 bundle2-input-bundle: 2 parts total
634 checking for updated bookmarks
635 checking for updated bookmarks
635 2 local changesets published
636 2 local changesets published
636 calling hook changegroup.lfiles: hgext.largefiles.reposetup.checkrequireslfiles
637 calling hook changegroup.lfiles: hgext.largefiles.reposetup.checkrequireslfiles
637 updating the branch cache
638 updating the branch cache
638 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
639 (sent 4 HTTP requests and * bytes; received * bytes in responses) (glob)
639 $ killdaemons.py
640 $ killdaemons.py
@@ -1,710 +1,710 b''
1 $ cat << EOF >> $HGRCPATH
1 $ cat << EOF >> $HGRCPATH
2 > [ui]
2 > [ui]
3 > interactive=yes
3 > interactive=yes
4 > EOF
4 > EOF
5
5
6 $ hg init debugrevlog
6 $ hg init debugrevlog
7 $ cd debugrevlog
7 $ cd debugrevlog
8 $ echo a > a
8 $ echo a > a
9 $ hg ci -Am adda
9 $ hg ci -Am adda
10 adding a
10 adding a
11 $ hg rm .
11 $ hg rm .
12 removing a
12 removing a
13 $ hg ci -Am make-it-empty
13 $ hg ci -Am make-it-empty
14 $ hg revert --all -r 0
14 $ hg revert --all -r 0
15 adding a
15 adding a
16 $ hg ci -Am make-it-full
16 $ hg ci -Am make-it-full
17 #if reporevlogstore
17 #if reporevlogstore
18 $ hg debugrevlog -c
18 $ hg debugrevlog -c
19 format : 1
19 format : 1
20 flags : inline
20 flags : inline
21
21
22 revisions : 3
22 revisions : 3
23 merges : 0 ( 0.00%)
23 merges : 0 ( 0.00%)
24 normal : 3 (100.00%)
24 normal : 3 (100.00%)
25 revisions : 3
25 revisions : 3
26 empty : 0 ( 0.00%)
26 empty : 0 ( 0.00%)
27 text : 0 (100.00%)
27 text : 0 (100.00%)
28 delta : 0 (100.00%)
28 delta : 0 (100.00%)
29 snapshot : 3 (100.00%)
29 snapshot : 3 (100.00%)
30 lvl-0 : 3 (100.00%)
30 lvl-0 : 3 (100.00%)
31 deltas : 0 ( 0.00%)
31 deltas : 0 ( 0.00%)
32 revision size : 191
32 revision size : 191
33 snapshot : 191 (100.00%)
33 snapshot : 191 (100.00%)
34 lvl-0 : 191 (100.00%)
34 lvl-0 : 191 (100.00%)
35 deltas : 0 ( 0.00%)
35 deltas : 0 ( 0.00%)
36
36
37 chunks : 3
37 chunks : 3
38 0x75 (u) : 3 (100.00%)
38 0x75 (u) : 3 (100.00%)
39 chunks size : 191
39 chunks size : 191
40 0x75 (u) : 191 (100.00%)
40 0x75 (u) : 191 (100.00%)
41
41
42 avg chain length : 0
42 avg chain length : 0
43 max chain length : 0
43 max chain length : 0
44 max chain reach : 67
44 max chain reach : 67
45 compression ratio : 0
45 compression ratio : 0
46
46
47 uncompressed data size (min/max/avg) : 57 / 66 / 62
47 uncompressed data size (min/max/avg) : 57 / 66 / 62
48 full revision size (min/max/avg) : 58 / 67 / 63
48 full revision size (min/max/avg) : 58 / 67 / 63
49 inter-snapshot size (min/max/avg) : 0 / 0 / 0
49 inter-snapshot size (min/max/avg) : 0 / 0 / 0
50 delta size (min/max/avg) : 0 / 0 / 0
50 delta size (min/max/avg) : 0 / 0 / 0
51 $ hg debugrevlog -m
51 $ hg debugrevlog -m
52 format : 1
52 format : 1
53 flags : inline, generaldelta
53 flags : inline, generaldelta
54
54
55 revisions : 3
55 revisions : 3
56 merges : 0 ( 0.00%)
56 merges : 0 ( 0.00%)
57 normal : 3 (100.00%)
57 normal : 3 (100.00%)
58 revisions : 3
58 revisions : 3
59 empty : 1 (33.33%)
59 empty : 1 (33.33%)
60 text : 1 (100.00%)
60 text : 1 (100.00%)
61 delta : 0 ( 0.00%)
61 delta : 0 ( 0.00%)
62 snapshot : 2 (66.67%)
62 snapshot : 2 (66.67%)
63 lvl-0 : 2 (66.67%)
63 lvl-0 : 2 (66.67%)
64 deltas : 0 ( 0.00%)
64 deltas : 0 ( 0.00%)
65 revision size : 88
65 revision size : 88
66 snapshot : 88 (100.00%)
66 snapshot : 88 (100.00%)
67 lvl-0 : 88 (100.00%)
67 lvl-0 : 88 (100.00%)
68 deltas : 0 ( 0.00%)
68 deltas : 0 ( 0.00%)
69
69
70 chunks : 3
70 chunks : 3
71 empty : 1 (33.33%)
71 empty : 1 (33.33%)
72 0x75 (u) : 2 (66.67%)
72 0x75 (u) : 2 (66.67%)
73 chunks size : 88
73 chunks size : 88
74 empty : 0 ( 0.00%)
74 empty : 0 ( 0.00%)
75 0x75 (u) : 88 (100.00%)
75 0x75 (u) : 88 (100.00%)
76
76
77 avg chain length : 0
77 avg chain length : 0
78 max chain length : 0
78 max chain length : 0
79 max chain reach : 44
79 max chain reach : 44
80 compression ratio : 0
80 compression ratio : 0
81
81
82 uncompressed data size (min/max/avg) : 0 / 43 / 28
82 uncompressed data size (min/max/avg) : 0 / 43 / 28
83 full revision size (min/max/avg) : 44 / 44 / 44
83 full revision size (min/max/avg) : 44 / 44 / 44
84 inter-snapshot size (min/max/avg) : 0 / 0 / 0
84 inter-snapshot size (min/max/avg) : 0 / 0 / 0
85 delta size (min/max/avg) : 0 / 0 / 0
85 delta size (min/max/avg) : 0 / 0 / 0
86 $ hg debugrevlog a
86 $ hg debugrevlog a
87 format : 1
87 format : 1
88 flags : inline, generaldelta
88 flags : inline, generaldelta
89
89
90 revisions : 1
90 revisions : 1
91 merges : 0 ( 0.00%)
91 merges : 0 ( 0.00%)
92 normal : 1 (100.00%)
92 normal : 1 (100.00%)
93 revisions : 1
93 revisions : 1
94 empty : 0 ( 0.00%)
94 empty : 0 ( 0.00%)
95 text : 0 (100.00%)
95 text : 0 (100.00%)
96 delta : 0 (100.00%)
96 delta : 0 (100.00%)
97 snapshot : 1 (100.00%)
97 snapshot : 1 (100.00%)
98 lvl-0 : 1 (100.00%)
98 lvl-0 : 1 (100.00%)
99 deltas : 0 ( 0.00%)
99 deltas : 0 ( 0.00%)
100 revision size : 3
100 revision size : 3
101 snapshot : 3 (100.00%)
101 snapshot : 3 (100.00%)
102 lvl-0 : 3 (100.00%)
102 lvl-0 : 3 (100.00%)
103 deltas : 0 ( 0.00%)
103 deltas : 0 ( 0.00%)
104
104
105 chunks : 1
105 chunks : 1
106 0x75 (u) : 1 (100.00%)
106 0x75 (u) : 1 (100.00%)
107 chunks size : 3
107 chunks size : 3
108 0x75 (u) : 3 (100.00%)
108 0x75 (u) : 3 (100.00%)
109
109
110 avg chain length : 0
110 avg chain length : 0
111 max chain length : 0
111 max chain length : 0
112 max chain reach : 3
112 max chain reach : 3
113 compression ratio : 0
113 compression ratio : 0
114
114
115 uncompressed data size (min/max/avg) : 2 / 2 / 2
115 uncompressed data size (min/max/avg) : 2 / 2 / 2
116 full revision size (min/max/avg) : 3 / 3 / 3
116 full revision size (min/max/avg) : 3 / 3 / 3
117 inter-snapshot size (min/max/avg) : 0 / 0 / 0
117 inter-snapshot size (min/max/avg) : 0 / 0 / 0
118 delta size (min/max/avg) : 0 / 0 / 0
118 delta size (min/max/avg) : 0 / 0 / 0
119 #endif
119 #endif
120
120
121 Test debugindex, with and without the --verbose/--debug flag
121 Test debugindex, with and without the --verbose/--debug flag
122 $ hg debugrevlogindex a
122 $ hg debugrevlogindex a
123 rev linkrev nodeid p1 p2
123 rev linkrev nodeid p1 p2
124 0 0 b789fdd96dc2 000000000000 000000000000
124 0 0 b789fdd96dc2 000000000000 000000000000
125
125
126 #if no-reposimplestore
126 #if no-reposimplestore
127 $ hg --verbose debugrevlogindex a
127 $ hg --verbose debugrevlogindex a
128 rev offset length linkrev nodeid p1 p2
128 rev offset length linkrev nodeid p1 p2
129 0 0 3 0 b789fdd96dc2 000000000000 000000000000
129 0 0 3 0 b789fdd96dc2 000000000000 000000000000
130
130
131 $ hg --debug debugrevlogindex a
131 $ hg --debug debugrevlogindex a
132 rev offset length linkrev nodeid p1 p2
132 rev offset length linkrev nodeid p1 p2
133 0 0 3 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
133 0 0 3 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
134 #endif
134 #endif
135
135
136 $ hg debugrevlogindex -f 1 a
136 $ hg debugrevlogindex -f 1 a
137 rev flag size link p1 p2 nodeid
137 rev flag size link p1 p2 nodeid
138 0 0000 2 0 -1 -1 b789fdd96dc2
138 0 0000 2 0 -1 -1 b789fdd96dc2
139
139
140 #if no-reposimplestore
140 #if no-reposimplestore
141 $ hg --verbose debugrevlogindex -f 1 a
141 $ hg --verbose debugrevlogindex -f 1 a
142 rev flag offset length size link p1 p2 nodeid
142 rev flag offset length size link p1 p2 nodeid
143 0 0000 0 3 2 0 -1 -1 b789fdd96dc2
143 0 0000 0 3 2 0 -1 -1 b789fdd96dc2
144
144
145 $ hg --debug debugrevlogindex -f 1 a
145 $ hg --debug debugrevlogindex -f 1 a
146 rev flag offset length size link p1 p2 nodeid
146 rev flag offset length size link p1 p2 nodeid
147 0 0000 0 3 2 0 -1 -1 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
147 0 0000 0 3 2 0 -1 -1 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
148 #endif
148 #endif
149
149
150 $ hg debugindex -c
150 $ hg debugindex -c
151 rev linkrev nodeid p1 p2
151 rev linkrev nodeid p1 p2
152 0 0 07f494440405 000000000000 000000000000
152 0 0 07f494440405 000000000000 000000000000
153 1 1 8cccb4b5fec2 07f494440405 000000000000
153 1 1 8cccb4b5fec2 07f494440405 000000000000
154 2 2 b1e228c512c5 8cccb4b5fec2 000000000000
154 2 2 b1e228c512c5 8cccb4b5fec2 000000000000
155 $ hg debugindex -c --debug
155 $ hg debugindex -c --debug
156 rev linkrev nodeid p1 p2
156 rev linkrev nodeid p1 p2
157 0 0 07f4944404050f47db2e5c5071e0e84e7a27bba9 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
157 0 0 07f4944404050f47db2e5c5071e0e84e7a27bba9 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
158 1 1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a 07f4944404050f47db2e5c5071e0e84e7a27bba9 0000000000000000000000000000000000000000
158 1 1 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a 07f4944404050f47db2e5c5071e0e84e7a27bba9 0000000000000000000000000000000000000000
159 2 2 b1e228c512c5d7066d70562ed839c3323a62d6d2 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a 0000000000000000000000000000000000000000
159 2 2 b1e228c512c5d7066d70562ed839c3323a62d6d2 8cccb4b5fec20cafeb99dd01c26d4dee8ea4388a 0000000000000000000000000000000000000000
160 $ hg debugindex -m
160 $ hg debugindex -m
161 rev linkrev nodeid p1 p2
161 rev linkrev nodeid p1 p2
162 0 0 a0c8bcbbb45c 000000000000 000000000000
162 0 0 a0c8bcbbb45c 000000000000 000000000000
163 1 1 57faf8a737ae a0c8bcbbb45c 000000000000
163 1 1 57faf8a737ae a0c8bcbbb45c 000000000000
164 2 2 a35b10320954 57faf8a737ae 000000000000
164 2 2 a35b10320954 57faf8a737ae 000000000000
165 $ hg debugindex -m --debug
165 $ hg debugindex -m --debug
166 rev linkrev nodeid p1 p2
166 rev linkrev nodeid p1 p2
167 0 0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
167 0 0 a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
168 1 1 57faf8a737ae7faf490582941a82319ba6529dca a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 0000000000000000000000000000000000000000
168 1 1 57faf8a737ae7faf490582941a82319ba6529dca a0c8bcbbb45c63b90b70ad007bf38961f64f2af0 0000000000000000000000000000000000000000
169 2 2 a35b103209548032201c16c7688cb2657f037a38 57faf8a737ae7faf490582941a82319ba6529dca 0000000000000000000000000000000000000000
169 2 2 a35b103209548032201c16c7688cb2657f037a38 57faf8a737ae7faf490582941a82319ba6529dca 0000000000000000000000000000000000000000
170 $ hg debugindex a
170 $ hg debugindex a
171 rev linkrev nodeid p1 p2
171 rev linkrev nodeid p1 p2
172 0 0 b789fdd96dc2 000000000000 000000000000
172 0 0 b789fdd96dc2 000000000000 000000000000
173 $ hg debugindex --debug a
173 $ hg debugindex --debug a
174 rev linkrev nodeid p1 p2
174 rev linkrev nodeid p1 p2
175 0 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
175 0 0 b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000
176
176
177 debugdelta chain basic output
177 debugdelta chain basic output
178
178
179 #if reporevlogstore pure
179 #if reporevlogstore pure
180 $ hg debugindexstats
180 $ hg debugindexstats
181 abort: debugindexstats only works with native code
181 abort: debugindexstats only works with native code
182 [255]
182 [255]
183 #endif
183 #endif
184 #if reporevlogstore no-pure
184 #if reporevlogstore no-pure
185 $ hg debugindexstats
185 $ hg debugindexstats
186 node trie capacity: 4
186 node trie capacity: 4
187 node trie count: 2
187 node trie count: 2
188 node trie depth: 1
188 node trie depth: 1
189 node trie last rev scanned: -1 (no-rust !)
189 node trie last rev scanned: -1 (no-rust !)
190 node trie last rev scanned: 3 (rust !)
190 node trie last rev scanned: 3 (rust !)
191 node trie lookups: 4 (no-rust !)
191 node trie lookups: 4 (no-rust !)
192 node trie lookups: 2 (rust !)
192 node trie lookups: 2 (rust !)
193 node trie misses: 1
193 node trie misses: 1
194 node trie splits: 1
194 node trie splits: 1
195 revs in memory: 3
195 revs in memory: 3
196 #endif
196 #endif
197
197
198 #if reporevlogstore no-pure
198 #if reporevlogstore no-pure
199 $ hg debugdeltachain -m
199 $ hg debugdeltachain -m
200 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
200 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
201 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
201 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
202 1 2 1 -1 base 0 0 0 0.00000 0 0 0.00000 0 0 1.00000 1
202 1 2 1 -1 base 0 0 0 0.00000 0 0 0.00000 0 0 1.00000 1
203 2 3 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
203 2 3 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
204
204
205 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen}\n'
205 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen}\n'
206 0 1 1
206 0 1 1
207 1 2 1
207 1 2 1
208 2 3 1
208 2 3 1
209
209
210 $ hg debugdeltachain -m -Tjson
210 $ hg debugdeltachain -m -Tjson
211 [
211 [
212 {
212 {
213 "chainid": 1,
213 "chainid": 1,
214 "chainlen": 1,
214 "chainlen": 1,
215 "chainratio": 1.02325581395, (no-py3 !)
215 "chainratio": 1.02325581395, (no-py3 !)
216 "chainratio": 1.0232558139534884, (py3 !)
216 "chainratio": 1.0232558139534884, (py3 !)
217 "chainsize": 44,
217 "chainsize": 44,
218 "compsize": 44,
218 "compsize": 44,
219 "deltatype": "base",
219 "deltatype": "base",
220 "extradist": 0,
220 "extradist": 0,
221 "extraratio": 0.0,
221 "extraratio": 0.0,
222 "largestblock": 44,
222 "largestblock": 44,
223 "lindist": 44,
223 "lindist": 44,
224 "prevrev": -1,
224 "prevrev": -1,
225 "readdensity": 1.0,
225 "readdensity": 1.0,
226 "readsize": 44,
226 "readsize": 44,
227 "rev": 0,
227 "rev": 0,
228 "srchunks": 1,
228 "srchunks": 1,
229 "uncompsize": 43
229 "uncompsize": 43
230 },
230 },
231 {
231 {
232 "chainid": 2,
232 "chainid": 2,
233 "chainlen": 1,
233 "chainlen": 1,
234 "chainratio": 0,
234 "chainratio": 0,
235 "chainsize": 0,
235 "chainsize": 0,
236 "compsize": 0,
236 "compsize": 0,
237 "deltatype": "base",
237 "deltatype": "base",
238 "extradist": 0,
238 "extradist": 0,
239 "extraratio": 0,
239 "extraratio": 0,
240 "largestblock": 0,
240 "largestblock": 0,
241 "lindist": 0,
241 "lindist": 0,
242 "prevrev": -1,
242 "prevrev": -1,
243 "readdensity": 1,
243 "readdensity": 1,
244 "readsize": 0,
244 "readsize": 0,
245 "rev": 1,
245 "rev": 1,
246 "srchunks": 1,
246 "srchunks": 1,
247 "uncompsize": 0
247 "uncompsize": 0
248 },
248 },
249 {
249 {
250 "chainid": 3,
250 "chainid": 3,
251 "chainlen": 1,
251 "chainlen": 1,
252 "chainratio": 1.02325581395, (no-py3 !)
252 "chainratio": 1.02325581395, (no-py3 !)
253 "chainratio": 1.0232558139534884, (py3 !)
253 "chainratio": 1.0232558139534884, (py3 !)
254 "chainsize": 44,
254 "chainsize": 44,
255 "compsize": 44,
255 "compsize": 44,
256 "deltatype": "base",
256 "deltatype": "base",
257 "extradist": 0,
257 "extradist": 0,
258 "extraratio": 0.0,
258 "extraratio": 0.0,
259 "largestblock": 44,
259 "largestblock": 44,
260 "lindist": 44,
260 "lindist": 44,
261 "prevrev": -1,
261 "prevrev": -1,
262 "readdensity": 1.0,
262 "readdensity": 1.0,
263 "readsize": 44,
263 "readsize": 44,
264 "rev": 2,
264 "rev": 2,
265 "srchunks": 1,
265 "srchunks": 1,
266 "uncompsize": 43
266 "uncompsize": 43
267 }
267 }
268 ]
268 ]
269
269
270 debugdelta chain with sparse read enabled
270 debugdelta chain with sparse read enabled
271
271
272 $ cat >> $HGRCPATH <<EOF
272 $ cat >> $HGRCPATH <<EOF
273 > [experimental]
273 > [experimental]
274 > sparse-read = True
274 > sparse-read = True
275 > EOF
275 > EOF
276 $ hg debugdeltachain -m
276 $ hg debugdeltachain -m
277 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
277 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks
278 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
278 0 1 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
279 1 2 1 -1 base 0 0 0 0.00000 0 0 0.00000 0 0 1.00000 1
279 1 2 1 -1 base 0 0 0 0.00000 0 0 0.00000 0 0 1.00000 1
280 2 3 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
280 2 3 1 -1 base 44 43 44 1.02326 44 0 0.00000 44 44 1.00000 1
281
281
282 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n'
282 $ hg debugdeltachain -m -T '{rev} {chainid} {chainlen} {readsize} {largestblock} {readdensity}\n'
283 0 1 1 44 44 1.0
283 0 1 1 44 44 1.0
284 1 2 1 0 0 1
284 1 2 1 0 0 1
285 2 3 1 44 44 1.0
285 2 3 1 44 44 1.0
286
286
287 $ hg debugdeltachain -m -Tjson
287 $ hg debugdeltachain -m -Tjson
288 [
288 [
289 {
289 {
290 "chainid": 1,
290 "chainid": 1,
291 "chainlen": 1,
291 "chainlen": 1,
292 "chainratio": 1.02325581395, (no-py3 !)
292 "chainratio": 1.02325581395, (no-py3 !)
293 "chainratio": 1.0232558139534884, (py3 !)
293 "chainratio": 1.0232558139534884, (py3 !)
294 "chainsize": 44,
294 "chainsize": 44,
295 "compsize": 44,
295 "compsize": 44,
296 "deltatype": "base",
296 "deltatype": "base",
297 "extradist": 0,
297 "extradist": 0,
298 "extraratio": 0.0,
298 "extraratio": 0.0,
299 "largestblock": 44,
299 "largestblock": 44,
300 "lindist": 44,
300 "lindist": 44,
301 "prevrev": -1,
301 "prevrev": -1,
302 "readdensity": 1.0,
302 "readdensity": 1.0,
303 "readsize": 44,
303 "readsize": 44,
304 "rev": 0,
304 "rev": 0,
305 "srchunks": 1,
305 "srchunks": 1,
306 "uncompsize": 43
306 "uncompsize": 43
307 },
307 },
308 {
308 {
309 "chainid": 2,
309 "chainid": 2,
310 "chainlen": 1,
310 "chainlen": 1,
311 "chainratio": 0,
311 "chainratio": 0,
312 "chainsize": 0,
312 "chainsize": 0,
313 "compsize": 0,
313 "compsize": 0,
314 "deltatype": "base",
314 "deltatype": "base",
315 "extradist": 0,
315 "extradist": 0,
316 "extraratio": 0,
316 "extraratio": 0,
317 "largestblock": 0,
317 "largestblock": 0,
318 "lindist": 0,
318 "lindist": 0,
319 "prevrev": -1,
319 "prevrev": -1,
320 "readdensity": 1,
320 "readdensity": 1,
321 "readsize": 0,
321 "readsize": 0,
322 "rev": 1,
322 "rev": 1,
323 "srchunks": 1,
323 "srchunks": 1,
324 "uncompsize": 0
324 "uncompsize": 0
325 },
325 },
326 {
326 {
327 "chainid": 3,
327 "chainid": 3,
328 "chainlen": 1,
328 "chainlen": 1,
329 "chainratio": 1.02325581395, (no-py3 !)
329 "chainratio": 1.02325581395, (no-py3 !)
330 "chainratio": 1.0232558139534884, (py3 !)
330 "chainratio": 1.0232558139534884, (py3 !)
331 "chainsize": 44,
331 "chainsize": 44,
332 "compsize": 44,
332 "compsize": 44,
333 "deltatype": "base",
333 "deltatype": "base",
334 "extradist": 0,
334 "extradist": 0,
335 "extraratio": 0.0,
335 "extraratio": 0.0,
336 "largestblock": 44,
336 "largestblock": 44,
337 "lindist": 44,
337 "lindist": 44,
338 "prevrev": -1,
338 "prevrev": -1,
339 "readdensity": 1.0,
339 "readdensity": 1.0,
340 "readsize": 44,
340 "readsize": 44,
341 "rev": 2,
341 "rev": 2,
342 "srchunks": 1,
342 "srchunks": 1,
343 "uncompsize": 43
343 "uncompsize": 43
344 }
344 }
345 ]
345 ]
346
346
347 $ printf "This test checks things.\n" >> a
347 $ printf "This test checks things.\n" >> a
348 $ hg ci -m a
348 $ hg ci -m a
349 $ hg branch other
349 $ hg branch other
350 marked working directory as branch other
350 marked working directory as branch other
351 (branches are permanent and global, did you want a bookmark?)
351 (branches are permanent and global, did you want a bookmark?)
352 $ for i in `$TESTDIR/seq.py 5`; do
352 $ for i in `$TESTDIR/seq.py 5`; do
353 > printf "shorter ${i}" >> a
353 > printf "shorter ${i}" >> a
354 > hg ci -m "a other:$i"
354 > hg ci -m "a other:$i"
355 > hg up -q default
355 > hg up -q default
356 > printf "for the branch default we want longer chains: ${i}" >> a
356 > printf "for the branch default we want longer chains: ${i}" >> a
357 > hg ci -m "a default:$i"
357 > hg ci -m "a default:$i"
358 > hg up -q other
358 > hg up -q other
359 > done
359 > done
360 $ hg debugdeltachain a -T '{rev} {srchunks}\n' \
360 $ hg debugdeltachain a -T '{rev} {srchunks}\n' \
361 > --config experimental.sparse-read.density-threshold=0.50 \
361 > --config experimental.sparse-read.density-threshold=0.50 \
362 > --config experimental.sparse-read.min-gap-size=0
362 > --config experimental.sparse-read.min-gap-size=0
363 0 1
363 0 1
364 1 1
364 1 1
365 2 1
365 2 1
366 3 1
366 3 1
367 4 1
367 4 1
368 5 1
368 5 1
369 6 1
369 6 1
370 7 1
370 7 1
371 8 1
371 8 1
372 9 1
372 9 1
373 10 2 (no-zstd !)
373 10 2 (no-zstd !)
374 10 1 (zstd !)
374 10 1 (zstd !)
375 11 1
375 11 1
376 $ hg --config extensions.strip= strip --no-backup -r 1
376 $ hg --config extensions.strip= strip --no-backup -r 1
377 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
377 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
378
378
379 Test max chain len
379 Test max chain len
380 $ cat >> $HGRCPATH << EOF
380 $ cat >> $HGRCPATH << EOF
381 > [format]
381 > [format]
382 > maxchainlen=4
382 > maxchainlen=4
383 > EOF
383 > EOF
384
384
385 $ printf "This test checks if maxchainlen config value is respected also it can serve as basic test for debugrevlog -d <file>.\n" >> a
385 $ printf "This test checks if maxchainlen config value is respected also it can serve as basic test for debugrevlog -d <file>.\n" >> a
386 $ hg ci -m a
386 $ hg ci -m a
387 $ printf "b\n" >> a
387 $ printf "b\n" >> a
388 $ hg ci -m a
388 $ hg ci -m a
389 $ printf "c\n" >> a
389 $ printf "c\n" >> a
390 $ hg ci -m a
390 $ hg ci -m a
391 $ printf "d\n" >> a
391 $ printf "d\n" >> a
392 $ hg ci -m a
392 $ hg ci -m a
393 $ printf "e\n" >> a
393 $ printf "e\n" >> a
394 $ hg ci -m a
394 $ hg ci -m a
395 $ printf "f\n" >> a
395 $ printf "f\n" >> a
396 $ hg ci -m a
396 $ hg ci -m a
397 $ printf 'g\n' >> a
397 $ printf 'g\n' >> a
398 $ hg ci -m a
398 $ hg ci -m a
399 $ printf 'h\n' >> a
399 $ printf 'h\n' >> a
400 $ hg ci -m a
400 $ hg ci -m a
401
401
402 $ hg debugrevlog -d a
402 $ hg debugrevlog -d a
403 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
403 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
404 0 -1 -1 0 ??? 0 0 0 0 ??? ???? ? 1 0 (glob)
404 0 -1 -1 0 ??? 0 0 0 0 ??? ???? ? 1 0 (glob)
405 1 0 -1 ??? ??? 0 0 0 0 ??? ???? ? 1 1 (glob)
405 1 0 -1 ??? ??? 0 0 0 0 ??? ???? ? 1 1 (glob)
406 2 1 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
406 2 1 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
407 3 2 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
407 3 2 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
408 4 3 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 4 (glob)
408 4 3 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 4 (glob)
409 5 4 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 0 (glob)
409 5 4 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 0 (glob)
410 6 5 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 1 (glob)
410 6 5 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 1 (glob)
411 7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
411 7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
412 8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
412 8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
413 #endif
413 #endif
414
414
415 Test debuglocks command:
415 Test debuglocks command:
416
416
417 $ hg debuglocks
417 $ hg debuglocks
418 lock: free
418 lock: free
419 wlock: free
419 wlock: free
420
420
421 * Test setting the lock
421 * Test setting the lock
422
422
423 waitlock <file> will wait for file to be created. If it isn't in a reasonable
423 waitlock <file> will wait for file to be created. If it isn't in a reasonable
424 amount of time, displays error message and returns 1
424 amount of time, displays error message and returns 1
425 $ waitlock() {
425 $ waitlock() {
426 > start=`date +%s`
426 > start=`date +%s`
427 > timeout=5
427 > timeout=5
428 > while [ \( ! -f $1 \) -a \( ! -L $1 \) ]; do
428 > while [ \( ! -f $1 \) -a \( ! -L $1 \) ]; do
429 > now=`date +%s`
429 > now=`date +%s`
430 > if [ "`expr $now - $start`" -gt $timeout ]; then
430 > if [ "`expr $now - $start`" -gt $timeout ]; then
431 > echo "timeout: $1 was not created in $timeout seconds"
431 > echo "timeout: $1 was not created in $timeout seconds"
432 > return 1
432 > return 1
433 > fi
433 > fi
434 > sleep 0.1
434 > sleep 0.1
435 > done
435 > done
436 > }
436 > }
437 $ dolock() {
437 $ dolock() {
438 > {
438 > {
439 > waitlock .hg/unlock
439 > waitlock .hg/unlock
440 > rm -f .hg/unlock
440 > rm -f .hg/unlock
441 > echo y
441 > echo y
442 > } | hg debuglocks "$@" > /dev/null
442 > } | hg debuglocks "$@" > /dev/null
443 > }
443 > }
444 $ dolock -s &
444 $ dolock -s &
445 $ waitlock .hg/store/lock
445 $ waitlock .hg/store/lock
446
446
447 $ hg debuglocks
447 $ hg debuglocks
448 lock: user *, process * (*s) (glob)
448 lock: user *, process * (*s) (glob)
449 wlock: free
449 wlock: free
450 [1]
450 [1]
451 $ touch .hg/unlock
451 $ touch .hg/unlock
452 $ wait
452 $ wait
453 $ [ -f .hg/store/lock ] || echo "There is no lock"
453 $ [ -f .hg/store/lock ] || echo "There is no lock"
454 There is no lock
454 There is no lock
455
455
456 * Test setting the wlock
456 * Test setting the wlock
457
457
458 $ dolock -S &
458 $ dolock -S &
459 $ waitlock .hg/wlock
459 $ waitlock .hg/wlock
460
460
461 $ hg debuglocks
461 $ hg debuglocks
462 lock: free
462 lock: free
463 wlock: user *, process * (*s) (glob)
463 wlock: user *, process * (*s) (glob)
464 [1]
464 [1]
465 $ touch .hg/unlock
465 $ touch .hg/unlock
466 $ wait
466 $ wait
467 $ [ -f .hg/wlock ] || echo "There is no wlock"
467 $ [ -f .hg/wlock ] || echo "There is no wlock"
468 There is no wlock
468 There is no wlock
469
469
470 * Test setting both locks
470 * Test setting both locks
471
471
472 $ dolock -Ss &
472 $ dolock -Ss &
473 $ waitlock .hg/wlock && waitlock .hg/store/lock
473 $ waitlock .hg/wlock && waitlock .hg/store/lock
474
474
475 $ hg debuglocks
475 $ hg debuglocks
476 lock: user *, process * (*s) (glob)
476 lock: user *, process * (*s) (glob)
477 wlock: user *, process * (*s) (glob)
477 wlock: user *, process * (*s) (glob)
478 [2]
478 [2]
479
479
480 * Test failing to set a lock
480 * Test failing to set a lock
481
481
482 $ hg debuglocks -s
482 $ hg debuglocks -s
483 abort: lock is already held
483 abort: lock is already held
484 [255]
484 [255]
485
485
486 $ hg debuglocks -S
486 $ hg debuglocks -S
487 abort: wlock is already held
487 abort: wlock is already held
488 [255]
488 [255]
489
489
490 $ touch .hg/unlock
490 $ touch .hg/unlock
491 $ wait
491 $ wait
492
492
493 $ hg debuglocks
493 $ hg debuglocks
494 lock: free
494 lock: free
495 wlock: free
495 wlock: free
496
496
497 * Test forcing the lock
497 * Test forcing the lock
498
498
499 $ dolock -s &
499 $ dolock -s &
500 $ waitlock .hg/store/lock
500 $ waitlock .hg/store/lock
501
501
502 $ hg debuglocks
502 $ hg debuglocks
503 lock: user *, process * (*s) (glob)
503 lock: user *, process * (*s) (glob)
504 wlock: free
504 wlock: free
505 [1]
505 [1]
506
506
507 $ hg debuglocks -L
507 $ hg debuglocks -L
508
508
509 $ hg debuglocks
509 $ hg debuglocks
510 lock: free
510 lock: free
511 wlock: free
511 wlock: free
512
512
513 $ touch .hg/unlock
513 $ touch .hg/unlock
514 $ wait
514 $ wait
515
515
516 * Test forcing the wlock
516 * Test forcing the wlock
517
517
518 $ dolock -S &
518 $ dolock -S &
519 $ waitlock .hg/wlock
519 $ waitlock .hg/wlock
520
520
521 $ hg debuglocks
521 $ hg debuglocks
522 lock: free
522 lock: free
523 wlock: user *, process * (*s) (glob)
523 wlock: user *, process * (*s) (glob)
524 [1]
524 [1]
525
525
526 $ hg debuglocks -W
526 $ hg debuglocks -W
527
527
528 $ hg debuglocks
528 $ hg debuglocks
529 lock: free
529 lock: free
530 wlock: free
530 wlock: free
531
531
532 $ touch .hg/unlock
532 $ touch .hg/unlock
533 $ wait
533 $ wait
534
534
535 Test WdirUnsupported exception
535 Test WdirUnsupported exception
536
536
537 $ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff
537 $ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff
538 abort: working directory revision cannot be specified
538 abort: working directory revision cannot be specified
539 [255]
539 [255]
540
540
541 Test cache warming command
541 Test cache warming command
542
542
543 $ rm -rf .hg/cache/
543 $ rm -rf .hg/cache/
544 $ hg debugupdatecaches --debug
544 $ hg debugupdatecaches --debug
545 updating the branch cache
545 updating the branch cache
546 $ ls -r .hg/cache/*
546 $ ls -r .hg/cache/*
547 .hg/cache/tags2-served
547 .hg/cache/tags2-served
548 .hg/cache/tags2
548 .hg/cache/tags2
549 .hg/cache/rbc-revs-v1
549 .hg/cache/rbc-revs-v1
550 .hg/cache/rbc-names-v1
550 .hg/cache/rbc-names-v1
551 .hg/cache/hgtagsfnodes1
551 .hg/cache/hgtagsfnodes1
552 .hg/cache/branch2-visible-hidden
552 .hg/cache/branch2-visible-hidden
553 .hg/cache/branch2-visible
553 .hg/cache/branch2-visible
554 .hg/cache/branch2-served.hidden
554 .hg/cache/branch2-served.hidden
555 .hg/cache/branch2-served
555 .hg/cache/branch2-served
556 .hg/cache/branch2-immutable
556 .hg/cache/branch2-immutable
557 .hg/cache/branch2-base
557 .hg/cache/branch2-base
558
558
559 Test debugcolor
559 Test debugcolor
560
560
561 #if no-windows
561 #if no-windows
562 $ hg debugcolor --style --color always | egrep 'mode|style|log\.'
562 $ hg debugcolor --style --color always | egrep 'mode|style|log\.'
563 color mode: 'ansi'
563 color mode: 'ansi'
564 available style:
564 available style:
565 \x1b[0;33mlog.changeset\x1b[0m: \x1b[0;33myellow\x1b[0m (esc)
565 \x1b[0;33mlog.changeset\x1b[0m: \x1b[0;33myellow\x1b[0m (esc)
566 #endif
566 #endif
567
567
568 $ hg debugcolor --style --color never
568 $ hg debugcolor --style --color never
569 color mode: None
569 color mode: None
570 available style:
570 available style:
571
571
572 $ cd ..
572 $ cd ..
573
573
574 Test internal debugstacktrace command
574 Test internal debugstacktrace command
575
575
576 $ cat > debugstacktrace.py << EOF
576 $ cat > debugstacktrace.py << EOF
577 > from __future__ import absolute_import
577 > from __future__ import absolute_import
578 > from mercurial import (
578 > from mercurial import (
579 > util,
579 > util,
580 > )
580 > )
581 > from mercurial.utils import (
581 > from mercurial.utils import (
582 > procutil,
582 > procutil,
583 > )
583 > )
584 > def f():
584 > def f():
585 > util.debugstacktrace(f=procutil.stdout)
585 > util.debugstacktrace(f=procutil.stdout)
586 > g()
586 > g()
587 > def g():
587 > def g():
588 > util.dst(b'hello from g\\n', skip=1)
588 > util.dst(b'hello from g\\n', skip=1)
589 > h()
589 > h()
590 > def h():
590 > def h():
591 > util.dst(b'hi ...\\nfrom h hidden in g', 1, depth=2)
591 > util.dst(b'hi ...\\nfrom h hidden in g', 1, depth=2)
592 > f()
592 > f()
593 > EOF
593 > EOF
594 $ "$PYTHON" debugstacktrace.py
594 $ "$PYTHON" debugstacktrace.py
595 stacktrace at:
595 stacktrace at:
596 *debugstacktrace.py:16 in * (glob)
596 *debugstacktrace.py:16 in * (glob)
597 *debugstacktrace.py:9 in f (glob)
597 *debugstacktrace.py:9 in f (glob)
598 hello from g at:
598 hello from g at:
599 *debugstacktrace.py:16 in * (glob)
599 *debugstacktrace.py:16 in * (glob)
600 *debugstacktrace.py:10 in f (glob)
600 *debugstacktrace.py:10 in f (glob)
601 hi ...
601 hi ...
602 from h hidden in g at:
602 from h hidden in g at:
603 *debugstacktrace.py:10 in f (glob)
603 *debugstacktrace.py:10 in f (glob)
604 *debugstacktrace.py:13 in g (glob)
604 *debugstacktrace.py:13 in g (glob)
605
605
606 Test debugcapabilities command:
606 Test debugcapabilities command:
607
607
608 $ hg debugcapabilities ./debugrevlog/
608 $ hg debugcapabilities ./debugrevlog/
609 Main capabilities:
609 Main capabilities:
610 branchmap
610 branchmap
611 $USUAL_BUNDLE2_CAPS$
611 $USUAL_BUNDLE2_CAPS$
612 getbundle
612 getbundle
613 known
613 known
614 lookup
614 lookup
615 pushkey
615 pushkey
616 unbundle
616 unbundle
617 Bundle2 capabilities:
617 Bundle2 capabilities:
618 HG20
618 HG20
619 bookmarks
619 bookmarks
620 changegroup
620 changegroup
621 01
621 01
622 02
622 02
623 checkheads
623 checkheads
624 related
624 related
625 digests
625 digests
626 md5
626 md5
627 sha1
627 sha1
628 sha512
628 sha512
629 error
629 error
630 abort
630 abort
631 unsupportedcontent
631 unsupportedcontent
632 pushraced
632 pushraced
633 pushkey
633 pushkey
634 hgtagsfnodes
634 hgtagsfnodes
635 listkeys
635 listkeys
636 phases
636 phases
637 heads
637 heads
638 pushkey
638 pushkey
639 remote-changegroup
639 remote-changegroup
640 http
640 http
641 https
641 https
642 stream
642 stream
643 v2
643 v2
644
644
645 Test debugpeer
645 Test debugpeer
646
646
647 $ hg debugpeer ssh://user@dummy/debugrevlog
647 $ hg debugpeer ssh://user@dummy/debugrevlog
648 url: ssh://user@dummy/debugrevlog
648 url: ssh://user@dummy/debugrevlog
649 local: no
649 local: no
650 pushable: yes
650 pushable: yes
651
651
652 #if rust
652 #if rust
653
653
654 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
654 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
655 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
655 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
656 devel-peer-request: hello+between
656 devel-peer-request: hello+between
657 devel-peer-request: pairs: 81 bytes
657 devel-peer-request: pairs: 81 bytes
658 sending hello command
658 sending hello command
659 sending between command
659 sending between command
660 remote: 463
660 remote: 487
661 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,persistent-nodemap,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
661 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,persistent-nodemap,revlog-compression-zstd,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
662 remote: 1
662 remote: 1
663 devel-peer-request: protocaps
663 devel-peer-request: protocaps
664 devel-peer-request: caps: * bytes (glob)
664 devel-peer-request: caps: * bytes (glob)
665 sending protocaps command
665 sending protocaps command
666 url: ssh://user@dummy/debugrevlog
666 url: ssh://user@dummy/debugrevlog
667 local: no
667 local: no
668 pushable: yes
668 pushable: yes
669
669
670 #endif
670 #endif
671
671
672 #if no-rust zstd
672 #if no-rust zstd
673
673
674 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
674 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
675 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
675 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
676 devel-peer-request: hello+between
676 devel-peer-request: hello+between
677 devel-peer-request: pairs: 81 bytes
677 devel-peer-request: pairs: 81 bytes
678 sending hello command
678 sending hello command
679 sending between command
679 sending between command
680 remote: 444
680 remote: 468
681 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
681 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlog-compression-zstd,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
682 remote: 1
682 remote: 1
683 devel-peer-request: protocaps
683 devel-peer-request: protocaps
684 devel-peer-request: caps: * bytes (glob)
684 devel-peer-request: caps: * bytes (glob)
685 sending protocaps command
685 sending protocaps command
686 url: ssh://user@dummy/debugrevlog
686 url: ssh://user@dummy/debugrevlog
687 local: no
687 local: no
688 pushable: yes
688 pushable: yes
689
689
690 #endif
690 #endif
691
691
692 #if no-rust no-zstd
692 #if no-rust no-zstd
693
693
694 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
694 $ hg --debug debugpeer ssh://user@dummy/debugrevlog
695 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
695 running .* ".*[/\\]dummyssh" ['"]user@dummy['"] ['"]hg -R debugrevlog serve --stdio['"] (re)
696 devel-peer-request: hello+between
696 devel-peer-request: hello+between
697 devel-peer-request: pairs: 81 bytes
697 devel-peer-request: pairs: 81 bytes
698 sending hello command
698 sending hello command
699 sending between command
699 sending between command
700 remote: 444
700 remote: 444
701 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
701 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
702 remote: 1
702 remote: 1
703 devel-peer-request: protocaps
703 devel-peer-request: protocaps
704 devel-peer-request: caps: * bytes (glob)
704 devel-peer-request: caps: * bytes (glob)
705 sending protocaps command
705 sending protocaps command
706 url: ssh://user@dummy/debugrevlog
706 url: ssh://user@dummy/debugrevlog
707 local: no
707 local: no
708 pushable: yes
708 pushable: yes
709
709
710 #endif
710 #endif
General Comments 0
You need to be logged in to leave comments. Login now