diff --git a/dvc/graph/commit.py b/dvc/graph/commit.py index 6cce7dd03..dab354ce5 100644 --- a/dvc/graph/commit.py +++ b/dvc/graph/commit.py @@ -39,16 +39,18 @@ class Commit(object): if self._branch_tips: branch_text = 'Branch tips: {}\n'.format(', '.join(self._branch_tips)) - metric_text = '' - if self._is_target and self._target_metric: - metric_text = '\nTarget metric: {}'.format(self._target_metric) - if self._target_metric_delta is not None: - metric_text += ' ({:+f})'.format(self._target_metric_delta) - if self._is_collapsed: - return branch_text + self.COLLAPSED_TEXT + metric_text + return branch_text + self.COLLAPSED_TEXT + self._text_metrics_line() - return branch_text + self._comment[:self.TEXT_LIMIT] + metric_text + '\n' + self.hash + return branch_text + self._comment[:self.TEXT_LIMIT] + self._text_metrics_line() + '\n' + self.hash + + def _text_metrics_line(self): + result = '' + if self._is_target and self._target_metric: + result = '\nTarget metric: {}'.format(self._target_metric) + if self._target_metric_delta is not None: + result += ' ({:+f})'.format(self._target_metric_delta) + return result @property def is_repro(self): diff --git a/dvc/graph/workflow.py b/dvc/graph/workflow.py index 4c72fdd67..f88c1a0d3 100644 --- a/dvc/graph/workflow.py +++ b/dvc/graph/workflow.py @@ -31,10 +31,8 @@ class Workflow(object): if p not in self._edges: self._edges[p] = set() self._edges[p].add(commit.hash) - - if commit.hash not in self._back_edges: - self._back_edges[commit.hash] = set() - for p in commit.parent_hashes: + if commit.hash not in self._back_edges: + self._back_edges[commit.hash] = set() self._back_edges[commit.hash].add(p) if not commit.parent_hashes: