return this;
}
// FIXME get repository lock
public void execute() throws HgRemoteConnectionException, HgIOException, HgLibraryFailureException, CancelledException {
final ProgressSupport progress = getProgressSupport(null);
try {
progress.start(100);
// TODO refactor same code in HgIncomingCommand #getComparator and #getParentHelper
final HgChangelog clog = repo.getChangelog();
final HgParentChildMap<HgChangelog> parentHelper = new HgParentChildMap<HgChangelog>(clog);
parentHelper.init();
final RepositoryComparator comparator = new RepositoryComparator(parentHelper, remote);
// get incoming revisions
comparator.compare(new ProgressSupport.Sub(progress, 50), getCancelSupport(null, true));
final List<Nodeid> common = comparator.getCommon();
// get bundle with changes from remote
HgBundle incoming = remote.getChanges(common);
//
// add revisions to changelog, manifest, files
final Internals implRepo = HgInternals.getImplementationRepo(repo);
final AddRevInspector insp;
Transaction.Factory trFactory = implRepo.getTransactionFactory();
Transaction tr = trFactory.create(repo);
try {
incoming.inspectAll(insp = new AddRevInspector(implRepo, tr));
insp.done();
tr.commit();
} catch (HgRuntimeException ex) {
tr.rollback();
throw ex;
} catch (HgIOException ex) {
tr.rollback();
throw ex;
} catch (RuntimeException ex) {
tr.rollback();
throw ex;
}
progress.worked(45);
added = insp.addedChangesets();
if (!added.isEmpty()) {
parentHelper.init(); // refresh the map, we use it for phases below
}
// get remote phases, update local phases to match that of remote
// do not update any remote phase (it's pull, after all)
final PhasesHelper phaseHelper = new PhasesHelper(implRepo, parentHelper);
if (phaseHelper.isCapableOfPhases()) {
RevisionSet rsCommon = new RevisionSet(common);
HgRemoteRepository.Phases remotePhases = remote.getPhases();
phaseHelper.synchronizeWithRemote(remotePhases, rsCommon.union(added));
}
progress.worked(5);
incoming.unlink(); // keep the file only in case of failure
} catch (HgRuntimeException ex) {
throw new HgLibraryFailureException(ex);
} finally {
progress.done();
}
}