Skip to content

Commit

Permalink
deprecate the use of FilePath.update_all, simplify the invocation of …
Browse files Browse the repository at this point in the history
…get_path
  • Loading branch information
Zhongpeng Lin committed Dec 1, 2010
1 parent d09c28c commit 5a3a0ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 10 additions & 3 deletions pycvsanaly2/extensions/FilePaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def __init__ (self):
def __init__ (self, db):
self.__dict__ = self.__shared_state
self.__dict__['db'] = db

def update_for_revision (self, cursor, commit_id, repo_id):
db = self.__dict__['db']

#TODO check all places using this method to remove this if statement
if commit_id == self.__dict__['rev']:
return

Expand Down Expand Up @@ -144,10 +145,15 @@ def __build_path (self, file_id, adj):

def get_path (self, file_id, commit_id, repo_id):
profiler_start ("Getting path for file %d at commit %d", (file_id, commit_id))
#Test here if avoid unnecessary database connection
if commit_id != self.__dict__['rev']:
cnn = self.__dict__['db'].connect()
cursor = cnn.cursor()
self.update_for_revision(cursor, commit_id, repo_id)
cursor.close()
self.__dict__['rev'] = commit_id

adj = self.__dict__['adj']
assert adj is not None, "Matrix no updated"

path = self.__build_path (file_id, adj)

profiler_stop ("Getting path for file %d at commit %d", (file_id, commit_id), True)
Expand All @@ -166,6 +172,7 @@ def get_commit_id (self):
return self.__dict__['rev']

def update_all(self, repo_id):
print("Deprecation warning: FilePath.update_all has discovered defects!")
db = self.__dict__['db']
cnn = db.connect ()

Expand Down
3 changes: 1 addition & 2 deletions pycvsanaly2/extensions/HunkBlame.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class HunkBlame(Blame):
'''
classdocs
'''
deps = ['Hunks']
# deps = ['Hunks']

MAX_BLAMES = 1

Expand Down Expand Up @@ -217,7 +217,6 @@ def run (self, repo, uri, db):
hunk = read_cursor.fetchone()
n_blames = 0
fp = FilePaths(db)
fp.update_all(repoid)

while hunk is not None:
hunk_id, file_id, commit_id, start_line, end_line, rev = hunk
Expand Down

0 comments on commit 5a3a0ed

Please sign in to comment.