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:
Shawn O. Pearce
2010-05-10 11:24:28 -07:00
parent 2f1f80687e
commit d875e38b25
2 changed files with 8 additions and 7 deletions

View File

@@ -53,7 +53,7 @@ import java.util.Set;
*/
class PushOp implements ProjectRunnable {
interface Factory {
PushOp create(String d, URIish u);
PushOp create(Project.NameKey d, URIish u);
}
private static final Logger log = PushReplication.log;
@@ -64,15 +64,16 @@ class PushOp implements ProjectRunnable {
private final RemoteConfig config;
private final Set<String> delta = new HashSet<String>();
private final String projectName;
private final Project.NameKey projectName;
private final URIish uri;
private boolean mirror;
private Repository db;
@Inject
PushOp(final GitRepositoryManager grm, final PushReplication.ReplicationConfig p,
final RemoteConfig c, @Assisted final String d, @Assisted final URIish u) {
PushOp(final GitRepositoryManager grm,
final PushReplication.ReplicationConfig p, final RemoteConfig c,
@Assisted final Project.NameKey d, @Assisted final URIish u) {
repoManager = grm;
pool = p;
config = c;
@@ -100,7 +101,7 @@ class PushOp implements ProjectRunnable {
// created and scheduled for a future point in time.)
//
pool.notifyStarting(this);
db = repoManager.openRepository(projectName);
db = repoManager.openRepository(projectName.get());
runImpl();
} catch (RepositoryNotFoundException e) {
log.error("Cannot replicate " + projectName + "; " + e.getMessage());
@@ -289,7 +290,7 @@ class PushOp implements ProjectRunnable {
@Override
public NameKey getProjectNameKey() {
return new Project.NameKey(projectName);
return projectName;
}
@Override

View File

@@ -366,7 +366,7 @@ public class PushReplication implements ReplicationQueue {
synchronized (pending) {
PushOp e = pending.get(uri);
if (e == null) {
e = opFactory.create(project.get(), uri);
e = opFactory.create(project, uri);
pool.schedule(e, delay, TimeUnit.SECONDS);
pending.put(uri, e);
}