Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
py-heptapod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
heptapod
py-heptapod
Commits
79131e356920
Commit
79131e356920
authored
4 years ago
by
Georges Racinet
Browse files
Options
Downloads
Patches
Plain Diff
testhelpers: new commit_remove() helper method
This is the equivalent to `hg rm` for a single file.
parent
9935ee545308
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
heptapod/testhelpers.py
+17
-0
17 additions, 0 deletions
heptapod/testhelpers.py
heptapod/tests/test_testhelpers.py
+18
-0
18 additions, 0 deletions
heptapod/tests/test_testhelpers.py
with
35 additions
and
0 deletions
heptapod/testhelpers.py
+
17
−
0
View file @
79131e35
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
heptapod/tests/test_testhelpers.py
+
18
−
0
View file @
79131e35
...
...
@@ -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
=
''
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment