dvc: safely return to saved tree in brancher

This commit is contained in:
Alexander Schepanovski
2020-01-03 19:09:34 +07:00
parent 77b937b001
commit ecd511fc69
+6 -10
View File
@@ -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