Commit 47fbaf1c authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

utils.hg: higher level assert_matching_changesets helper

It is based on the previously introduced `changeset_extracts()`
and has options for fields of comparison and order.

The hope is that it will make failures appearing on tests
easier to understand, especially to (relative) newcomers.
parent 8fa3f8406c79
...@@ -183,3 +183,23 @@ class LocalRepo(object): ...@@ -183,3 +183,23 @@ class LocalRepo(object):
self.path.join('.gitlab-ci.yml').write(json.dumps(ci_config)) self.path.join('.gitlab-ci.yml').write(json.dumps(ci_config))
self.hg('add', '.gitlab-ci.yml') self.hg('add', '.gitlab-ci.yml')
self.hg('commit', '-m', message) self.hg('commit', '-m', message)
def assert_matching_changesets(repo1, repo2, fields, ordered=True, revs=None):
"""Assert changesets to have same information in the two given repos
Of course all structural information of the changesets can be checked
with just ``node``, but there is also outer information, like for example
``phases``, and ``bookmarks``, whose inclusion depends on the test case.
Also, adding some human-readable information such as `desc` or `topic`
can make matter more obvious to people engaged in debugging.
The ordering can be kept or not, according to the test case.
collection = tuple if ordered else set
extract1, extract2 = [
repo.changeset_extracts(fields, collection=collection, revs=revs)[1]
for repo in (repo1, repo2)
assert extract1 == extract2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment