-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplemented comment propagation code to make it more robust and more capable of dealing with non-trivial situations. Known issues fixed or improved by this is: * Comments against lines in files modified by a later merge or rebase in the review were not propagate forward properly to commits after the merge or rebase. Issues raised in such circumstances would never be marked as addressed by later commits. * Crash when attempting to comment lines in a version of a file that was introduced into the review by a merge commit or rebase but where the file is not included in the (equivalent) merge commit's diff because there were no (suspected) conflicts in the file. * Reopening an issue against lines that are themselves modified by a later commit. In that case, the issue is now left as "addressed" only with a new commit as the "addressed by" commit. It's possible to reopen the issue again from there, eventually reaching either an open issue or an issue that is marked as addressed by the commit that actually addressed it. * Support for writing comments via /showfile even if the file in question has been changed in the review. This was previously not supported simply because the old comment propagation code was slightly difficult to reuse. Notable changes: * Introduced a new utility class Propagation used whenever comments are propagated between file versions (when initially created, when new commits are added to the review and when reopening an issue.) * Dropped the column 'commit' from the table commentchainlines. It was confusing since it was not included in the primary key of the table, and the columns that make up the primary key could have identical values for several different commits. The value in the 'commit' column was thus just a commit (the first) where the comment existed against the specified lines. It wasn't used a lot, and where it was, it was either wrong or inaccurate. * Added columns 'from_addressed_by' and 'to_addressed_by' to the table commentchainchanges to properly record the changes to the column 'addressed_by' in the table 'commentchains' when reopening an issue that ends up being addressed again by a different commit. Previously, when reopening an issue, the 'addressed_by' column was always set to NULL so changes to it needn't be recorded explicitly.
- Loading branch information
Showing
19 changed files
with
913 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
installation/migrations/dbschema.altertable.commentchainchanges.addressed_by.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- mode: python; encoding: utf-8 -*- | ||
# | ||
# Copyright 2012 Jens Lindström, Opera Software ASA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
import sys | ||
import psycopg2 | ||
import json | ||
import argparse | ||
import os | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--uid", type=int) | ||
parser.add_argument("--gid", type=int) | ||
|
||
arguments = parser.parse_args() | ||
|
||
os.setgid(arguments.gid) | ||
os.setuid(arguments.uid) | ||
|
||
data = json.load(sys.stdin) | ||
|
||
db = psycopg2.connect(database="critic") | ||
cursor = db.cursor() | ||
|
||
try: | ||
# Make sure the columns don't already exist. | ||
cursor.execute("SELECT from_addressed_by, to_addressed_by FROM commentchainchanges") | ||
|
||
# Above statement should have thrown a psycopg2.ProgrammingError, but it | ||
# didn't, so just exit. | ||
sys.exit(0) | ||
except psycopg2.ProgrammingError: | ||
db.rollback() | ||
except: | ||
raise | ||
|
||
cursor.execute("""ALTER TABLE commentchainchanges | ||
ADD from_addressed_by INTEGER REFERENCES commits, | ||
ADD to_addressed_by INTEGER REFERENCES commits""") | ||
|
||
db.commit() | ||
db.close() |
47 changes: 47 additions & 0 deletions
47
installation/migrations/dbschema.altertable.commentchainlines.drop.commit.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- mode: python; encoding: utf-8 -*- | ||
# | ||
# Copyright 2012 Jens Lindström, Opera Software ASA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
import sys | ||
import psycopg2 | ||
import json | ||
import argparse | ||
import os | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--uid", type=int) | ||
parser.add_argument("--gid", type=int) | ||
|
||
arguments = parser.parse_args() | ||
|
||
os.setgid(arguments.gid) | ||
os.setuid(arguments.uid) | ||
|
||
data = json.load(sys.stdin) | ||
|
||
db = psycopg2.connect(database="critic") | ||
cursor = db.cursor() | ||
|
||
try: | ||
# Check if the 'commit' column already doesn't exist. | ||
cursor.execute("SELECT commit FROM commentchainlines") | ||
except psycopg2.ProgrammingError: | ||
# Seems it doesn't, so just exit. | ||
sys.exit(0) | ||
|
||
cursor.execute("""ALTER TABLE commentchainlines DROP commit""") | ||
|
||
db.commit() | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.