Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
heptapod
py-heptapod
Commits
79131e356920
Commit
533cb7d0
authored
Nov 11, 2020
by
Georges Racinet
🎸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testhelpers: new commit_remove() helper method
This is the equivalent to `hg rm` for a single file.
parent
9935ee545308
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
heptapod/testhelpers.py
heptapod/testhelpers.py
+17
-0
heptapod/tests/test_testhelpers.py
heptapod/tests/test_testhelpers.py
+18
-0
No files found.
heptapod/testhelpers.py
View file @
79131e35
...
...
@@ -266,6 +266,23 @@ class LocalRepoWrapper(object):
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.
...
...
heptapod/tests/test_testhelpers.py
View file @
79131e35
...
...
@@ -237,6 +237,24 @@ def test_phase(tmpdir):
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
=
''
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment