mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
dvc: safely return to saved tree in brancher
This commit is contained in:
+6
-10
@@ -42,13 +42,9 @@ def brancher( # noqa: E302
|
||||
if all_tags:
|
||||
revs.extend(scm.list_tags())
|
||||
|
||||
# NOTE: it might be a good idea to wrap this loop in try/finally block
|
||||
# to don't leave the tree on some unexpected branch after the
|
||||
# `brancher()`, but this could cause problems on exception handling
|
||||
# code which might expect the tree on which exception was raised to
|
||||
# stay in place. This behavior is a subject to change.
|
||||
for sha, names in group_by(scm.resolve_rev, revs).items():
|
||||
self.tree = CleanTree(scm.get_tree(sha))
|
||||
yield ", ".join(names)
|
||||
|
||||
self.tree = saved_tree
|
||||
try:
|
||||
for sha, names in group_by(scm.resolve_rev, revs).items():
|
||||
self.tree = CleanTree(scm.get_tree(sha))
|
||||
yield ", ".join(names)
|
||||
finally:
|
||||
self.tree = saved_tree
|
||||
|
||||
Reference in New Issue
Block a user