mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
+10
-25
@@ -5,12 +5,7 @@ from dvc.scm.tree import WorkingTree
|
||||
|
||||
|
||||
def brancher( # noqa: E302
|
||||
self,
|
||||
branches=None,
|
||||
all_branches=False,
|
||||
tags=None,
|
||||
all_tags=False,
|
||||
all_commits=False,
|
||||
self, all_branches=False, all_tags=False, all_commits=False
|
||||
):
|
||||
"""Generator that iterates over specified revisions.
|
||||
|
||||
@@ -26,7 +21,7 @@ def brancher( # noqa: E302
|
||||
- empty string it there is no branches to iterate over
|
||||
- "Working Tree" if there are uncommitted changes in the SCM repo
|
||||
"""
|
||||
if not any([branches, all_branches, tags, all_tags, all_commits]):
|
||||
if not any([all_branches, all_tags, all_commits]):
|
||||
yield ""
|
||||
return
|
||||
|
||||
@@ -42,24 +37,14 @@ def brancher( # noqa: E302
|
||||
revs = scm.list_all_commits()
|
||||
else:
|
||||
if all_branches:
|
||||
branches = scm.list_branches()
|
||||
revs.extend(scm.list_branches())
|
||||
|
||||
if all_tags:
|
||||
tags = scm.list_tags()
|
||||
revs.extend(scm.list_tags())
|
||||
|
||||
if branches is not None:
|
||||
revs.extend(branches)
|
||||
|
||||
if tags is not None:
|
||||
revs.extend(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