|
1 | 1 | # coding: utf-8
|
2 | 2 | #
|
3 |
| -# Copyright © 2012-2015 Ejwa Software. All rights reserved. |
| 3 | +# Copyright © 2012-2017 Ejwa Software. All rights reserved. |
4 | 4 | #
|
5 | 5 | # This file is part of gitinspector.
|
6 | 6 | #
|
@@ -123,40 +123,42 @@ def run(self):
|
123 | 123 | class Blame(object):
|
124 | 124 | def __init__(self, repo, hard, useweeks, changes):
|
125 | 125 | self.blames = {}
|
126 |
| - ls_tree_r = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1, |
127 |
| - stdout=subprocess.PIPE).stdout |
128 |
| - lines = ls_tree_r.readlines() |
129 |
| - ls_tree_r.close() |
130 |
| - |
131 |
| - progress_text = _(PROGRESS_TEXT) |
132 |
| - if repo != None: |
133 |
| - progress_text = "[%s] " % repo.name + progress_text |
134 |
| - |
135 |
| - for i, row in enumerate(lines): |
136 |
| - row = row.strip().decode("unicode_escape", "ignore") |
137 |
| - row = row.encode("latin-1", "replace") |
138 |
| - row = row.decode("utf-8", "replace").strip("\"").strip("'").strip() |
139 |
| - |
140 |
| - if FileDiff.get_extension(row) in extensions.get_located() and FileDiff.is_valid_extension(row) and not \ |
141 |
| - filtering.set_filtered(FileDiff.get_filename(row)): |
142 |
| - blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \ |
143 |
| - (["-C", "-C", "-M"] if hard else []) + |
144 |
| - [interval.get_since(), interval.get_ref(), "--", row]) |
145 |
| - thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), |
146 |
| - self.blames, row.strip()) |
147 |
| - thread.daemon = True |
148 |
| - thread.start() |
149 |
| - |
150 |
| - if format.is_interactive_format(): |
151 |
| - terminal.output_progress(progress_text, i, len(lines)) |
152 |
| - |
153 |
| - # Make sure all threads have completed. |
154 |
| - for i in range(0, NUM_THREADS): |
155 |
| - __thread_lock__.acquire() |
156 |
| - |
157 |
| - # We also have to release them for future use. |
158 |
| - for i in range(0, NUM_THREADS): |
159 |
| - __thread_lock__.release() |
| 126 | + ls_tree_p = subprocess.Popen(["git", "ls-tree", "--name-only", "-r", interval.get_ref()], bufsize=1, |
| 127 | + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 128 | + lines = ls_tree_p.communicate()[0].splitlines() |
| 129 | + ls_tree_p.stdout.close() |
| 130 | + |
| 131 | + if ls_tree_p.returncode == 0: |
| 132 | + progress_text = _(PROGRESS_TEXT) |
| 133 | + |
| 134 | + if repo != None: |
| 135 | + progress_text = "[%s] " % repo.name + progress_text |
| 136 | + |
| 137 | + for i, row in enumerate(lines): |
| 138 | + row = row.strip().decode("unicode_escape", "ignore") |
| 139 | + row = row.encode("latin-1", "replace") |
| 140 | + row = row.decode("utf-8", "replace").strip("\"").strip("'").strip() |
| 141 | + |
| 142 | + if FileDiff.get_extension(row) in extensions.get_located() and \ |
| 143 | + FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)): |
| 144 | + blame_command = filter(None, ["git", "blame", "--line-porcelain", "-w"] + \ |
| 145 | + (["-C", "-C", "-M"] if hard else []) + |
| 146 | + [interval.get_since(), interval.get_ref(), "--", row]) |
| 147 | + thread = BlameThread(useweeks, changes, blame_command, FileDiff.get_extension(row), |
| 148 | + self.blames, row.strip()) |
| 149 | + thread.daemon = True |
| 150 | + thread.start() |
| 151 | + |
| 152 | + if format.is_interactive_format(): |
| 153 | + terminal.output_progress(progress_text, i, len(lines)) |
| 154 | + |
| 155 | + # Make sure all threads have completed. |
| 156 | + for i in range(0, NUM_THREADS): |
| 157 | + __thread_lock__.acquire() |
| 158 | + |
| 159 | + # We also have to release them for future use. |
| 160 | + for i in range(0, NUM_THREADS): |
| 161 | + __thread_lock__.release() |
160 | 162 |
|
161 | 163 | def __iadd__(self, other):
|
162 | 164 | try:
|
|
0 commit comments