From 7835c7b3aff6c9662e39e1c4b0854725c59e8fef Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sat, 16 Nov 2013 21:58:30 -0500 Subject: add some docstrings --- git-deps | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/git-deps b/git-deps index 1093049..df1766a 100755 --- a/git-deps +++ b/git-deps @@ -202,6 +202,9 @@ class DependencyDetector(object): return self.commits[rev] def find_dependencies(self, dependent_rev, recurse=None): + """Find all dependencies of the given revision, recursively traversing + the dependency tree if requested. + """ if recurse is None: recurse = self.options.recurse @@ -226,6 +229,10 @@ class DependencyDetector(object): self.notify_listeners('dependent_done', dependent, dependencies) def find_dependencies_with_parent(self, dependent, parent): + """Find all dependencies of the given revision caused by the given + parent commit. This will be called multiple times for merge + commits which have multiple parents. + """ self.logger.debug(" Finding dependencies of %s via parent %s" % (dependent.hex[:8], parent.hex[:8])) diff = self.repo.diff(parent, dependent, context_lines=self.options.context_lines) @@ -236,6 +243,12 @@ class DependencyDetector(object): self.blame_hunk(dependent, parent, path, hunk) def blame_hunk(self, dependent, parent, path, hunk): + """Run git blame on the parts of the hunk which exist in the older + commit in the diff. The commits generated by git blame are + the commits which the newer commit in the diff depends on, + because without the lines from those commits, the hunk would + not apply correctly. + """ first_line_num = hunk.old_start line_range_before = "-%d,%d" % (hunk.old_start, hunk.old_lines) line_range_after = "+%d,%d" % (hunk.new_start, hunk.new_lines) -- cgit