Skip to content

Commit

Permalink
add and fix checks for the enable_revmap config option
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Sep 3, 2010
1 parent a6f5f15 commit e12d18d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions github/github.py
Expand Up @@ -68,6 +68,8 @@ def upgrade_environment(self, db):

def _upgrade_db(self, db):
#open the revision map
if int(self.enable_revmap) == 0:
return 0
try:
revmap_fd = open(self.revmap, 'rb')
except IOError:
Expand Down Expand Up @@ -148,6 +150,11 @@ def get_link_resolvers(self):
return []

def _format_changeset_link(self, formatter, ns, match):
self.env.log.debug("format changeset link")
if int(self.enable_revmap) == 0:
self.env.log.debug("revmap disabled, skipping thingy")
return match.group(0)
self.env.log.debug("revmap enabled: formatting links")
commit_info = self._get_commit_data(match.group(0))
self.env.log.debug("long tooltips: %s", self.long_tooltips)
if commit_info:
Expand Down Expand Up @@ -197,6 +204,8 @@ def post_process_request(self, req, template, data, content_type):
return (template, data, content_type)

def _get_commit_data(self, commit_id):
if int(self.enable_revmap) == 0:
return False
cursor = self.env.get_db_cnx().cursor()
if commit_id.startswith('r'):
commit_id = commit_id[1:]
Expand Down
2 changes: 1 addition & 1 deletion github/hook.py
Expand Up @@ -105,7 +105,7 @@ def process(self, commit, status):
msg = "%s \n %s" % (msg, note)
author = commit['author']['name']
timestamp = datetime.now(utc)
if self.enable_revmap:
if int(self.enable_revmap):
cursor = self.env.get_db_cnx().cursor()
cursor.execute("INSERT INTO svn_revmap (svn_rev, git_hash, commit_msg) VALUES (0, %s, %s);",
(commit['id'], commit['message']))
Expand Down

0 comments on commit e12d18d

Please sign in to comment.