private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException { logger.debug("Repo already checked out - updating instead."); try { final SvnUpdate update = svnOperationFactory.createUpdate(); update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); long[] ids = update.run(); StringBuilder version = new StringBuilder(); for (long id : ids) { if (version.length() > 0) { version.append(","); } version.append(id); } return version.toString(); } catch (Exception e) { String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")"; if (logger.isDebugEnabled()) { logger.debug(message, e); } else if (logger.isWarnEnabled()) { logger.warn(message); } } final SVNStatus status = SVNClientManager.newInstance().getStatusClient() .doStatus(getWorkingDirectory(), false); return status != null ? status.getRevision().toString() : null; }
private String checkout(SvnOperationFactory svnOperationFactory) throws SVNException { logger.debug("Checking out " + getUri() + " to: " + getWorkingDirectory().getAbsolutePath()); final SvnCheckout checkout = svnOperationFactory.createCheckout(); checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(getUri()))); checkout.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); Long id = checkout.run(); if (id == null) { return null; } return id.toString(); }
/** * Creates a target from file * @param file target file * @return a new <code>SvnTarget</code> object representing the file */ public static SvnTarget fromFile(File file) { return fromFile(file, SVNRevision.UNDEFINED); }
public void handle(File path, String changelistName) { try { getOperation().receive(SvnTarget.fromFile(path), changelistName); } catch (SVNException e) {} }
public void handle(File path, String changelistName) { try { getOperation().receive(SvnTarget.fromFile(path), changelistName); } catch (SVNException e) { } } }
private SvnTarget getAbsoluteTarget(String path) { if (SVNPathUtil.isURL(path)) { try { return SvnTarget.fromURL(SVNURL.parseURIEncoded(path)); } catch (SVNException e) { return SvnTarget.fromFile(SVNFileUtil.createFilePath(path)); } } else { return SvnTarget.fromFile(SVNFileUtil.createFilePath(path)); } } }
private SvnTarget getTarget(String path, Revision revision) { SVNRevision svnRevision = getSVNRevision(revision); if (SVNPathUtil.isURL(path)) { try { return SvnTarget.fromURL(SVNURL.parseURIEncoded(path), svnRevision); } catch (SVNException e) { //never happens if SVNPathUtil#isURL works correctly throw new IllegalArgumentException(e); } } return SvnTarget.fromFile(new File(path), svnRevision); }
public static void readPropertiesRecursively(SVNWCDbRoot root, File relpath, SVNDepth depth, boolean baseProperties, boolean pristineProperties, Collection<String> changelists, ISvnObjectReceiver<SVNProperties> receiver) throws SVNException { final Collection<Properties> propsList = cacheProperties(root, relpath, depth, baseProperties, pristineProperties, changelists); for (Properties properties : propsList) { SVNProperties props = SVNSqlJetStatement.parseProperties(properties.properties); File target = new File(properties.relPath); File absolutePath = root.getAbsPath(target); receiver.receive(SvnTarget.fromFile(absolutePath), props); } }
/** * Get version of "omegat/project_save.tmx" in SVN. */ private static String getSVNTmxVersion(File wc) throws Exception { final SvnOperationFactory of = new SvnOperationFactory(); final SvnGetInfo infoOp = of.createGetInfo(); infoOp.setSingleTarget(SvnTarget.fromFile(new File(wc, "omegat/project_save.tmx"))); infoOp.setDepth(SVNDepth.EMPTY); SvnInfo info = infoOp.run(); long r = info.getRevision(); return Long.toString(r); }
public void handleInfo(SVNInfo info) throws SVNException { SvnInfo info2 = SvnCodec.info(info); getOperation().receive(SvnTarget.fromFile(info.getFile()), info2); }
public void handleAdminEvent(SVNAdminEvent event, double progress) throws SVNException { getOperation().receive(SvnTarget.fromFile(getOperation().getRepositoryRoot()), event); } }
public void upgrade(String path) throws ClientException { try { final SvnOperationFactory of = getSVNWCClient().getOperationsFactory(); final SvnUpgrade upgrade = of.createUpgrade(); upgrade.setSingleTarget(SvnTarget.fromFile(new File(path))); upgrade.run(); } catch (SVNException e) { throwException(e); } } }
public void handleDiffStatus(SVNDiffStatus diffStatus) throws SVNException { if (receiver != null) { final SvnTarget target = diffStatus.getURL() != null ? SvnTarget.fromURL(diffStatus.getURL()) : SvnTarget.fromFile(diffStatus.getFile()); receiver.receive(target, SvnCodec.diffStatus(diffStatus)); } } };
public void doPatch(File absPatchPath, File localAbsPath, boolean dryRun, int stripCount) throws SVNException { final SvnPatch patch = getOperationsFactory().createPatch(); patch.setPatchFile(absPatchPath); patch.setStripCount(stripCount); patch.setDryRun(dryRun); patch.setSingleTarget(SvnTarget.fromFile(localAbsPath)); patch.run(); }
private void update(@NotNull String path, @Nullable SVNDepth depth) throws SVNException { final SvnUpdate update = factory.createUpdate(); update.setSingleTarget(SvnTarget.fromFile(new File(wc, path))); update.setRevision(SVNRevision.HEAD); if (depth != null) { update.setDepthIsSticky(true); update.setDepth(depth); } update.run(); }
public static SvnCopySource copySource(SVNCopySource oldSource) { SvnTarget target; if (oldSource.isURL()) { target = SvnTarget.fromURL(oldSource.getURL(), oldSource.getPegRevision()); } else { target = SvnTarget.fromFile(oldSource.getFile(), oldSource.getPegRevision()); } final SvnCopySource copySource = SvnCopySource.create(target, oldSource.getRevision()); copySource.setCopyContents(oldSource.isCopyContents()); return copySource; }
public void doCleanup(File path, boolean deleteWCProperties, boolean breakLocks, boolean vacuumPristines, boolean removeUnversionedItems, boolean removeIgnoredItems, boolean includeExternals) throws SVNException { SvnCleanup cleanup = getOperationsFactory().createCleanup(); cleanup.setSingleTarget(SvnTarget.fromFile(path)); cleanup.setDeleteWCProperties(deleteWCProperties); cleanup.setBreakLocks(breakLocks); cleanup.setVacuumPristines(vacuumPristines); cleanup.setRemoveUnversionedItems(removeUnversionedItems); cleanup.setRemoveIgnoredItems(removeIgnoredItems); cleanup.setIncludeExternals(includeExternals); cleanup.run(); }
public void doPatch(File absPatchPath, File localAbsPath, boolean dryRun, int stripCount, boolean ignoreWhitespace, boolean removeTempFiles, boolean reverse) throws SVNException { final SvnPatch patch = getOperationsFactory().createPatch(); patch.setPatchFile(absPatchPath); patch.setStripCount(stripCount); patch.setDryRun(dryRun); patch.setSingleTarget(SvnTarget.fromFile(localAbsPath)); patch.setIgnoreWhitespace(ignoreWhitespace); patch.setRemoveTempFiles(removeTempFiles); patch.setReverse(reverse); patch.run(); }
private void checkout(@NotNull String path, @NotNull SVNDepth depth) throws SVNException { final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl().appendPath(path, true))); checkout.setSingleTarget(SvnTarget.fromFile(wc)); checkout.setRevision(SVNRevision.HEAD); checkout.setDepth(depth); checkout.run(); }
@Test public void checkoutRootRevision() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SvnOperationFactory factory = server.createOperationFactory(); final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl())); checkout.setSingleTarget(SvnTarget.fromFile(server.getTempDirectory())); checkout.setRevision(SVNRevision.create(0)); checkout.run(); } }