Remove TrackingIds table from SQL database
This table is not necessary with the secondary index enabled. Change-Id: I87820c638cf69e688f9aa95edf190a8c56138a0b
This commit is contained in:
@@ -2868,10 +2868,7 @@ tracking systems, parsed out of the commit message and
|
|||||||
saved in Gerrit's database.
|
saved in Gerrit's database.
|
||||||
|
|
||||||
After making changes to this section, existing changes
|
After making changes to this section, existing changes
|
||||||
must be reindexed with link:pgm-reindex.html[reindex]
|
must be reindexed with link:pgm-reindex.html[reindex].
|
||||||
if index.type is `LUCENE` or `SOLR`; or with
|
|
||||||
link:pgm-ScanTrackingIds.html[ScanTrackingIds] if index.type
|
|
||||||
is unset or `SQL`.
|
|
||||||
|
|
||||||
The tracking ids are searchable using tr:<tracking id> or
|
The tracking ids are searchable using tr:<tracking id> or
|
||||||
bug:<tracking id>.
|
bug:<tracking id>.
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
ScanTrackingIds
|
|
||||||
===============
|
|
||||||
|
|
||||||
NAME
|
|
||||||
----
|
|
||||||
ScanTrackingIds - Rescan changes to index trackingids
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
--------
|
|
||||||
--
|
|
||||||
'java' -jar gerrit.war 'ScanTrackingIds' -d <SITE_PATH>
|
|
||||||
--
|
|
||||||
|
|
||||||
DESCRIPTION
|
|
||||||
-----------
|
|
||||||
Scans every known change and updates the indexed tracking
|
|
||||||
ids associated with the change, after editing the trackingid
|
|
||||||
configuration in gerrit.config.
|
|
||||||
|
|
||||||
This task can take quite some time, but can run in the background
|
|
||||||
concurrently to the server if the database is MySQL or PostgreSQL.
|
|
||||||
If the database is H2, this task must be run by itself.
|
|
||||||
|
|
||||||
STATUS
|
|
||||||
------
|
|
||||||
This command will be replaced by `reindex`.
|
|
||||||
|
|
||||||
If secondary indexing is enabled
|
|
||||||
(link:config-gerrit.html#index.type[index.type] set to `LUCENE`
|
|
||||||
or `SOLR`) use link:pgm-reindex.html[reindex].
|
|
||||||
|
|
||||||
OPTIONS
|
|
||||||
-------
|
|
||||||
|
|
||||||
-d::
|
|
||||||
\--site-path::
|
|
||||||
Location of the gerrit.config file, and all other per-site
|
|
||||||
configuration data, supporting libraries and log files.
|
|
||||||
|
|
||||||
\--threads::
|
|
||||||
Number of threads to perform the scan work with. Defaults to
|
|
||||||
twice the number of CPUs available.
|
|
||||||
|
|
||||||
CONTEXT
|
|
||||||
-------
|
|
||||||
This command can only be run on a server which has direct
|
|
||||||
connectivity to the metadata database, and local access to the
|
|
||||||
managed Git repositories.
|
|
||||||
|
|
||||||
EXAMPLES
|
|
||||||
--------
|
|
||||||
To rescan all known trackingids:
|
|
||||||
|
|
||||||
====
|
|
||||||
$ java -jar gerrit.war ScanTrackingIds -d site_path --threads 16
|
|
||||||
====
|
|
||||||
|
|
||||||
GERRIT
|
|
||||||
------
|
|
||||||
Part of link:index.html[Gerrit Code Review]
|
|
||||||
|
|
||||||
SEARCHBOX
|
|
||||||
---------
|
|
@@ -35,9 +35,6 @@ version::
|
|||||||
Transition Utilities
|
Transition Utilities
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
link:pgm-ScanTrackingIds.html[ScanTrackingIds]::
|
|
||||||
Rescan all changes after configuring trackingids.
|
|
||||||
|
|
||||||
link:pgm-LocalUsernamesToLowerCase.html[LocalUsernamesToLowerCase]::
|
link:pgm-LocalUsernamesToLowerCase.html[LocalUsernamesToLowerCase]::
|
||||||
Convert the local username of every account to lower case.
|
Convert the local username of every account to lower case.
|
||||||
|
|
||||||
|
@@ -1,177 +0,0 @@
|
|||||||
// Copyright (C) 2010 The Android Open Source Project
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
package com.google.gerrit.pgm;
|
|
||||||
|
|
||||||
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
|
|
||||||
|
|
||||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
|
||||||
import com.google.gerrit.pgm.util.SiteProgram;
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
|
||||||
import com.google.gerrit.server.schema.SchemaVersionCheck;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.gwtorm.server.SchemaFactory;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
|
||||||
import org.eclipse.jgit.lib.TextProgressMonitor;
|
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
|
||||||
import org.kohsuke.args4j.Option;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/** Scan changes and update the trackingid information for them. */
|
|
||||||
public class ScanTrackingIds extends SiteProgram {
|
|
||||||
@Option(name = "--threads", usage = "Number of concurrent threads to run")
|
|
||||||
private int threads = 2 * Runtime.getRuntime().availableProcessors();
|
|
||||||
|
|
||||||
private final LifecycleManager manager = new LifecycleManager();
|
|
||||||
private final TextProgressMonitor monitor = new TextProgressMonitor();
|
|
||||||
private List<Change> todo;
|
|
||||||
|
|
||||||
private Injector dbInjector;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private TrackingFooters footers;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private GitRepositoryManager gitManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private SchemaFactory<ReviewDb> database;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int run() throws Exception {
|
|
||||||
if (threads <= 0) {
|
|
||||||
threads = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbInjector = createDbInjector(MULTI_USER);
|
|
||||||
manager.add(
|
|
||||||
dbInjector,
|
|
||||||
dbInjector.createChildInjector(SchemaVersionCheck.module()));
|
|
||||||
manager.start();
|
|
||||||
dbInjector.injectMembers(this);
|
|
||||||
|
|
||||||
final ReviewDb db = database.open();
|
|
||||||
try {
|
|
||||||
todo = db.changes().all().toList();
|
|
||||||
synchronized (monitor) {
|
|
||||||
monitor.beginTask("Scanning changes", todo.size());
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<Worker> workers = new ArrayList<Worker>(threads);
|
|
||||||
for (int tid = 0; tid < threads; tid++) {
|
|
||||||
Worker t = new Worker();
|
|
||||||
t.start();
|
|
||||||
workers.add(t);
|
|
||||||
}
|
|
||||||
for (Worker t : workers) {
|
|
||||||
t.join();
|
|
||||||
}
|
|
||||||
synchronized (monitor) {
|
|
||||||
monitor.endTask();
|
|
||||||
}
|
|
||||||
manager.stop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scan(ReviewDb db, Change change) {
|
|
||||||
final Project.NameKey project = change.getDest().getParentKey();
|
|
||||||
final Repository git;
|
|
||||||
try {
|
|
||||||
git = gitManager.openRepository(project);
|
|
||||||
} catch (IOException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
PatchSet ps = db.patchSets().get(change.currentPatchSetId());
|
|
||||||
if (ps == null || ps.getRevision() == null
|
|
||||||
|| ps.getRevision().get() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ChangeUtil.updateTrackingIds(db, change, footers, parse(git, ps)
|
|
||||||
.getFooterLines());
|
|
||||||
} catch (OrmException error) {
|
|
||||||
System.err.println("ERR " + error.getMessage());
|
|
||||||
} catch (IOException error) {
|
|
||||||
System.err.println("ERR Cannot scan " + change.getId() + ": "
|
|
||||||
+ error.getMessage());
|
|
||||||
} finally {
|
|
||||||
git.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private RevCommit parse(final Repository git, PatchSet ps)
|
|
||||||
throws MissingObjectException, IncorrectObjectTypeException, IOException {
|
|
||||||
RevWalk rw = new RevWalk(git);
|
|
||||||
try {
|
|
||||||
return rw.parseCommit(ObjectId.fromString(ps.getRevision().get()));
|
|
||||||
} finally {
|
|
||||||
rw.release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Change next() {
|
|
||||||
synchronized (todo) {
|
|
||||||
if (todo.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return todo.remove(todo.size() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Worker extends Thread {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
ReviewDb db;
|
|
||||||
try {
|
|
||||||
db = database.open();
|
|
||||||
} catch (OrmException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
for (;;) {
|
|
||||||
Change change = next();
|
|
||||||
if (change == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
scan(db, change);
|
|
||||||
synchronized (monitor) {
|
|
||||||
monitor.update(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -98,9 +98,6 @@ public interface ReviewDb extends Schema {
|
|||||||
@Relation(id = 26)
|
@Relation(id = 26)
|
||||||
PatchLineCommentAccess patchComments();
|
PatchLineCommentAccess patchComments();
|
||||||
|
|
||||||
@Relation(id = 27)
|
|
||||||
TrackingIdAccess trackingIds();
|
|
||||||
|
|
||||||
@Relation(id = 28)
|
@Relation(id = 28)
|
||||||
SubmoduleSubscriptionAccess submoduleSubscriptions();
|
SubmoduleSubscriptionAccess submoduleSubscriptions();
|
||||||
|
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
// Copyright (C) 2010 The Android Open Source Project
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
package com.google.gerrit.reviewdb.server;
|
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
|
||||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
|
||||||
import com.google.gwtorm.server.Access;
|
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.gwtorm.server.PrimaryKey;
|
|
||||||
import com.google.gwtorm.server.Query;
|
|
||||||
import com.google.gwtorm.server.ResultSet;
|
|
||||||
|
|
||||||
public interface TrackingIdAccess extends Access<TrackingId, TrackingId.Key> {
|
|
||||||
@PrimaryKey("key")
|
|
||||||
TrackingId get(TrackingId.Key key) throws OrmException;
|
|
||||||
|
|
||||||
@Query("WHERE key.changeId = ?")
|
|
||||||
ResultSet<TrackingId> byChange(Change.Id change) throws OrmException;
|
|
||||||
}
|
|
@@ -108,18 +108,6 @@ CREATE INDEX patch_set_ancestors_desc
|
|||||||
ON patch_set_ancestors (ancestor_revision);
|
ON patch_set_ancestors (ancestor_revision);
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
|
||||||
-- ProjectAccess
|
|
||||||
-- @PrimaryKey covers: all, suggestByName
|
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
|
||||||
-- TrackingIdAccess
|
|
||||||
--
|
|
||||||
CREATE INDEX tracking_ids_byTrkKey
|
|
||||||
ON tracking_ids (tracking_key);
|
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
-- *********************************************************************
|
||||||
-- StarredChangeAccess
|
-- StarredChangeAccess
|
||||||
-- @PrimaryKey covers: byAccount
|
-- @PrimaryKey covers: byAccount
|
||||||
|
@@ -158,20 +158,6 @@ WHERE status = 'd';
|
|||||||
CREATE INDEX patch_set_ancestors_desc
|
CREATE INDEX patch_set_ancestors_desc
|
||||||
ON patch_set_ancestors (ancestor_revision);
|
ON patch_set_ancestors (ancestor_revision);
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
|
||||||
-- ProjectAccess
|
|
||||||
-- @PrimaryKey covers: all, suggestByName
|
|
||||||
-- covers: ownedByGroup
|
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
|
||||||
-- TrackingIdAccess
|
|
||||||
--
|
|
||||||
CREATE INDEX tracking_ids_byTrkKey
|
|
||||||
ON tracking_ids (tracking_key);
|
|
||||||
|
|
||||||
|
|
||||||
-- *********************************************************************
|
-- *********************************************************************
|
||||||
-- StarredChangeAccess
|
-- StarredChangeAccess
|
||||||
-- @PrimaryKey covers: byAccount
|
-- @PrimaryKey covers: byAccount
|
||||||
|
@@ -28,13 +28,10 @@ import com.google.gerrit.reviewdb.client.ChangeMessage;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
import com.google.gerrit.reviewdb.client.RevId;
|
||||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.change.ChangeInserter;
|
import com.google.gerrit.server.change.ChangeInserter;
|
||||||
import com.google.gerrit.server.change.ChangeMessages;
|
import com.google.gerrit.server.change.ChangeMessages;
|
||||||
import com.google.gerrit.server.change.PatchSetInserter;
|
import com.google.gerrit.server.change.PatchSetInserter;
|
||||||
import com.google.gerrit.server.config.TrackingFooter;
|
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
|
||||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
@@ -64,7 +61,6 @@ import org.eclipse.jgit.lib.Ref;
|
|||||||
import org.eclipse.jgit.lib.RefDatabase;
|
import org.eclipse.jgit.lib.RefDatabase;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.FooterLine;
|
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
@@ -78,11 +74,8 @@ import java.text.MessageFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
public class ChangeUtil {
|
public class ChangeUtil {
|
||||||
/**
|
/**
|
||||||
@@ -149,59 +142,6 @@ public class ChangeUtil {
|
|||||||
computeSortKey(c);
|
computeSortKey(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateTrackingIds(ReviewDb db, Change change,
|
|
||||||
TrackingFooters trackingFooters, List<FooterLine> footerLines)
|
|
||||||
throws OrmException {
|
|
||||||
if (trackingFooters.getTrackingFooters().isEmpty() || footerLines.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Set<TrackingId> want = new HashSet<TrackingId>();
|
|
||||||
final Set<TrackingId> have = new HashSet<TrackingId>( //
|
|
||||||
db.trackingIds().byChange(change.getId()).toList());
|
|
||||||
|
|
||||||
for (final TrackingFooter footer : trackingFooters.getTrackingFooters()) {
|
|
||||||
for (final FooterLine footerLine : footerLines) {
|
|
||||||
if (footerLine.matches(footer.footerKey())) {
|
|
||||||
// supporting multiple tracking-ids on a single line
|
|
||||||
final Matcher m = footer.match().matcher(footerLine.getValue());
|
|
||||||
while (m.find()) {
|
|
||||||
if (m.group().isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String idstr;
|
|
||||||
if (m.groupCount() > 0) {
|
|
||||||
idstr = m.group(1);
|
|
||||||
} else {
|
|
||||||
idstr = m.group();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (idstr.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (idstr.length() > TrackingId.TRACKING_ID_MAX_CHAR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
want.add(new TrackingId(change.getId(), idstr, footer.system()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only insert the rows we don't have, and delete rows we don't match.
|
|
||||||
//
|
|
||||||
final Set<TrackingId> toInsert = new HashSet<TrackingId>(want);
|
|
||||||
final Set<TrackingId> toDelete = new HashSet<TrackingId>(have);
|
|
||||||
|
|
||||||
toInsert.removeAll(have);
|
|
||||||
toDelete.removeAll(want);
|
|
||||||
|
|
||||||
db.trackingIds().insert(toInsert);
|
|
||||||
db.trackingIds().delete(toDelete);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void insertAncestors(ReviewDb db, PatchSet.Id id, RevCommit src)
|
public static void insertAncestors(ReviewDb db, PatchSet.Id id, RevCommit src)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
final int cnt = src.getParentCount();
|
final int cnt = src.getParentCount();
|
||||||
@@ -433,7 +373,6 @@ public class ChangeUtil {
|
|||||||
|
|
||||||
db.changeMessages().delete(db.changeMessages().byChange(changeId));
|
db.changeMessages().delete(db.changeMessages().byChange(changeId));
|
||||||
db.starredChanges().delete(db.starredChanges().byChange(changeId));
|
db.starredChanges().delete(db.starredChanges().byChange(changeId));
|
||||||
db.trackingIds().delete(db.trackingIds().byChange(changeId));
|
|
||||||
db.changes().delete(Collections.singleton(change));
|
db.changes().delete(Collections.singleton(change));
|
||||||
indexer.delete(change);
|
indexer.delete(change);
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,6 @@ import com.google.gerrit.reviewdb.client.RevId;
|
|||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
import com.google.gerrit.server.ChangeUtil;
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.mail.CreateChangeSender;
|
import com.google.gerrit.server.mail.CreateChangeSender;
|
||||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||||
@@ -59,7 +58,6 @@ public class ChangeInserter {
|
|||||||
private final GitReferenceUpdated gitRefUpdated;
|
private final GitReferenceUpdated gitRefUpdated;
|
||||||
private final ChangeHooks hooks;
|
private final ChangeHooks hooks;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
private final TrackingFooters trackingFooters;
|
|
||||||
private final MergeabilityChecker mergeabilityChecker;
|
private final MergeabilityChecker mergeabilityChecker;
|
||||||
private final CreateChangeSender.Factory createChangeSenderFactory;
|
private final CreateChangeSender.Factory createChangeSenderFactory;
|
||||||
|
|
||||||
@@ -81,7 +79,6 @@ public class ChangeInserter {
|
|||||||
GitReferenceUpdated gitRefUpdated,
|
GitReferenceUpdated gitRefUpdated,
|
||||||
ChangeHooks hooks,
|
ChangeHooks hooks,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
TrackingFooters trackingFooters,
|
|
||||||
MergeabilityChecker mergeabilityChecker,
|
MergeabilityChecker mergeabilityChecker,
|
||||||
CreateChangeSender.Factory createChangeSenderFactory,
|
CreateChangeSender.Factory createChangeSenderFactory,
|
||||||
@Assisted RefControl refControl,
|
@Assisted RefControl refControl,
|
||||||
@@ -91,7 +88,6 @@ public class ChangeInserter {
|
|||||||
this.gitRefUpdated = gitRefUpdated;
|
this.gitRefUpdated = gitRefUpdated;
|
||||||
this.hooks = hooks;
|
this.hooks = hooks;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.trackingFooters = trackingFooters;
|
|
||||||
this.mergeabilityChecker = mergeabilityChecker;
|
this.mergeabilityChecker = mergeabilityChecker;
|
||||||
this.createChangeSenderFactory = createChangeSenderFactory;
|
this.createChangeSenderFactory = createChangeSenderFactory;
|
||||||
this.refControl = refControl;
|
this.refControl = refControl;
|
||||||
@@ -162,7 +158,6 @@ public class ChangeInserter {
|
|||||||
ChangeUtil.insertAncestors(db, patchSet.getId(), commit);
|
ChangeUtil.insertAncestors(db, patchSet.getId(), commit);
|
||||||
db.patchSets().insert(Collections.singleton(patchSet));
|
db.patchSets().insert(Collections.singleton(patchSet));
|
||||||
db.changes().insert(Collections.singleton(change));
|
db.changes().insert(Collections.singleton(change));
|
||||||
ChangeUtil.updateTrackingIds(db, change, trackingFooters, commit.getFooterLines());
|
|
||||||
LabelTypes labelTypes = refControl.getProjectControl().getLabelTypes();
|
LabelTypes labelTypes = refControl.getProjectControl().getLabelTypes();
|
||||||
approvalsUtil.addReviewers(db, labelTypes, change, patchSet, patchSetInfo,
|
approvalsUtil.addReviewers(db, labelTypes, change, patchSet, patchSetInfo,
|
||||||
reviewers, Collections.<Account.Id> emptySet());
|
reviewers, Collections.<Account.Id> emptySet());
|
||||||
|
@@ -31,7 +31,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
import com.google.gerrit.server.ChangeUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
|
||||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.MergeUtil;
|
import com.google.gerrit.server.git.MergeUtil;
|
||||||
@@ -54,7 +53,6 @@ import org.eclipse.jgit.lib.ObjectId;
|
|||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.merge.ThreeWayMerger;
|
import org.eclipse.jgit.merge.ThreeWayMerger;
|
||||||
import org.eclipse.jgit.revwalk.FooterLine;
|
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
@@ -89,7 +87,6 @@ public class PatchSetInserter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final ChangeHooks hooks;
|
private final ChangeHooks hooks;
|
||||||
private final TrackingFooters trackingFooters;
|
|
||||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||||
private final ReviewDb db;
|
private final ReviewDb db;
|
||||||
private final IdentifiedUser user;
|
private final IdentifiedUser user;
|
||||||
@@ -116,7 +113,6 @@ public class PatchSetInserter {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PatchSetInserter(ChangeHooks hooks,
|
public PatchSetInserter(ChangeHooks hooks,
|
||||||
TrackingFooters trackingFooters,
|
|
||||||
ReviewDb db,
|
ReviewDb db,
|
||||||
PatchSetInfoFactory patchSetInfoFactory,
|
PatchSetInfoFactory patchSetInfoFactory,
|
||||||
GitReferenceUpdated gitRefUpdated,
|
GitReferenceUpdated gitRefUpdated,
|
||||||
@@ -131,7 +127,6 @@ public class PatchSetInserter {
|
|||||||
@Assisted Change change,
|
@Assisted Change change,
|
||||||
@Assisted RevCommit commit) {
|
@Assisted RevCommit commit) {
|
||||||
this.hooks = hooks;
|
this.hooks = hooks;
|
||||||
this.trackingFooters = trackingFooters;
|
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.patchSetInfoFactory = patchSetInfoFactory;
|
this.patchSetInfoFactory = patchSetInfoFactory;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@@ -287,9 +282,6 @@ public class PatchSetInserter {
|
|||||||
ApprovalsUtil.copyLabels(db, refControl.getProjectControl()
|
ApprovalsUtil.copyLabels(db, refControl.getProjectControl()
|
||||||
.getLabelTypes(), currentPatchSetId, patchSet, changeKind);
|
.getLabelTypes(), currentPatchSetId, patchSet, changeKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<FooterLine> footerLines = commit.getFooterLines();
|
|
||||||
ChangeUtil.updateTrackingIds(db, updatedChange, trackingFooters, footerLines);
|
|
||||||
db.commit();
|
db.commit();
|
||||||
|
|
||||||
if (changeMessage != null) {
|
if (changeMessage != null) {
|
||||||
|
@@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.config;
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import org.eclipse.jgit.revwalk.FooterLine;
|
import org.eclipse.jgit.revwalk.FooterLine;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
public class TrackingFooters {
|
public class TrackingFooters {
|
||||||
@@ -33,8 +33,12 @@ public class TrackingFooters {
|
|||||||
return trackingFooters;
|
return trackingFooters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> extract(List<FooterLine> lines) {
|
public boolean isEmpty() {
|
||||||
Set<String> r = Sets.newHashSet();
|
return trackingFooters.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Multimap<String, String> extract(List<FooterLine> lines) {
|
||||||
|
Multimap<String, String> r = ArrayListMultimap.create();
|
||||||
for (FooterLine footer : lines) {
|
for (FooterLine footer : lines) {
|
||||||
for (TrackingFooter config : trackingFooters) {
|
for (TrackingFooter config : trackingFooters) {
|
||||||
if (footer.matches(config.footerKey())) {
|
if (footer.matches(config.footerKey())) {
|
||||||
@@ -44,7 +48,7 @@ public class TrackingFooters {
|
|||||||
? m.group(1)
|
? m.group(1)
|
||||||
: m.group();
|
: m.group();
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
r.add(id);
|
r.put(config.system(), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.data.LabelType;
|
import com.google.gerrit.common.data.LabelType;
|
||||||
@@ -30,7 +31,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
import com.google.gerrit.reviewdb.client.RevId;
|
||||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
|
||||||
import com.google.gerrit.reviewdb.client.UserIdentity;
|
import com.google.gerrit.reviewdb.client.UserIdentity;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
@@ -292,11 +292,16 @@ public class EventFactory {
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTrackingIds(ChangeAttribute a, Collection<TrackingId> ids) {
|
public void addTrackingIds(ChangeAttribute a, Multimap<String, String> set) {
|
||||||
if (!ids.isEmpty()) {
|
if (!set.isEmpty()) {
|
||||||
a.trackingIds = new ArrayList<TrackingIdAttribute>(ids.size());
|
a.trackingIds = new ArrayList<TrackingIdAttribute>(set.size());
|
||||||
for (TrackingId t : ids) {
|
for (Map.Entry<String, Collection<String>> e : set.asMap().entrySet()) {
|
||||||
a.trackingIds.add(asTrackingIdAttribute(t));
|
for (String id : e.getValue()) {
|
||||||
|
TrackingIdAttribute t = new TrackingIdAttribute();
|
||||||
|
t.system = e.getKey();
|
||||||
|
t.id = id;
|
||||||
|
a.trackingIds.add(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -379,13 +384,6 @@ public class EventFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrackingIdAttribute asTrackingIdAttribute(TrackingId id) {
|
|
||||||
TrackingIdAttribute a = new TrackingIdAttribute();
|
|
||||||
a.system = id.getSystem();
|
|
||||||
a.id = id.getTrackingId();
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a PatchSetAttribute for the given patchset suitable for
|
* Create a PatchSetAttribute for the given patchset suitable for
|
||||||
* serialization to JSON.
|
* serialization to JSON.
|
||||||
|
@@ -75,7 +75,6 @@ import com.google.gerrit.server.change.RevisionResource;
|
|||||||
import com.google.gerrit.server.change.Submit;
|
import com.google.gerrit.server.change.Submit;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||||
import com.google.gerrit.server.config.TrackingFooters;
|
|
||||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.MultiProgressMonitor.Task;
|
import com.google.gerrit.server.git.MultiProgressMonitor.Task;
|
||||||
@@ -127,9 +126,9 @@ import org.eclipse.jgit.transport.AdvertiseRefsHook;
|
|||||||
import org.eclipse.jgit.transport.AdvertiseRefsHookChain;
|
import org.eclipse.jgit.transport.AdvertiseRefsHookChain;
|
||||||
import org.eclipse.jgit.transport.BaseReceivePack;
|
import org.eclipse.jgit.transport.BaseReceivePack;
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
import org.eclipse.jgit.transport.RefFilter;
|
|
||||||
import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
||||||
import org.eclipse.jgit.transport.ReceivePack;
|
import org.eclipse.jgit.transport.ReceivePack;
|
||||||
|
import org.eclipse.jgit.transport.RefFilter;
|
||||||
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
||||||
import org.eclipse.jgit.transport.UploadPack;
|
import org.eclipse.jgit.transport.UploadPack;
|
||||||
import org.kohsuke.args4j.CmdLineException;
|
import org.kohsuke.args4j.CmdLineException;
|
||||||
@@ -266,7 +265,6 @@ public class ReceiveCommits {
|
|||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
private final String canonicalWebUrl;
|
private final String canonicalWebUrl;
|
||||||
private final CommitValidators.Factory commitValidatorsFactory;
|
private final CommitValidators.Factory commitValidatorsFactory;
|
||||||
private final TrackingFooters trackingFooters;
|
|
||||||
private final TagCache tagCache;
|
private final TagCache tagCache;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final ChangeInserter.Factory changeInserterFactory;
|
private final ChangeInserter.Factory changeInserterFactory;
|
||||||
@@ -333,7 +331,6 @@ public class ReceiveCommits {
|
|||||||
final CommitValidators.Factory commitValidatorsFactory,
|
final CommitValidators.Factory commitValidatorsFactory,
|
||||||
@CanonicalWebUrl final String canonicalWebUrl,
|
@CanonicalWebUrl final String canonicalWebUrl,
|
||||||
@GerritPersonIdent final PersonIdent gerritIdent,
|
@GerritPersonIdent final PersonIdent gerritIdent,
|
||||||
final TrackingFooters trackingFooters,
|
|
||||||
final WorkQueue workQueue,
|
final WorkQueue workQueue,
|
||||||
@ChangeUpdateExecutor ListeningExecutorService changeUpdateExector,
|
@ChangeUpdateExecutor ListeningExecutorService changeUpdateExector,
|
||||||
final RequestScopePropagator requestScopePropagator,
|
final RequestScopePropagator requestScopePropagator,
|
||||||
@@ -363,7 +360,6 @@ public class ReceiveCommits {
|
|||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.canonicalWebUrl = canonicalWebUrl;
|
this.canonicalWebUrl = canonicalWebUrl;
|
||||||
this.trackingFooters = trackingFooters;
|
|
||||||
this.tagCache = tagCache;
|
this.tagCache = tagCache;
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.changeInserterFactory = changeInserterFactory;
|
this.changeInserterFactory = changeInserterFactory;
|
||||||
@@ -1871,9 +1867,6 @@ public class ReceiveCommits {
|
|||||||
.messageUUID(db)), me, newPatchSet.getCreatedOn(), newPatchSet.getId());
|
.messageUUID(db)), me, newPatchSet.getCreatedOn(), newPatchSet.getId());
|
||||||
msg.setMessage("Uploaded patch set " + newPatchSet.getPatchSetId() + ".");
|
msg.setMessage("Uploaded patch set " + newPatchSet.getPatchSetId() + ".");
|
||||||
db.changeMessages().insert(Collections.singleton(msg));
|
db.changeMessages().insert(Collections.singleton(msg));
|
||||||
if (change.currentPatchSetId().equals(priorPatchSet)) {
|
|
||||||
ChangeUtil.updateTrackingIds(db, change, trackingFooters, footerLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mergedIntoRef == null) {
|
if (mergedIntoRef == null) {
|
||||||
// Change should be new, so it can go through review again.
|
// Change should be new, so it can go through review again.
|
||||||
|
@@ -222,8 +222,8 @@ public class ChangeField {
|
|||||||
public Iterable<String> get(ChangeData input, FillArgs args)
|
public Iterable<String> get(ChangeData input, FillArgs args)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
try {
|
try {
|
||||||
return args.trackingFooters.extract(
|
return Sets.newHashSet(args.trackingFooters.extract(
|
||||||
input.commitFooters(args.repoManager, args.db));
|
input.commitFooters(args.repoManager, args.db)).values());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new OrmException(e);
|
throw new OrmException(e);
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ public class BasicChangeRewrites extends QueryRewriter<ChangeData> {
|
|||||||
new InvalidProvider<ReviewDb>(), //
|
new InvalidProvider<ReviewDb>(), //
|
||||||
new InvalidProvider<ChangeQueryRewriter>(), //
|
new InvalidProvider<ChangeQueryRewriter>(), //
|
||||||
null, null, null, null, null, null, null, //
|
null, null, null, null, null, null, null, //
|
||||||
null, null, null, null, null, null, null), null);
|
null, null, null, null, null, null, null, null), null);
|
||||||
|
|
||||||
private static final QueryRewriter.Definition<ChangeData, BasicChangeRewrites> mydef =
|
private static final QueryRewriter.Definition<ChangeData, BasicChangeRewrites> mydef =
|
||||||
new QueryRewriter.Definition<ChangeData, BasicChangeRewrites>(
|
new QueryRewriter.Definition<ChangeData, BasicChangeRewrites>(
|
||||||
|
@@ -30,7 +30,6 @@ import com.google.gerrit.reviewdb.client.Patch;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
import com.google.gerrit.reviewdb.client.PatchLineComment;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
@@ -148,7 +147,6 @@ public class ChangeData {
|
|||||||
private List<PatchSetApproval> currentApprovals;
|
private List<PatchSetApproval> currentApprovals;
|
||||||
private List<String> currentFiles;
|
private List<String> currentFiles;
|
||||||
private Collection<PatchLineComment> comments;
|
private Collection<PatchLineComment> comments;
|
||||||
private Collection<TrackingId> trackingIds;
|
|
||||||
private CurrentUser visibleTo;
|
private CurrentUser visibleTo;
|
||||||
private ChangeControl changeControl;
|
private ChangeControl changeControl;
|
||||||
private List<ChangeMessage> messages;
|
private List<ChangeMessage> messages;
|
||||||
@@ -483,14 +481,6 @@ public class ChangeData {
|
|||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<TrackingId> trackingIds(Provider<ReviewDb> db)
|
|
||||||
throws OrmException {
|
|
||||||
if (trackingIds == null) {
|
|
||||||
trackingIds = db.get().trackingIds().byChange(legacyId).toList();
|
|
||||||
}
|
|
||||||
return trackingIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ChangeMessage> messages(Provider<ReviewDb> db)
|
public List<ChangeMessage> messages(Provider<ReviewDb> db)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
if (messages == null) {
|
if (messages == null) {
|
||||||
|
@@ -31,6 +31,7 @@ import com.google.gerrit.server.account.CapabilityControl;
|
|||||||
import com.google.gerrit.server.account.GroupBackend;
|
import com.google.gerrit.server.account.GroupBackend;
|
||||||
import com.google.gerrit.server.account.GroupBackends;
|
import com.google.gerrit.server.account.GroupBackends;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
|
import com.google.gerrit.server.config.TrackingFooters;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.git.SubmitStrategyFactory;
|
import com.google.gerrit.server.git.SubmitStrategyFactory;
|
||||||
import com.google.gerrit.server.index.ChangeIndex;
|
import com.google.gerrit.server.index.ChangeIndex;
|
||||||
@@ -157,6 +158,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
final IndexCollection indexes;
|
final IndexCollection indexes;
|
||||||
final SubmitStrategyFactory submitStrategyFactory;
|
final SubmitStrategyFactory submitStrategyFactory;
|
||||||
final ConflictsCache conflictsCache;
|
final ConflictsCache conflictsCache;
|
||||||
|
final TrackingFooters trackingFooters;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -175,7 +177,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
Provider<ListChildProjects> listChildProjects,
|
Provider<ListChildProjects> listChildProjects,
|
||||||
IndexCollection indexes,
|
IndexCollection indexes,
|
||||||
SubmitStrategyFactory submitStrategyFactory,
|
SubmitStrategyFactory submitStrategyFactory,
|
||||||
ConflictsCache conflictsCache) {
|
ConflictsCache conflictsCache,
|
||||||
|
TrackingFooters trackingFooters) {
|
||||||
this.dbProvider = dbProvider;
|
this.dbProvider = dbProvider;
|
||||||
this.rewriter = rewriter;
|
this.rewriter = rewriter;
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
@@ -192,6 +195,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
this.submitStrategyFactory = submitStrategyFactory;
|
this.submitStrategyFactory = submitStrategyFactory;
|
||||||
this.conflictsCache = conflictsCache;
|
this.conflictsCache = conflictsCache;
|
||||||
|
this.trackingFooters = trackingFooters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +590,8 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
public Predicate<ChangeData> tr(String trackingId) {
|
public Predicate<ChangeData> tr(String trackingId) {
|
||||||
return new TrackingIdPredicate(args.dbProvider, trackingId);
|
return new TrackingIdPredicate(args.dbProvider, args.trackingFooters,
|
||||||
|
args.repoManager, trackingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
|
@@ -22,6 +22,7 @@ import com.google.gerrit.common.data.SubmitRecord;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.config.TrackingFooters;
|
||||||
import com.google.gerrit.server.data.ChangeAttribute;
|
import com.google.gerrit.server.data.ChangeAttribute;
|
||||||
import com.google.gerrit.server.data.PatchSetAttribute;
|
import com.google.gerrit.server.data.PatchSetAttribute;
|
||||||
import com.google.gerrit.server.data.QueryStatsAttribute;
|
import com.google.gerrit.server.data.QueryStatsAttribute;
|
||||||
@@ -99,6 +100,7 @@ public class QueryProcessor {
|
|||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final ChangeControl.GenericFactory changeControlFactory;
|
private final ChangeControl.GenericFactory changeControlFactory;
|
||||||
|
private final TrackingFooters trackingFooters;
|
||||||
private final CurrentUser user;
|
private final CurrentUser user;
|
||||||
private final int maxLimit;
|
private final int maxLimit;
|
||||||
|
|
||||||
@@ -125,12 +127,14 @@ public class QueryProcessor {
|
|||||||
ChangeQueryBuilder.Factory queryBuilder, CurrentUser currentUser,
|
ChangeQueryBuilder.Factory queryBuilder, CurrentUser currentUser,
|
||||||
ChangeQueryRewriter queryRewriter, Provider<ReviewDb> db,
|
ChangeQueryRewriter queryRewriter, Provider<ReviewDb> db,
|
||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
|
TrackingFooters trackingFooters,
|
||||||
ChangeControl.GenericFactory changeControlFactory) {
|
ChangeControl.GenericFactory changeControlFactory) {
|
||||||
this.eventFactory = eventFactory;
|
this.eventFactory = eventFactory;
|
||||||
this.queryBuilder = queryBuilder.create(currentUser);
|
this.queryBuilder = queryBuilder.create(currentUser);
|
||||||
this.queryRewriter = queryRewriter;
|
this.queryRewriter = queryRewriter;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
|
this.trackingFooters = trackingFooters;
|
||||||
this.changeControlFactory = changeControlFactory;
|
this.changeControlFactory = changeControlFactory;
|
||||||
this.user = currentUser;
|
this.user = currentUser;
|
||||||
this.maxLimit = currentUser.getCapabilities()
|
this.maxLimit = currentUser.getCapabilities()
|
||||||
@@ -307,10 +311,15 @@ public class QueryProcessor {
|
|||||||
if (cc == null || cc.getCurrentUser() != user) {
|
if (cc == null || cc.getCurrentUser() != user) {
|
||||||
cc = changeControlFactory.controlFor(d.change(db), user);
|
cc = changeControlFactory.controlFor(d.change(db), user);
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelTypes labelTypes = cc.getLabelTypes();
|
LabelTypes labelTypes = cc.getLabelTypes();
|
||||||
c = eventFactory.asChangeAttribute(d.getChange());
|
c = eventFactory.asChangeAttribute(d.getChange());
|
||||||
eventFactory.extend(c, d.getChange());
|
eventFactory.extend(c, d.getChange());
|
||||||
eventFactory.addTrackingIds(c, d.trackingIds(db));
|
|
||||||
|
if (!trackingFooters.isEmpty()) {
|
||||||
|
eventFactory.addTrackingIds(c,
|
||||||
|
trackingFooters.extract(d.commitFooters(repoManager, db)));
|
||||||
|
}
|
||||||
|
|
||||||
if (includeAllReviewers) {
|
if (includeAllReviewers) {
|
||||||
eventFactory.addAllReviewers(c, d.getChange());
|
eventFactory.addAllReviewers(c, d.getChange());
|
||||||
|
@@ -14,26 +14,46 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.TrackingId;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
|
import com.google.gerrit.server.config.TrackingFooters;
|
||||||
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.index.ChangeField;
|
import com.google.gerrit.server.index.ChangeField;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
class TrackingIdPredicate extends IndexPredicate<ChangeData> {
|
import org.slf4j.Logger;
|
||||||
private final Provider<ReviewDb> db;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
TrackingIdPredicate(Provider<ReviewDb> db, String trackingId) {
|
import java.io.IOException;
|
||||||
|
|
||||||
|
class TrackingIdPredicate extends IndexPredicate<ChangeData> {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TrackingIdPredicate.class);
|
||||||
|
|
||||||
|
private final Provider<ReviewDb> db;
|
||||||
|
private final TrackingFooters trackingFooters;
|
||||||
|
private final GitRepositoryManager repositoryManager;
|
||||||
|
|
||||||
|
TrackingIdPredicate(Provider<ReviewDb> db,
|
||||||
|
TrackingFooters trackingFooters,
|
||||||
|
GitRepositoryManager repositoryManager,
|
||||||
|
String trackingId) {
|
||||||
super(ChangeField.TR, trackingId);
|
super(ChangeField.TR, trackingId);
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
this.trackingFooters = trackingFooters;
|
||||||
|
this.repositoryManager = repositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(final ChangeData object) throws OrmException {
|
public boolean match(ChangeData object) throws OrmException {
|
||||||
for (TrackingId c : object.trackingIds(db)) {
|
Change c = object.change(db);
|
||||||
if (getValue().equals(c.getTrackingId())) {
|
if (c != null) {
|
||||||
return true;
|
try {
|
||||||
|
return trackingFooters.extract(object.commitFooters(repositoryManager, db))
|
||||||
|
.values().contains(getValue());
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Cannot extract footers from " + c.getChangeId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -26,7 +26,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder {
|
|||||||
new FakeQueryBuilder.Definition<ChangeData, FakeQueryBuilder>(
|
new FakeQueryBuilder.Definition<ChangeData, FakeQueryBuilder>(
|
||||||
FakeQueryBuilder.class),
|
FakeQueryBuilder.class),
|
||||||
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
new ChangeQueryBuilder.Arguments(null, null, null, null, null, null,
|
||||||
null, null, null, null, null, null, null, indexes, null, null),
|
null, null, null, null, null, null, null, indexes, null, null, null),
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user