Mercurial > hg-stable
view tests/fakemergerecord.py @ 40009:842ffcf1d42f
storageutil: extract most of emitrevisions() to standalone function
As part of implementing a storage backend, I found myself copying
most of revlog.emitrevisions(). This code is highly nuanced and it
bothered me greatly to be copying such low-level code.
This commit extracts the bulk of revlog.emitrevisions() into a
new standalone function. In order to make the function generally
usable, all "self" function calls that aren't exposed on the
ifilestorage interface are passed in via callable arguments.
No meaningful behavior should have changed as part of the port.
Upcoming commits will tweak behavior to make the code more
generically usable.
Differential Revision: https://phab.mercurial-scm.org/D4803
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 28 Sep 2018 16:16:22 -0700 |
parents | 4dc6f0905722 |
children | 2372284d9457 |
line wrap: on
line source
# Extension to write out fake unsupported records into the merge state # # from __future__ import absolute_import from mercurial import ( merge, registrar, ) cmdtable = {} command = registrar.command(cmdtable) @command(b'fakemergerecord', [(b'X', b'mandatory', None, b'add a fake mandatory record'), (b'x', b'advisory', None, b'add a fake advisory record')], '') def fakemergerecord(ui, repo, *pats, **opts): with repo.wlock(): ms = merge.mergestate.read(repo) records = ms._makerecords() if opts.get('mandatory'): records.append((b'X', b'mandatory record')) if opts.get('advisory'): records.append((b'x', b'advisory record')) ms._writerecords(records)