Skip to content

Commit

Permalink
Add skip_work option
Browse files Browse the repository at this point in the history
  • Loading branch information
hezyin committed Aug 3, 2017
1 parent 25cbbf3 commit 7f2491b
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions graphs/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def process(self, rev=None,
max_branch_length=100,
min_branch_date=None,
checkpoint_interval=100,
skip_work=False,
verbose=True):
"""
This function supports four ways of specifying the
Expand Down Expand Up @@ -183,15 +184,6 @@ def process(self, rev=None,
repo_name = os.path.basename(self.repo_path.rstrip('/'))
self.save(repo_name + '-1st-' + str(counter) + '.pickle')

# generate diff_index by diff commit with its first parent
diff_index = _diff_with_first_parent(commit)

# figure out the change type of each entry in diff_index
_fill_change_type(diff_index)

if verbose:
_print_diff_index(diff_index)

if into_branches:
is_merge_commit = len(commit.parents) > 1
if is_merge_commit:
Expand All @@ -203,22 +195,32 @@ def process(self, rev=None,
else:
is_merge_commit = False

for diff in diff_index:
if diff.change_type == 'U':
print('Unknown change type encountered.')
continue
if not skip_work:
# generate diff_index by diff commit with its first parent
diff_index = _diff_with_first_parent(commit)

if diff.change_type == 'A':
self.on_add(diff, commit, is_merge_commit)
# figure out the change type of each entry in diff_index
_fill_change_type(diff_index)

elif diff.change_type == 'D':
self.on_delete(diff, commit, is_merge_commit)
if verbose:
_print_diff_index(diff_index)

elif diff.change_type == 'R':
self.on_rename(diff, commit, is_merge_commit)
for diff in diff_index:
if diff.change_type == 'U':
print('Unknown change type encountered.')
continue

else:
self.on_modify(diff, commit, is_merge_commit)
if diff.change_type == 'A':
self.on_add(diff, commit, is_merge_commit)

elif diff.change_type == 'D':
self.on_delete(diff, commit, is_merge_commit)

elif diff.change_type == 'R':
self.on_rename(diff, commit, is_merge_commit)

else:
self.on_modify(diff, commit, is_merge_commit)

counter += 1

Expand Down Expand Up @@ -293,21 +295,22 @@ def process(self, rev=None,
if len(cur_commit.parents) == 2:
self.merge_commits.append(cur_commit)

self._start_process_commit(cur_commit)
diff_index = _diff_with_first_parent(cur_commit)
_fill_change_type(diff_index)
for diff in diff_index:
if diff.change_type == 'U':
print('Unknown change type encountered.')
continue
if diff.change_type == 'A':
self.on_add2(diff, cur_commit)
elif diff.change_type == 'D':
self.on_delete2(diff, cur_commit)
elif diff.change_type == 'R':
self.on_rename2(diff, cur_commit)
else:
self.on_modify2(diff, cur_commit)
if not skip_work:
self._start_process_commit(cur_commit)
diff_index = _diff_with_first_parent(cur_commit)
_fill_change_type(diff_index)
for diff in diff_index:
if diff.change_type == 'U':
print('Unknown change type encountered.')
continue
if diff.change_type == 'A':
self.on_add2(diff, cur_commit)
elif diff.change_type == 'D':
self.on_delete2(diff, cur_commit)
elif diff.change_type == 'R':
self.on_rename2(diff, cur_commit)
else:
self.on_modify2(diff, cur_commit)

# get next commit
prev_commit = cur_commit.parents[0]
Expand Down

0 comments on commit 7f2491b

Please sign in to comment.