public DownOperation(Config config) { this(config, new DownOperationOptions()); }
public DownOperationOptions parseOptions(String[] operationArguments) { DownOperationOptions operationOptions = new DownOperationOptions(); OptionParser parser = new OptionParser(); parser.allowsUnrecognizedOptions(); OptionSpec<String> optionConflictStrategy = parser.acceptsAll(asList("C", "conflict-strategy")).withRequiredArg(); OptionSpec<Void> optionNoApply = parser.acceptsAll(asList("A", "no-apply")); OptionSet options = parser.parse(operationArguments); // --conflict-strategy=<strategy> if (options.has(optionConflictStrategy)) { String conflictStrategyStr = options.valueOf(optionConflictStrategy).toUpperCase(); operationOptions.setConflictStrategy(DownConflictStrategy.valueOf(conflictStrategyStr)); } // --no-apply if (options.has(optionNoApply)) { operationOptions.setApplyChanges(false); } return operationOptions; }
if (options.getConflictStrategy() != DownConflictStrategy.RENAME) { logger.log(Level.INFO, "Conflict strategy " + options.getConflictStrategy() + " not yet implemented."); result.setResultCode(DownResultCode.NOK);
private void applyChangesAndPersistDatabase(MemoryDatabase winnersDatabase, boolean cleanupOccurred, List<PartialFileHistory> preDeleteFileHistoriesWithLastVersion) throws Exception { if (options.isApplyChanges()) { new ApplyChangesOperation(config, localDatabase, transferManager, winnersDatabase, result, cleanupOccurred, preDeleteFileHistoriesWithLastVersion).execute(); } else { logger.log(Level.INFO, "Doing nothing on the file system, because --no-apply switched on"); } // We only persist the versions that we have already applied. DatabaseBranch currentApplyBranch = new DatabaseBranch(); for (DatabaseVersion databaseVersion : winnersDatabase.getDatabaseVersions()) { currentApplyBranch.add(databaseVersion.getHeader()); } persistDatabaseVersions(currentApplyBranch, winnersDatabase); localDatabase.commit(); }
public DownOperationResult down() throws Exception { return down(new DownOperationOptions()); }