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
d8b7d77b61d7
Commit
d8b7d77b61d7
authored
5 years ago
by
Georges Racinet
Browse files
Options
Downloads
Patches
Plain Diff
testhelpers: write_commit branch kwarg
parent
3b02a4edcda8
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
+6
-1
6 additions, 1 deletion
heptapod/testhelpers.py
heptapod/tests/test_testhelpers.py
+17
-2
17 additions, 2 deletions
heptapod/tests/test_testhelpers.py
with
23 additions
and
3 deletions
heptapod/testhelpers.py
+
6
−
1
View file @
d8b7d77b
...
...
@@ -56,7 +56,9 @@
ui
=
make_ui
(
base_ui
,
config
=
config
)
return
cls
(
hg
.
repository
(
ui
,
path
))
def
write_commit
(
self
,
rpath
,
content
=
None
,
message
=
None
,
parent
=
None
):
def
write_commit
(
self
,
rpath
,
content
=
None
,
message
=
None
,
parent
=
None
,
branch
=
None
):
"""
Write content at rpath and commit in one call.
This is meant to allow fast and efficient preparation of
...
...
@@ -88,6 +90,9 @@
if
parent
is
not
None
:
self
.
update_bin
(
parent
)
if
branch
is
not
None
:
self
.
repo
.
dirstate
.
setbranch
(
branch
)
flags
=
'
wb
'
if
isinstance
(
content
,
bytes
)
else
'
w
'
with
open
(
path
,
flags
)
as
fobj
:
fobj
.
write
(
content
)
...
...
This diff is collapsed.
Click to expand it.
heptapod/tests/test_testhelpers.py
+
17
−
2
View file @
d8b7d77b
...
...
@@ -98,8 +98,8 @@
assert
foo
.
read
()
==
'
Foo 1
'
def
test_write_commit_branch
ing
(
tmpdir
):
def
test_write_commit_
named_
branch
(
tmpdir
):
"""
Demonstrate the use of write_commit with parent.
"""
wrapper
=
LocalRepoWrapper
.
init
(
tmpdir
)
node0
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 0
'
)
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 1
'
)
...
...
@@ -102,7 +102,8 @@
"""
Demonstrate the use of write_commit with parent.
"""
wrapper
=
LocalRepoWrapper
.
init
(
tmpdir
)
node0
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 0
'
)
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 1
'
)
nodebr
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo branch
'
,
parent
=
node0
)
nodebr
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo branch
'
,
parent
=
node0
,
branch
=
'
other
'
)
ctxbr
=
wrapper
.
repo
[
nodebr
]
...
...
@@ -107,3 +108,4 @@
ctxbr
=
wrapper
.
repo
[
nodebr
]
assert
ctxbr
.
branch
()
==
'
other
'
assert
[
c
.
node
()
for
c
in
ctxbr
.
parents
()]
==
[
node0
]
...
...
@@ -109,1 +111,14 @@
assert
[
c
.
node
()
for
c
in
ctxbr
.
parents
()]
==
[
node0
]
def
test_write_commit_wild_branch
(
tmpdir
):
"""
Demonstrate the use of write_commit with parent.
"""
wrapper
=
LocalRepoWrapper
.
init
(
tmpdir
)
node0
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 0
'
)
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo 1
'
)
nodebr
=
wrapper
.
write_commit
(
'
foo
'
,
content
=
'
Foo branch
'
,
parent
=
node0
)
ctxbr
=
wrapper
.
repo
[
nodebr
]
assert
ctxbr
.
branch
()
==
'
default
'
assert
[
c
.
node
()
for
c
in
ctxbr
.
parents
()]
==
[
node0
]
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