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

testhelpers: new commit_remove() helper method

This is the equivalent to `hg rm` for a single file.
parent 9935ee545308
No related branches found
No related tags found
No related merge requests found
......@@ -266,6 +266,23 @@
return self.commit((path, ), message=message, add_remove=True,
**commit_opts)
def commit_remove(self, rpath, parent=None, message=None,
**commit_opts):
"""Make a commit removing the given file.
:param add_remove: ignored
:param commit_opts: see :meth:`commit` except ``add_removed`` which
is ignored.
"""
commit_opts.pop('add_remove', None)
if message is None:
message = b"removing %s" % as_bytes(rpath)
self.prepare_wdir(parent=parent)
os.unlink(os.path.join(self.repo.root, as_bytes(rpath)))
return self.commit((rpath, ), message=message, add_remove=True,
**commit_opts)
def update_bin(self, bin_node, **opts):
"""Update to a revision specified by its node in binary form.
......
......@@ -237,6 +237,24 @@
assert ctx.phase() == phases.draft
@parametrize('msg_kind', ('no-message', 'explicit-message'))
def test_remove_file(tmpdir, msg_kind):
wrapper = LocalRepoWrapper.init(tmpdir)
wrapper.write_commit('foo', content='bar')
assert tmpdir.join('foo').read() == 'bar'
if msg_kind == 'no-message':
passed_msg, expected_msg = (None, b'removing foo')
else:
passed_msg, expected_msg = ('explicit', b'explicit')
ctx = wrapper.commit_remove('foo', message=passed_msg)
assert ctx.description() == expected_msg
# also proves the file actually was in parent revision
assert ctx.filesremoved() == [b'foo']
assert not tmpdir.join('foo').exists()
def test_prune_update_hidden(tmpdir):
wrapper = LocalRepoWrapper.init(tmpdir,
config=dict(extensions=dict(evolve='')))
......
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