protected SVNRevision[] resolveRevisions(SVNRevision pegRevision, SVNRevision revision, boolean isURL, boolean noticeLocalModifications) { if (!pegRevision.isValid()) { if (isURL) { pegRevision = SVNRevision.HEAD; } else { if (noticeLocalModifications) { pegRevision = SVNRevision.WORKING; } else { pegRevision = SVNRevision.BASE; } } } if (!revision.isValid()) { revision = pegRevision; } return new SVNRevision[] { pegRevision, revision }; }
protected SVNRevision[] resolveRevisions(SVNRevision pegRevision, SVNRevision revision, boolean isURL, boolean noticeLocalModifications) { if (!pegRevision.isValid()) { if (isURL) { pegRevision = SVNRevision.HEAD; } else { if (noticeLocalModifications) { pegRevision = SVNRevision.WORKING; } else { pegRevision = SVNRevision.BASE; } } } if (!revision.isValid()) { revision = pegRevision; } return new SVNRevision[] { pegRevision, revision }; }
protected SVNRevision[] resolveRevisions(SVNRevision pegRevision, SVNRevision revision, boolean isURL, boolean noticeLocalModifications) { if (!pegRevision.isValid()) { if (isURL) { pegRevision = SVNRevision.HEAD; } else { if (noticeLocalModifications) { pegRevision = SVNRevision.WORKING; } else { pegRevision = SVNRevision.BASE; } } } if (!revision.isValid()) { revision = pegRevision; } return new SVNRevision[] { pegRevision, revision }; }
protected SVNRevision[] resolveRevisions(SVNRevision pegRevision, SVNRevision revision, boolean isURL, boolean noticeLocalModifications) { if (!pegRevision.isValid()) { if (isURL) { pegRevision = SVNRevision.HEAD; } else { if (noticeLocalModifications) { pegRevision = SVNRevision.WORKING; } else { pegRevision = SVNRevision.BASE; } } } if (!revision.isValid()) { revision = pegRevision; } return new SVNRevision[] { pegRevision, revision }; }
private static String getUrlWithoutRevision( String remoteUrlPossiblyWithRevision) { int idx = remoteUrlPossiblyWithRevision.lastIndexOf('@'); if (idx > 0) { String n = remoteUrlPossiblyWithRevision.substring(idx + 1); SVNRevision r = SVNRevision.parse(n); if ((r != null) && (r.isValid())) { return remoteUrlPossiblyWithRevision.substring(0, idx); } } return remoteUrlPossiblyWithRevision; }
/** * Cuts off any optional '@revisionnr' and slashes from the end of the url string. */ public static String getUrlWithoutRevision(String remoteUrlPossiblyWithRevision) { int idx = remoteUrlPossiblyWithRevision.lastIndexOf('@'); int slashIdx = remoteUrlPossiblyWithRevision.lastIndexOf('/'); // Substitute optional '@revisionnr' String substititedString = remoteUrlPossiblyWithRevision; if (idx > 0 && idx > slashIdx) { String n = remoteUrlPossiblyWithRevision.substring(idx + 1); SVNRevision r = SVNRevision.parse(n); if ((r != null) && (r.isValid())) { substititedString = remoteUrlPossiblyWithRevision.substring(0, idx); } } // Substitute slashes at the end substititedString = substititedString.replaceAll(REGEX_END_SLASHES, ""); return substititedString; } }
/** * 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; }
private void ensureRevisionIsValid(SVNRevision revision) throws SVNException { final boolean revisionIsValid = revision != null && revision.isValid(); if (!revisionIsValid) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION, "Not all required revisions are specified"); SVNErrorManager.error(err, SVNLogType.DEFAULT); } }
/** * 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; }
static String getUrlWithoutRevision( String remoteUrlPossiblyWithRevision) { String remoteUrlWithoutRevision = remoteUrlPossiblyWithRevision; if (Hudson.getInstance() != null) { for (NodeProperty n: Hudson.getInstance().getGlobalNodeProperties()) { EnvironmentVariablesNodeProperty gnp = (EnvironmentVariablesNodeProperty)n; for (Entry e : gnp.getEnvVars().entrySet()) { if (remoteUrlWithoutRevision.contains("${" + e.getKey().toString() + "}")) { remoteUrlWithoutRevision = remoteUrlWithoutRevision.replace("${" + e.getKey().toString() + "}", e.getValue().toString()); } } } } int idx = remoteUrlWithoutRevision.lastIndexOf('@'); if (idx > 0) { String n = remoteUrlWithoutRevision.substring(idx + 1); SVNRevision r = SVNRevision.parse(n); if ((r != null) && (r.isValid())) { return remoteUrlWithoutRevision.substring(0, idx); } } return remoteUrlWithoutRevision; }
private FSFS open(File repositoryRoot, SVNRevision revision) throws SVNException { if (revision == null || !revision.isValid()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision number supplied"); SVNErrorManager.error(err, SVNLogType.FSFS); } return SVNAdminHelper.openRepository(repositoryRoot, true); }
private FSFS open(File repositoryRoot, SVNRevision revision) throws SVNException { if (revision == null || !revision.isValid()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision number supplied"); SVNErrorManager.error(err, SVNLogType.FSFS); } return SVNAdminHelper.openRepository(repositoryRoot, true); }
private SvnCopySource(SvnTarget source, SVNRevision revision) { setSource(source); if (revision == null || !revision.isValid()) { revision = source.getResolvedPegRevision(); } setRevision(revision); }
private FSFS open(File repositoryRoot, SVNRevision revision) throws SVNException { if (revision == null || !revision.isValid()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision number supplied"); SVNErrorManager.error(err, SVNLogType.FSFS); } return SVNAdminHelper.openRepository(repositoryRoot, true); }
@Override protected void ensureArgumentsAreValid() throws SVNException { if (getDepth() == SVNDepth.UNKNOWN) { setDepth(SVNDepth.EMPTY); } if (getRevision() == null || !getRevision().isValid()) { if (getFirstTarget() != null) { setRevision(getFirstTarget().getResolvedPegRevision()); } } super.ensureArgumentsAreValid(); }
@Override protected void ensureArgumentsAreValid() throws SVNException { if (getFirstTarget().getPegRevision() == null || getFirstTarget().getPegRevision() == SVNRevision.UNDEFINED) { if (getRevision() == null || !getRevision().isValid()) { setRevision(hasRemoteTargets() ? SVNRevision.HEAD : SVNRevision.WORKING); } } else { // TODO: should we add setRevision(getFirstTarget().getPegRevision()); ? currently everything is working without this line } if (getDepth() == null || getDepth() == SVNDepth.UNKNOWN) { setDepth(SVNDepth.EMPTY); } super.ensureArgumentsAreValid(); }
/** * Test parsing of @revision information from the tail of the URL */ @Test public void moduleLocationRevisions() throws Exception { SubversionSCM.ModuleLocation m = new SubversionSCM.ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@13000", null); SVNRevision r = m.getRevision(null); assertTrue(r.isValid()); assertEquals(13000, r.getNumber()); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", m.getURL()); m = new SubversionSCM.ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@HEAD", null); r = m.getRevision(null); assertTrue(r.isValid()); assertSame(r, SVNRevision.HEAD); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant", m.getURL()); m = new SubversionSCM.ModuleLocation("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@FAKE", null); r = m.getRevision(null); assertFalse(r.isValid()); assertEquals("https://svn.jenkins-ci.org/trunk/hudson/test-projects/trivial-ant@FAKE", m.getURL()); }
@Override protected SVNProperties run() throws SVNException { SVNRevision revision = getOperation().getRevision(); if (!revision.isValid()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION, "Valid revision have to be specified to fetch revision property"); SVNErrorManager.error(err, SVNLogType.DEFAULT); } SvnRepositoryAccess access = getRepositoryAccess(); Structure<RepositoryInfo> repositoryInfo = access.createRepositoryFor(getOperation().getFirstTarget(), SVNRevision.HEAD, SVNRevision.HEAD, null); SVNRepository repository = repositoryInfo.get(RepositoryInfo.repository); repositoryInfo.release(); Structure<RevisionsPair> revPair = access.getRevisionNumber(repository, getOperation().getFirstTarget(), getOperation().getRevision(), null); long revNumber = revPair.lng(RevisionsPair.revNumber); getOperation().setRevisionNumber(revNumber); SVNProperties revisionProperties = repository.getRevisionProperties(revNumber, null); if (revisionProperties != null) { getOperation().receive(getOperation().getFirstTarget(), revisionProperties); } return revisionProperties; }