Skip to content
Snippets Groups Projects
Commit 1a47fd00 authored by Georges Racinet's avatar Georges Racinet
Browse files

testhelpers: write_commit optionally returning changectx

It's probably what we always want if we care about the return,
will maybe become the default later.

Tested by using it in test_write_commit_random()
parent 4788be77
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
def write_commit(self, rpath, def write_commit(self, rpath,
content=None, message=None, content=None, message=None,
return_ctx=False,
parent=None, branch=None): parent=None, branch=None):
"""Write content at rpath and commit in one call. """Write content at rpath and commit in one call.
...@@ -108,9 +109,10 @@ ...@@ -108,9 +109,10 @@
match=match, match=match,
editor=False, editor=False,
extra=None) extra=None)
return cmdutil.commit(repo.ui, repo, commitfun, (path, ), new_node = cmdutil.commit(repo.ui, repo, commitfun, (path, ),
dict(addremove=True, dict(addremove=True,
message=message)) message=message))
return repo[new_node] if return_ctx else new_node
def update_bin(self, bin_node): def update_bin(self, bin_node):
"""Update to a revision specified by its node in binary form. """Update to a revision specified by its node in binary form.
......
...@@ -130,6 +130,6 @@ ...@@ -130,6 +130,6 @@
wrapper = LocalRepoWrapper.init(tmpdir) wrapper = LocalRepoWrapper.init(tmpdir)
node0 = wrapper.write_commit('foo') node0 = wrapper.write_commit('foo')
node1 = wrapper.write_commit('foo', parent=node0) ctx1 = wrapper.write_commit('foo', parent=node0, return_ctx=True)
node2 = wrapper.write_commit('foo', parent=node0) ctx2 = wrapper.write_commit('foo', parent=node0, return_ctx=True)
...@@ -135,6 +135,4 @@ ...@@ -135,6 +135,4 @@
ctx1 = wrapper.repo[node1]
ctx2 = wrapper.repo[node2]
assert ctx1.p1() == ctx2.p1() assert ctx1.p1() == ctx2.p1()
assert ctx1 != ctx2 assert ctx1 != ctx2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment