Mercurial > public > mercurial-scm > hg
comparison mercurial/repair.py @ 39686:3d22aef3ecd5
transaction: make entries a private attribute (API)
This attribute is tracking changes to append-only files. It is
an implementation detail and should not be exposed as part of
the public interface.
But code in repair was accessing it, so it seemingly does belong
as part of the public API. But that code in repair is making
assumptions about how storage works and is grossly wrong when
alternate storage backends are in play. We'll need some kind of
"strip" API at the storage layer that knows how to handle things
in a storage-agnostic manner. I don't think accessing a private
attribute on the transaction is any worse than what this code
is already doing. So I'm fine with violating the abstraction for
transactions.
And with this change, all per-instance attributes on transaction
have been made private except for "changes" and "hookargs." Both
are used by multiple consumers and look like they need to be
part of the public interface.
.. api::
Various attributes of ``transaction.transaction`` are now ``_``
prefixed to indicate they shouldn't be used by external
consumers.
Differential Revision: https://phab.mercurial-scm.org/D4634
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 17 Sep 2018 16:29:12 -0700 |
parents | 73cf21b2e8a6 |
children | b2ec79559a4b |
comparison
equal
deleted
inserted
replaced
39685:4024c363cd33 | 39686:3d22aef3ecd5 |
---|---|
188 compress=False, obsolescence=False) | 188 compress=False, obsolescence=False) |
189 | 189 |
190 with ui.uninterruptable(): | 190 with ui.uninterruptable(): |
191 try: | 191 try: |
192 with repo.transaction("strip") as tr: | 192 with repo.transaction("strip") as tr: |
193 offset = len(tr.entries) | 193 # TODO this code violates the interface abstraction of the |
194 # transaction and makes assumptions that file storage is | |
195 # using append-only files. We'll need some kind of storage | |
196 # API to handle stripping for us. | |
197 offset = len(tr._entries) | |
194 | 198 |
195 tr.startgroup() | 199 tr.startgroup() |
196 cl.strip(striprev, tr) | 200 cl.strip(striprev, tr) |
197 stripmanifest(repo, striprev, tr, files) | 201 stripmanifest(repo, striprev, tr, files) |
198 | 202 |
199 for fn in files: | 203 for fn in files: |
200 repo.file(fn).strip(striprev, tr) | 204 repo.file(fn).strip(striprev, tr) |
201 tr.endgroup() | 205 tr.endgroup() |
202 | 206 |
203 for i in pycompat.xrange(offset, len(tr.entries)): | 207 for i in pycompat.xrange(offset, len(tr._entries)): |
204 file, troffset, ignore = tr.entries[i] | 208 file, troffset, ignore = tr._entries[i] |
205 with repo.svfs(file, 'a', checkambig=True) as fp: | 209 with repo.svfs(file, 'a', checkambig=True) as fp: |
206 fp.truncate(troffset) | 210 fp.truncate(troffset) |
207 if troffset == 0: | 211 if troffset == 0: |
208 repo.store.markremoved(file) | 212 repo.store.markremoved(file) |
209 | 213 |