sapling/tests/commitextra.py
Siddharth Agarwal 553598f445 git_handler: store hg extra data in git deterministically by sorting it
Previously, we'd iterate over the extra elements in arbitrary order. We now
sort the elements and store them in deterministic order.

Without sorting, the included test fails half the time.
2014-08-31 05:13:39 -07:00

25 lines
787 B
Python

'''test helper extension to create commits with multiple extra fields'''
from mercurial import cmdutil, commands, scmutil
cmdtable = {}
command = cmdutil.command(cmdtable)
testedwith = 'internal'
@command('commitextra',
[('', 'field', [],
'extra data to store', 'FIELD=VALUE'),
] + commands.commitopts + commands.commitopts2,
'commitextra')
def commitextra(ui, repo, *pats, **opts):
'''make a commit with extra fields'''
fields = opts.get('field')
extras = {}
for field in fields:
k, v = field.split('=', 1)
extras[k] = v
message = cmdutil.logmessage(ui, opts)
repo.commit(message, opts.get('user'), opts.get('date'),
match=scmutil.match(repo[None], pats, opts), extra=extras)
return 0