Mercurial > hg
comparison mercurial/bundlerepo.py @ 51012:3470a39fb66b
revlog: adapt the `reading` check for `bundlerepo`
We cannot just rely on the length check for the `bundlerepo` as the local
revlog might be empty with all data in the bundle.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 25 Sep 2023 12:13:38 +0200 |
parents | d718eddf01d9 |
children | 8520db304f01 |
comparison
equal
deleted
inserted
replaced
51011:9461a0b74596 | 51012:3470a39fb66b |
---|---|
10 This provides a read-only repository interface to bundles as if they | 10 This provides a read-only repository interface to bundles as if they |
11 were part of the actual repository. | 11 were part of the actual repository. |
12 """ | 12 """ |
13 | 13 |
14 | 14 |
15 import contextlib | |
15 import os | 16 import os |
16 import shutil | 17 import shutil |
17 | 18 |
18 from .i18n import _ | 19 from .i18n import _ |
19 from .node import ( | 20 from .node import ( |
105 node_id=node, | 106 node_id=node, |
106 ) | 107 ) |
107 self.index.append(e) | 108 self.index.append(e) |
108 self.bundlerevs.add(n) | 109 self.bundlerevs.add(n) |
109 n += 1 | 110 n += 1 |
111 | |
112 @contextlib.contextmanager | |
113 def reading(self): | |
114 if self.repotiprev < 0: | |
115 yield | |
116 else: | |
117 with super().reading() as x: | |
118 yield x | |
110 | 119 |
111 def _chunk(self, rev, df=None): | 120 def _chunk(self, rev, df=None): |
112 # Warning: in case of bundle, the diff is against what we stored as | 121 # Warning: in case of bundle, the diff is against what we stored as |
113 # delta base, not against rev - 1 | 122 # delta base, not against rev - 1 |
114 # XXX: could use some caching | 123 # XXX: could use some caching |