public static long revisionNumber(SVNRevision revision) { if (revision == null || revision == SVNRevision.UNDEFINED) { return SVNWCContext.INVALID_REVNUM; } return revision.getNumber(); }
@Override public SVNRevision[] handleExternal(File externalPath, SVNURL externalURL, SVNRevision externalRevision, SVNRevision externalPegRevision, String externalsDefinition, SVNRevision externalsWorkingRevision) { // When an external has been found, add to externals list. externals.add(new External(externalPath.getAbsolutePath(), externalURL, externalRevision.getNumber())); return new SVNRevision[] {externalRevision, externalPegRevision}; } }
@Override public String getFileVersion(String file) throws Exception { File f = new File(baseDirectory, file); if (!f.exists()) { return null; } SVNInfo info = ourClientManager.getWCClient().doInfo(f, SVNRevision.BASE); Log.logDebug(LOGGER, "SVN committed revision for file {0} is {1}", file, info.getCommittedRevision() .getNumber()); return Long.toString(info.getCommittedRevision().getNumber()); }
private void printInfoItemRevision(SVNRevision revision, String targetPath) { if (SVNRevision.isValidRevisionNumber(revision.getNumber())) { if (targetPath != null) { getSVNEnvironment().getOut().printf("%s %s", revision.getNumber(), targetPath); } else { getSVNEnvironment().getOut().printf("%s", revision.getNumber()); } } else if (targetPath != null) { getSVNEnvironment().getOut().printf("%s %s", "", targetPath); } }
private void printInfoItemRevision(SVNRevision revision, String targetPath) { if (SVNRevision.isValidRevisionNumber(revision.getNumber())) { if (targetPath != null) { getSVNEnvironment().getOut().printf("%s %s", revision.getNumber(), targetPath); } else { getSVNEnvironment().getOut().printf("%s", revision.getNumber()); } } else if (targetPath != null) { getSVNEnvironment().getOut().printf("%s %s", "", targetPath); } }
/** * Determines if the revision represented by this abstract object is * Working Copy specific - that is one of {@link #BASE} or {@link #WORKING}. * * @return <span class="javakeyword">true</span> if this object represents * a kind of a local revision, otherwise <span class="javakeyword">false</span> */ public boolean isLocal() { boolean remote = !isValid() || this == SVNRevision.HEAD || getNumber() >= 0 || getDate() != null; return !remote; }
/** * Determines if the revision represented by this abstract object is * Working Copy specific - that is one of {@link #BASE} or {@link #WORKING}. * * @return <span class="javakeyword">true</span> if this object represents * a kind of a local revision, otherwise <span class="javakeyword">false</span> */ public boolean isLocal() { boolean remote = !isValid() || this == SVNRevision.HEAD || getNumber() >= 0 || getDate() != null; return !remote; }
/** * Determines if the revision represented by this abstract object is * Working Copy specific - that is one of {@link #BASE} or {@link #WORKING}. * * @return <span class="javakeyword">true</span> if this object represents * a kind of a local revision, otherwise <span class="javakeyword">false</span> */ public boolean isLocal() { boolean remote = !isValid() || this == SVNRevision.HEAD || getNumber() >= 0 || getDate() != null; return !remote; }
/** * Determines if the revision represented by this abstract object is * Working Copy specific - that is one of {@link #BASE} or {@link #WORKING}. * * @return <span class="javakeyword">true</span> if this object represents * a kind of a local revision, otherwise <span class="javakeyword">false</span> */ public boolean isLocal() { boolean remote = !isValid() || this == SVNRevision.HEAD || getNumber() >= 0 || getDate() != null; return !remote; }
/** * @param modulePath The root of the current module that svn was checking out when it hits 'ext'. * Since we call svnkit multiple times in general case to check out from multiple locations, * we use this to make the path relative to the entire workspace, not just the particular module. */ public External(String modulePath, SVNExternal ext) { this.path = modulePath + '/' + ext.getPath(); this.url = ext.getResolvedURL().toDecodedString(); this.revision = ext.getRevision().getNumber(); }
/** * @param modulePath The root of the current module that svn was checking out when it hits 'ext'. * Since we call svnkit multiple times in general case to check out from multiple locations, * we use this to make the path relative to the entire workspace, not just the particular module. */ public External(String modulePath, SVNExternal ext) { this.path = modulePath + '/' + ext.getPath(); this.url = ext.getResolvedURL().toDecodedString(); this.revision = ext.getRevision().getNumber(); }
@Override public long getRepositoryRevision(SVNRepository repository, SVNURL url) { try { SVNInfo info = getWCClient(repository).doInfo(url, SVNRevision.HEAD, SVNRevision.HEAD); return info.getCommittedRevision().getNumber(); } catch (SVNException e) { throw translateSVNException(e); } }
public static String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
private String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
private String asString(SVNRevision revision, String path) throws SVNException { if (revision == SVNRevision.HEAD || SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revision.toString(); } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Illegal file external revision kind {0} for path ''{1}''", new Object[] { revision.toString(), path }); SVNErrorManager.error(err, SVNLogType.WC); return null; }
protected void doVirtualCopy(SVNEntry dstEntry, SVNCopySource copySource, boolean save) throws SVNException { dstEntry.setCopyFromURL(copySource.getURL().toString()); long cfRevision = copySource.getRevision().getNumber(); dstEntry.setCopyFromRevision(cfRevision); if (save) { SVNAdminArea dir = dstEntry.getAdminArea(); dir.saveEntries(false); } }
private SVNReference getReference(SVNRepository repository, String path, SVNRevision revision) { String url = repository.getUrl(path); SVNURL svnurl = SVNUtils.toURL(url); SVNInfo info = getInfo(repository, svnurl, revision); return new SVNReference( path, url, info.getRevision().getNumber(), Time.from(info.getCommittedDate(), null) ); }
@Test public void testGetRevisionFromTimestamp() { UpdateTask updateTask = createUpdateTask(); ModuleLocation l = new ModuleLocation("remote", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(NOW, revision.getDate()); assertEquals(-1L, revision.getNumber()); }
@Test public void testRevisionInUrlOverridesEverything() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@12345", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(12345L, revision.getNumber()); assertNull(revision.getDate()); }
@Test public void testRevisionInUrlOverridesEverything_HEAD() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote@HEAD", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(SVNRevision.HEAD.getName(), revision.getName()); assertEquals(-1L, revision.getNumber()); assertNull(revision.getDate()); }