Refactor PushOp to use Project.NameKey
Elsewhere we keep track of a project by its NameKey object, rather than a simple String. Do the same in PushOp, as it makes the API a bit more clear. Change-Id: Ieb3120e655b7b1dc43a675555ea8de63900d13a8 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -53,7 +53,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
class PushOp implements ProjectRunnable {
|
class PushOp implements ProjectRunnable {
|
||||||
interface Factory {
|
interface Factory {
|
||||||
PushOp create(String d, URIish u);
|
PushOp create(Project.NameKey d, URIish u);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger log = PushReplication.log;
|
private static final Logger log = PushReplication.log;
|
||||||
@@ -64,15 +64,16 @@ class PushOp implements ProjectRunnable {
|
|||||||
private final RemoteConfig config;
|
private final RemoteConfig config;
|
||||||
|
|
||||||
private final Set<String> delta = new HashSet<String>();
|
private final Set<String> delta = new HashSet<String>();
|
||||||
private final String projectName;
|
private final Project.NameKey projectName;
|
||||||
private final URIish uri;
|
private final URIish uri;
|
||||||
private boolean mirror;
|
private boolean mirror;
|
||||||
|
|
||||||
private Repository db;
|
private Repository db;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PushOp(final GitRepositoryManager grm, final PushReplication.ReplicationConfig p,
|
PushOp(final GitRepositoryManager grm,
|
||||||
final RemoteConfig c, @Assisted final String d, @Assisted final URIish u) {
|
final PushReplication.ReplicationConfig p, final RemoteConfig c,
|
||||||
|
@Assisted final Project.NameKey d, @Assisted final URIish u) {
|
||||||
repoManager = grm;
|
repoManager = grm;
|
||||||
pool = p;
|
pool = p;
|
||||||
config = c;
|
config = c;
|
||||||
@@ -100,7 +101,7 @@ class PushOp implements ProjectRunnable {
|
|||||||
// created and scheduled for a future point in time.)
|
// created and scheduled for a future point in time.)
|
||||||
//
|
//
|
||||||
pool.notifyStarting(this);
|
pool.notifyStarting(this);
|
||||||
db = repoManager.openRepository(projectName);
|
db = repoManager.openRepository(projectName.get());
|
||||||
runImpl();
|
runImpl();
|
||||||
} catch (RepositoryNotFoundException e) {
|
} catch (RepositoryNotFoundException e) {
|
||||||
log.error("Cannot replicate " + projectName + "; " + e.getMessage());
|
log.error("Cannot replicate " + projectName + "; " + e.getMessage());
|
||||||
@@ -289,7 +290,7 @@ class PushOp implements ProjectRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameKey getProjectNameKey() {
|
public NameKey getProjectNameKey() {
|
||||||
return new Project.NameKey(projectName);
|
return projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -366,7 +366,7 @@ public class PushReplication implements ReplicationQueue {
|
|||||||
synchronized (pending) {
|
synchronized (pending) {
|
||||||
PushOp e = pending.get(uri);
|
PushOp e = pending.get(uri);
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
e = opFactory.create(project.get(), uri);
|
e = opFactory.create(project, uri);
|
||||||
pool.schedule(e, delay, TimeUnit.SECONDS);
|
pool.schedule(e, delay, TimeUnit.SECONDS);
|
||||||
pending.put(uri, e);
|
pending.put(uri, e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user