mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
with: use context manager for transaction in strip
This commit is contained in:
parent
49db6467b8
commit
8bfeb98530
@ -160,10 +160,10 @@ def strip(ui, repo, nodelist, backup=True, topic='backup'):
|
||||
msg = _('programming error: cannot strip from inside a transaction')
|
||||
raise error.Abort(msg, hint=_('contact your extension maintainer'))
|
||||
|
||||
tr = repo.transaction("strip")
|
||||
try:
|
||||
with repo.transaction("strip") as tr:
|
||||
offset = len(tr.entries)
|
||||
|
||||
try:
|
||||
tr.startgroup()
|
||||
cl.strip(striprev, tr)
|
||||
mfst.strip(striprev, tr)
|
||||
@ -171,15 +171,11 @@ def strip(ui, repo, nodelist, backup=True, topic='backup'):
|
||||
repo.file(fn).strip(striprev, tr)
|
||||
tr.endgroup()
|
||||
|
||||
try:
|
||||
for i in xrange(offset, len(tr.entries)):
|
||||
file, troffset, ignore = tr.entries[i]
|
||||
repo.svfs(file, 'a').truncate(troffset)
|
||||
if troffset == 0:
|
||||
repo.store.markremoved(file)
|
||||
tr.close()
|
||||
finally:
|
||||
tr.release()
|
||||
|
||||
if saveheads or savebases:
|
||||
ui.note(_("adding branch\n"))
|
||||
|
Loading…
Reference in New Issue
Block a user