/** * 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 String formatRevisionString(String revisionPrefix, SVNRevision revision) { if (revision == null) { return null; } else if (revision == SVNRevision.HEAD) { return revisionPrefix + "HEAD"; } else if (revision.getDate() != null) { return revisionPrefix + "{" + SVNDate.formatDate(revision.getDate(), true) + "}"; } else if (SVNRevision.isValidRevisionNumber(revision.getNumber())) { return revisionPrefix + revision.getNumber(); } else { return null; } }
/** * 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; }
/** * Compares this object with another <b>SVNRevision</b> object. * * @param o an object to be compared with; if it's not an * <b>SVNRevision</b> then this method certainly returns * <span class="javakeyword">false</span> * @return <span class="javakeyword">true</span> if equal, otherwise * <span class="javakeyword">false</span> */ public boolean equals(Object o) { if (o == null || o.getClass() != SVNRevision.class) { return false; } SVNRevision r = (SVNRevision) o; if (myRevision >= 0) { return myRevision == r.getNumber(); } else if (myDate != null) { return myDate.equals(r.getDate()); } else if (myName != null) { return myName.equals(r.getName()); } return !r.isValid(); }
protected String checkRevPropTarget(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } return (String) targets.iterator().next(); }
/** * Compares this object with another <b>SVNRevision</b> object. * * @param o an object to be compared with; if it's not an * <b>SVNRevision</b> then this method certainly returns * <span class="javakeyword">false</span> * @return <span class="javakeyword">true</span> if equal, otherwise * <span class="javakeyword">false</span> */ public boolean equals(Object o) { if (o == null || o.getClass() != SVNRevision.class) { return false; } SVNRevision r = (SVNRevision) o; if (myRevision >= 0) { return myRevision == r.getNumber(); } else if (myDate != null) { return myDate.equals(r.getDate()); } else if (myName != null) { return myName.equals(r.getName()); } return !r.isValid(); }
protected String checkRevPropTarget(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } return (String) targets.iterator().next(); }
protected SVNURL getRevpropURL(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } String target = (String) targets.iterator().next(); return getSVNEnvironment().getURLFromTarget(target); }
public static long getRevisionNumber(SVNRevision revision, long youngestRevision, FSFS fsfs) throws SVNException { long revNumber = -1; if (revision.getNumber() >= 0) { revNumber = revision.getNumber(); } else if (revision == SVNRevision.HEAD) { revNumber = youngestRevision; } else if (revision.getDate() != null) { revNumber = fsfs.getDatedRevision(revision.getDate()); } else if (revision != SVNRevision.UNDEFINED) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision specifier"); SVNErrorManager.error(err, SVNLogType.FSFS); } if (revNumber > youngestRevision) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Revisions must not be greater than the youngest revision ({0})", new Long(youngestRevision)); SVNErrorManager.error(err, SVNLogType.FSFS); } return revNumber; }
protected SVNURL getRevpropURL(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } String target = (String) targets.iterator().next(); return getSVNEnvironment().getURLFromTarget(target); }
public static long getRevisionNumber(SVNRevision revision, long youngestRevision, FSFS fsfs) throws SVNException { long revNumber = -1; if (revision.getNumber() >= 0) { revNumber = revision.getNumber(); } else if (revision == SVNRevision.HEAD) { revNumber = youngestRevision; } else if (revision.getDate() != null) { revNumber = fsfs.getDatedRevision(revision.getDate()); } else if (revision != SVNRevision.UNDEFINED) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision specifier"); SVNErrorManager.error(err, SVNLogType.FSFS); } if (revNumber > youngestRevision) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Revisions must not be greater than the youngest revision ({0})", new Long(youngestRevision)); SVNErrorManager.error(err, SVNLogType.FSFS); } return revNumber; }
public static long getRevisionNumber(SVNRevision revision, long youngestRevision, FSFS fsfs) throws SVNException { long revNumber = -1; if (revision.getNumber() >= 0) { revNumber = revision.getNumber(); } else if (revision == SVNRevision.HEAD) { revNumber = youngestRevision; } else if (revision.getDate() != null) { revNumber = fsfs.getDatedRevision(revision.getDate()); } else if (revision != SVNRevision.UNDEFINED) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision specifier"); SVNErrorManager.error(err, SVNLogType.FSFS); } if (revNumber > youngestRevision) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Revisions must not be greater than the youngest revision ({0})", new Long(youngestRevision)); SVNErrorManager.error(err, SVNLogType.FSFS); } return revNumber; }
protected long getRevisionNumber(SVNRevision rev, long latestRevision, SVNRepository repos) throws SVNException { long result = -1; if (rev.getNumber() >= 0) { result = rev.getNumber(); } else if (rev == SVNRevision.HEAD) { result = latestRevision; } else if (rev.getDate() != null) { result = repos.getDatedRevision(rev.getDate()); } else if (rev != SVNRevision.UNDEFINED) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision specifier"), SVNLogType.CLIENT); } if (result > latestRevision) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Revisions must not be greater than the youngest revision (" + latestRevision + ")"), SVNLogType.CLIENT); } return result; }
protected long getRevisionNumber(SVNRevision rev, long latestRevision, SVNRepository repos) throws SVNException { long result = -1; if (rev.getNumber() >= 0) { result = rev.getNumber(); } else if (rev == SVNRevision.HEAD) { result = latestRevision; } else if (rev.getDate() != null) { result = repos.getDatedRevision(rev.getDate()); } else if (rev != SVNRevision.UNDEFINED) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Invalid revision specifier"), SVNLogType.CLIENT); } if (result > latestRevision) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Revisions must not be greater than the youngest revision (" + latestRevision + ")"), SVNLogType.CLIENT); } return result; }
@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 testRevisionFromRevisionParametersOverrideTimestamp() { UpdateTask updateTask = createUpdateTask(); updateTask.revisions = new RevisionParameterAction(new SubversionSCM.SvnInfo("remote", 4711)); ModuleLocation l = new ModuleLocation("remote", "local"); SVNRevision revision = updateTask.getRevision(l); assertEquals(4711L, revision.getNumber()); assertNull(revision.getDate()); }
@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()); }