Skip to content

Commit

Permalink
Convert merge actions with 'M'
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhp committed Mar 26, 2014
1 parent 6b45c6d commit af146b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pycvsanaly2/DBContentHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def commit(self, commit):
if action.type == 'A':
# A file has been added
file_id = self.__action_add(path, prefix, log)
elif action.type.find('M') >= 0:
elif action.type == 'M':
# A file has been modified
file_id = self.__get_file_for_path(path, log.id)[0]
elif action.type == 'D':
Expand Down
4 changes: 2 additions & 2 deletions pycvsanaly2/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def create_tables(self, cursor):
")")
cursor.execute("CREATE TABLE actions (" +
"id integer primary key," +
"type varchar(2)," +
"type varchar(1)," +
"file_id integer," +
"commit_id integer," +
"branch_id integer" +
Expand Down Expand Up @@ -556,7 +556,7 @@ def create_tables(self, cursor):
" CHARACTER SET=utf8")
cursor.execute("CREATE TABLE actions (" +
"id INT," +
"type varchar(2)," +
"type varchar(1)," +
"file_id integer," +
"commit_id integer," +
"branch_id integer," +
Expand Down
11 changes: 10 additions & 1 deletion pycvsanaly2/GitParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,16 @@ def _parse_line(self, line):
match = self.patterns['file'].match(line)
if match:
action = Action()
action.type = match.group(1)
type = match.group(1)
if len(type) > 1:
# merge actions
if 'M' in type:
type = 'M'
else:
# ignore merge actions without 'M'
return

action.type = type
action.f1 = match.group(2)

self.commit.actions.append(action)
Expand Down
9 changes: 2 additions & 7 deletions pycvsanaly2/extensions/Content.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,8 @@ def _get_file_contents(self):
# utf-8, ie. it's not already unicode, or latin-1, or something
# obvious. This almost always means that the file isn't source
# code at all.
# TODO: I should really throw a "not source" exception,
# but just doing None is fine for now.
try:
return to_utf8(self._file_contents).encode("utf-8")
except:
return None

return to_utf8(self._file_contents)

def _set_file_contents(self, contents):
self._file_contents = contents

Expand Down

0 comments on commit af146b5

Please sign in to comment.