aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2015-01-08 18:39:29 +0000
committerAdam Spiers <git@adamspiers.org>2015-01-08 18:39:29 +0000
commit2a7415a34c3d4b09d311b5548ab0b709ee7e4688 (patch)
treeb589bcea469d6d743b6c6e332fe49c08f6d89afd
parent72eea4009b58bf6d989e969d9fe54007bab5f169 (diff)
downloadgit-deps-2a7415a34c3d4b09d311b5548ab0b709ee7e4688.tar.gz
rename sha to sha1 everywhere
More accurate, and also improves accuracy of any future search/replace.
-rwxr-xr-xgit-deps96
-rw-r--r--html/js/git-deps-graph.js36
2 files changed, 66 insertions, 66 deletions
diff --git a/git-deps b/git-deps
index d66c6ab..0766edc 100755
--- a/git-deps
+++ b/git-deps
@@ -95,17 +95,17 @@ class CLIDependencyListener(DependencyListener):
"""
def new_dependency(self, dependent, dependency, path, line_num):
- dependent_sha = dependent.hex
- dependency_sha = dependency.hex
+ dependent_sha1 = dependent.hex
+ dependency_sha1 = dependency.hex
if self.options.recurse:
if self.options.log:
- print("%s depends on:" % dependent_sha)
+ print("%s depends on:" % dependent_sha1)
else:
- print("%s %s" % (dependent_sha, dependency_sha))
+ print("%s %s" % (dependent_sha1, dependency_sha1))
else:
if not self.options.log:
- print(dependency_sha)
+ print(dependency_sha1)
if self.options.log:
cmd = [
@@ -113,10 +113,10 @@ class CLIDependencyListener(DependencyListener):
'--no-pager',
'-c', 'color.ui=always',
'log', '-n1',
- dependency_sha
+ dependency_sha1
]
print(subprocess.check_output(cmd))
- # dependency = detector.get_commit(dependency_sha)
+ # dependency = detector.get_commit(dependency_sha1)
# print(dependency.message + "\n")
# for path in self.dependencies[dependency]:
@@ -145,18 +145,18 @@ class JSONDependencyListener(DependencyListener):
'dependencies': [],
}
- def abbreviate_sha(self, sha):
+ def abbreviate_sha1(self, sha1):
"""Uniquely abbreviates the given SHA1."""
# For now we invoke git-rev-parse(1), but hopefully eventually
# we will be able to do this via pygit2.
- cmd = ['git', 'rev-parse', '--short', sha]
+ cmd = ['git', 'rev-parse', '--short', sha1]
# self.logger.debug(" ".join(cmd))
out = subprocess.check_output(cmd).strip()
# self.logger.debug(out)
return out
- def describe(self, sha):
+ def describe(self, sha1):
"""Returns a human-readable representation of the given SHA1."""
# For now we invoke git-describe(1), but eventually we will be
@@ -170,7 +170,7 @@ class JSONDependencyListener(DependencyListener):
'--long', # remotes/github/master-0-g2b6d591
#'--contains',
#'--abbrev',
- sha
+ sha1
]
# self.logger.debug(" ".join(cmd))
out = None
@@ -183,7 +183,7 @@ class JSONDependencyListener(DependencyListener):
out = out.strip()
out = re.sub(r'^(heads|remotes)/', '', out)
- # We already have the abbreviated SHA from abbreviate_sha()
+ # We already have the abbreviated SHA1 from abbreviate_sha1()
out = re.sub(r'-g[0-9a-f]{7,}$', '', out)
# self.logger.debug(out)
return out
@@ -192,15 +192,15 @@ class JSONDependencyListener(DependencyListener):
"""Adds the commit to the commits array if it doesn't already exist,
and returns the commit's index in the array.
"""
- sha = commit.hex
- abbrev = self.abbreviate_sha(sha)
- if sha in self._commits:
- return self._commits[sha]
+ sha1 = commit.hex
+ abbrev = self.abbreviate_sha1(sha1)
+ if sha1 in self._commits:
+ return self._commits[sha1]
title, separator, body = commit.message.partition("\n")
commit = {
'name': abbrev,
- 'sha': sha,
- 'describe': self.describe(sha),
+ 'sha1': sha1,
+ 'describe': self.describe(sha1),
'author_name': commit.author.name,
'author_mail': commit.author.email,
'author_time': commit.author.time,
@@ -215,8 +215,8 @@ class JSONDependencyListener(DependencyListener):
'body': body.lstrip("\n"),
}
self._json['commits'].append(commit)
- self._commits[sha] = len(self._json['commits']) - 1
- return self._commits[sha]
+ self._commits[sha1] = len(self._json['commits']) - 1
+ return self._commits[sha1]
def add_link(self, source, target):
self._json['dependencies'].append
@@ -283,7 +283,7 @@ class DependencyDetector(object):
self.done = []
self.done_d = {}
- # A cache mapping SHAs to commit objects
+ # A cache mapping SHA1s to commit objects
self.commits = {}
# Memoization for branch_contains()
@@ -344,8 +344,8 @@ class DependencyDetector(object):
self.todo_d[dependent.hex] = True
while self.todo:
- shas = [commit.hex[:8] for commit in self.todo]
- self.logger.debug("TODO list: %s" % " ".join(shas))
+ sha1s = [commit.hex[:8] for commit in self.todo]
+ self.logger.debug("TODO list: %s" % " ".join(sha1s))
dependent = self.todo.pop(0)
del self.todo_d[dependent.hex]
self.logger.debug("Processing %s from TODO list" %
@@ -404,11 +404,11 @@ class DependencyDetector(object):
]
blame = subprocess.check_output(cmd)
- dependent_sha = dependent.hex
- if dependent_sha not in self.dependencies:
+ dependent_sha1 = dependent.hex
+ if dependent_sha1 not in self.dependencies:
self.logger.debug(' New dependent: %s (%s)' %
- (dependent_sha[:8], self.oneline(dependent)))
- self.dependencies[dependent_sha] = {}
+ (dependent_sha1[:8], self.oneline(dependent)))
+ self.dependencies[dependent_sha1] = {}
self.notify_listeners('new_dependent', dependent)
line_to_culprit = {}
@@ -418,44 +418,44 @@ class DependencyDetector(object):
m = re.match('^([0-9a-f]{40}) (\d+) (\d+)( \d+)?$', line)
if not m:
continue
- dependency_sha, orig_line_num, line_num = m.group(1, 2, 3)
+ dependency_sha1, orig_line_num, line_num = m.group(1, 2, 3)
line_num = int(line_num)
- dependency = self.get_commit(dependency_sha)
+ dependency = self.get_commit(dependency_sha1)
line_to_culprit[line_num] = dependency.hex
if self.is_excluded(dependency):
self.logger.debug(
' Excluding dependency %s from line %s (%s)' %
- (dependency_sha[:8], line_num,
+ (dependency_sha1[:8], line_num,
self.oneline(dependency)))
continue
- if dependency_sha not in self.dependencies[dependent_sha]:
- if dependency_sha in self.todo_d:
+ if dependency_sha1 not in self.dependencies[dependent_sha1]:
+ if dependency_sha1 in self.todo_d:
self.logger.debug(
' Dependency %s via line %s already in TODO' %
- (dependency_sha[:8], line_num,))
+ (dependency_sha1[:8], line_num,))
continue
- if dependency_sha in self.done_d:
+ if dependency_sha1 in self.done_d:
self.logger.debug(
' Dependency %s via line %s already done' %
- (dependency_sha[:8], line_num,))
+ (dependency_sha1[:8], line_num,))
continue
self.logger.debug(
' New dependency %s via line %s (%s)' %
- (dependency_sha[:8], line_num, self.oneline(dependency)))
- self.dependencies[dependent_sha][dependency_sha] = {}
+ (dependency_sha1[:8], line_num, self.oneline(dependency)))
+ self.dependencies[dependent_sha1][dependency_sha1] = {}
self.notify_listeners('new_dependency',
dependent, dependency, path, line_num)
- if dependency_sha not in self.dependencies:
+ if dependency_sha1 not in self.dependencies:
if self.options.recurse:
self.todo.append(dependency)
self.todo_d[dependency.hex] = True
self.logger.debug(' added to TODO')
- dep_sources = self.dependencies[dependent_sha][dependency_sha]
+ dep_sources = self.dependencies[dependent_sha1][dependency_sha1]
if path not in dep_sources:
dep_sources[path] = {}
@@ -494,26 +494,26 @@ class DependencyDetector(object):
return False
def branch_contains(self, commit, branch):
- sha = commit.hex[:8]
+ sha1 = commit.hex[:8]
self.logger.debug(" Does %s contain %s?" %
- (branch, sha))
+ (branch, sha1))
branch_commit = self.get_commit(branch)
- branch_sha = branch_commit.hex
+ branch_sha1 = branch_commit.hex
if commit.hex not in self.branch_contains_cache:
- self.branch_contains_cache[sha] = {}
- if branch_sha in self.branch_contains_cache[sha]:
- memoized = self.branch_contains_cache[sha][branch_sha]
+ self.branch_contains_cache[sha1] = {}
+ if branch_sha1 in self.branch_contains_cache[sha1]:
+ memoized = self.branch_contains_cache[sha1][branch_sha1]
self.logger.debug(" %s (memoized)" % memoized)
return memoized
- cmd = ['git', 'merge-base', sha, branch_sha]
+ cmd = ['git', 'merge-base', sha1, branch_sha1]
# self.logger.debug(" ".join(cmd))
out = subprocess.check_output(cmd).strip()
# self.logger.debug(out)
- result = out == sha
+ result = out == sha1
self.logger.debug(" %s" % result)
- self.branch_contains_cache[sha][branch_sha] = result
+ self.branch_contains_cache[sha1][branch_sha1] = result
return result
def tree_lookup(self, target_path, commit):
diff --git a/html/js/git-deps-graph.js b/html/js/git-deps-graph.js
index fa8fe82..02f64db 100644
--- a/html/js/git-deps-graph.js
+++ b/html/js/git-deps-graph.js
@@ -75,18 +75,18 @@ function redraw_on_zoom() {
// Returns 1 iff a link was added, otherwise 0.
function add_node(commit) {
- if (commit.sha in node_index) {
+ if (commit.sha1 in node_index) {
return 0;
}
nodes.push(commit);
- node_index[commit.sha] = nodes.length - 1;
+ node_index[commit.sha1] = nodes.length - 1;
return 1;
}
// Returns 1 iff a link was added, otherwise 0.
-function add_link(parent_sha, child_sha) {
- var pi = node_index[parent_sha];
- var ci = node_index[child_sha];
+function add_link(parent_sha1, child_sha1) {
+ var pi = node_index[parent_sha1];
+ var ci = node_index[child_sha1];
var link = {
source: pi,
@@ -94,37 +94,37 @@ function add_link(parent_sha, child_sha) {
value: 1 // no idea what WebCola needs this for
};
- if (! (parent_sha in deps)) {
- deps[parent_sha] = {};
+ if (! (parent_sha1 in deps)) {
+ deps[parent_sha1] = {};
}
- if (child_sha in deps[parent_sha]) {
+ if (child_sha1 in deps[parent_sha1]) {
// We've already got this link, presumably
// from a previous XHR.
return 0;
}
- deps[parent_sha][child_sha] = true;
+ deps[parent_sha1][child_sha1] = true;
links.push(link);
return 1;
}
function build_constraints() {
constraints = []; // FIXME: only rebuild constraints which changed
- for (var parent_sha in deps) {
- constraints.push(build_constraint(parent_sha));
+ for (var parent_sha1 in deps) {
+ constraints.push(build_constraint(parent_sha1));
}
}
-function build_constraint(parent_sha) {
+function build_constraint(parent_sha1) {
constraint = {
axis: 'x',
type: 'alignment',
offsets: [],
- parent: parent_sha
+ parent: parent_sha1
};
- for (var child_sha in deps[parent_sha]) {
+ for (var child_sha1 in deps[parent_sha1]) {
constraint.offsets.push({
- node: node_index[child_sha],
+ node: node_index[child_sha1],
offset: 0
});
}
@@ -227,7 +227,7 @@ function draw_graph(commitish) {
node = fg.selectAll(".node")
.data(nodes, function (d) {
- return d.sha;
+ return d.sha1;
})
.enter().append("g")
.attr("class", "node")
@@ -326,10 +326,10 @@ function tip_html(d) {
var pre = fragment.find(".commit-body pre").text(d.body);
if (options.debug) {
- var index = node_index[d.sha];
+ var index = node_index[d.sha1];
var debug = "node index: " + index;
$.each(constraints, function (i, constraint) {
- if (constraint.parent == d.sha) {
+ if (constraint.parent == d.sha1) {
var siblings = $.map(constraint.offsets,
function (offset, i) {
return offset.node;