Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
mercurial
mercurial-devel
Commits
df76808d
Commit
df76808d
authored
2 years ago
by
Pierre-Yves David
Browse files
Options
Downloads
Patches
Plain Diff
dirstate: use a context manager to handle the file used for writing the branch
This is more modern.
parent
444fa55f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!485
branching: merge default into stable
,
!483
cleanup branch hack in the transaction.
,
!482
write branch in the transaction when applicable
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mercurial/dirstate.py
+5
-7
5 additions, 7 deletions
mercurial/dirstate.py
with
5 additions
and
7 deletions
mercurial/dirstate.py
+
5
−
7
View file @
df76808d
...
...
@@ -613,6 +613,6 @@
def
setbranch
(
self
,
branch
):
self
.
__class__
.
_branch
.
set
(
self
,
encoding
.
fromlocal
(
branch
))
f
=
self
.
_opener
(
b
'
branch
'
,
b
'
w
'
,
atomictemp
=
True
,
checkambig
=
True
)
try
:
vfs
=
self
.
_opener
with
vfs
(
b
'
branch
'
,
b
'
w
'
,
atomictemp
=
True
,
checkambig
=
True
)
as
f
:
f
.
write
(
self
.
_branch
+
b
'
\n
'
)
...
...
@@ -618,5 +618,3 @@
f
.
write
(
self
.
_branch
+
b
'
\n
'
)
f
.
close
()
# make sure filecache has the correct stat info for _branch after
# replacing the underlying file
...
...
@@ -621,5 +619,8 @@
# make sure filecache has the correct stat info for _branch after
# replacing the underlying file
#
# XXX do we actually need this,
# refreshing the attribute is quite cheap
ce
=
self
.
_filecache
[
b
'
_branch
'
]
if
ce
:
ce
.
refresh
()
...
...
@@ -623,9 +624,6 @@
ce
=
self
.
_filecache
[
b
'
_branch
'
]
if
ce
:
ce
.
refresh
()
except
:
# re-raises
f
.
discard
()
raise
def
invalidate
(
self
):
"""
Causes the next access to reread the dirstate.
...
...
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