public SVNSqlJetStatement getJoinedStatement(String joinedTable) throws SVNException { SVNErrorManager.assertionFailure(false, "unsupported", SVNLogType.WC); return null; }
private int findInstructionIndex(SVNOffsetsIndex offsets, int offset) throws SVNException { int lo = 0; int hi = offsets.length - 1; int op = (lo + hi)/2; SVNErrorManager.assertionFailure(offset < offsets.offsets[offsets.length - 1], null, SVNLogType.DEFAULT); for (; lo < hi; op = (lo + hi)/2 ) { int thisOffset = offsets.offsets[op]; int nextOffset = offsets.offsets[op + 1]; if (offset < thisOffset) { hi = op; } else if (offset > nextOffset) { lo = op; } else { if (offset == nextOffset) { op++; } break; } } SVNErrorManager.assertionFailure(offsets.offsets[op] <= offset && offset < offsets.offsets[op + 1], null, SVNLogType.DEFAULT); return op; }
protected void checkField(int f) throws SVNException { SVNErrorManager.assertionFailure(fields.size() > 0, "fields not defined", SVNLogType.WC); SVNErrorManager.assertionFailure(f >= 0 && f < fields.size(), String.format("%d is not valid field index", f), SVNLogType.WC); SVNErrorManager.assertionFailure(fields.get(f) != null, String.format("field #%d is not defined", f), SVNLogType.WC); }
protected File getPackedRevPath(long revision, String kind) throws SVNException { SVNErrorManager.assertionFailure(myMaxFilesPerDirectory > 0, "max files per directory is 0 or negative: " + String.valueOf(myMaxFilesPerDirectory), SVNLogType.FSFS); SVNErrorManager.assertionFailure(isPackedRevision(revision), "revision " + String.valueOf(revision) + " is not packed", SVNLogType.FSFS); File file = new File(getDBRevsDir(), (revision/myMaxFilesPerDirectory) + PACK_EXT); file = new File(file, kind); return file; }
protected File getRevisionFile(long revision) throws SVNException { SVNErrorManager.assertionFailure(!isPackedRevision(revision), "revision " + String.valueOf(revision) + " is not expected to be packed", SVNLogType.FSFS); File revisionFile = null; if (myMaxFilesPerDirectory > 0) { File shardDir = new File(getDBRevsDir(), String.valueOf(revision/myMaxFilesPerDirectory)); revisionFile = new File(shardDir, String.valueOf(revision)); } else { revisionFile = new File(getDBRevsDir(), String.valueOf(revision)); } return revisionFile; }
private SVNSqlJetStatement prepareStatement(SVNWCDbStatements statementIndex) throws SVNException { final Class<? extends SVNSqlJetStatement> statementClass = statementIndex.getStatementClass(); SVNErrorManager.assertionFailure(statementClass != null, String.format("Statement '%s' not defined", statementIndex.toString()), SVNLogType.WC); if (statementClass == null) { return null; } try { final Constructor<? extends SVNSqlJetStatement> constructor = statementClass.getConstructor(SVNSqlJetDb.class); final SVNSqlJetStatement stmt = constructor.newInstance(this); return stmt; } catch (Exception e) { SVNErrorCode errorCode = SVNErrorCode.UNSUPPORTED_FEATURE; String message = e.getMessage() != null ? e.getMessage() : errorCode.getDescription(); SVNErrorMessage err = SVNErrorMessage.create(errorCode, message, new Object[0], SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, SVNLogType.WC); return null; } }
protected long getPackedOffset(long revision) throws SVNException { //TODO: later on introduce invoking memcache here to fetch\store the requested data //long shard = revision / myMaxFilesPerDirectory; File manifestFile = getPackedRevPath(revision, PACK_KIND_MANIFEST); BufferedReader reader = null; LinkedList manifest = new LinkedList(); try { reader = new BufferedReader(new InputStreamReader(SVNFileUtil.openFileForReading(manifestFile))); String line = null; while ((line = reader.readLine()) != null) { Long offset = null; try { offset = Long.valueOf(line); } catch (NumberFormatException nfe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT); SVNErrorManager.error(err, SVNLogType.FSFS); } manifest.add(offset); } } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(reader); } Long revOffsetLong = (Long) manifest.get((int) (revision % myMaxFilesPerDirectory)); SVNErrorManager.assertionFailure(revOffsetLong != null, "offset for revision " + String.valueOf(revision) + " is null", SVNLogType.FSFS); return revOffsetLong.longValue(); }
public void upgradeAddExternalInfo(File localAbsPath, SVNNodeKind kind, File defLocalAbsPath, File reposRelPath, SVNURL reposRootUrl, String reposUuid, long defPegRevision, long defRevision) throws SVNException { SVNNodeKind dbKind = SVNNodeKind.UNKNOWN; if (kind == SVNNodeKind.DIR) { dbKind = SVNNodeKind.DIR; } else if (kind == SVNNodeKind.FILE) { dbKind = SVNNodeKind.FILE; } else if (kind == SVNNodeKind.UNKNOWN) { dbKind = SVNNodeKind.UNKNOWN; } else { SVNErrorManager.assertionFailure(false, null, SVNLogType.WC); } getWcContext().getDb().upgradeInsertExternal(localAbsPath, dbKind, SVNFileUtil.getParentFile(localAbsPath), defLocalAbsPath, reposRelPath, reposRootUrl, reposUuid, defPegRevision, defRevision); }
protected Map[] getFullMergeInfo(SVNEntry entry, boolean getRecorded, boolean getImplicit, boolean[] indirect, SVNMergeInfoInheritance inherit, SVNRepository repos, File target, long start, long end) throws SVNException { Map[] result = new Map[2]; SVNErrorManager.assertionFailure(SVNRevision.isValidRevisionNumber(start) && SVNRevision.isValidRevisionNumber(end) && start > end, null, SVNLogType.WC); //get recorded merge info if (getRecorded) { result[0] = getWCOrRepositoryMergeInfo(target, entry, inherit, indirect, false, repos); } if (getImplicit) { long[] targetRev = new long[1]; targetRev[0] = SVNRepository.INVALID_REVISION; SVNURL url = deriveLocation(target, null, targetRev, SVNRevision.WORKING, repos, myWCAccess); if (targetRev[0] <= end) { result[1] = new TreeMap(); return result; } Map implicitMergeInfo = calculateImplicitMergeInfo(repos, url, targetRev, start, end); if (implicitMergeInfo != null) { result[1] = implicitMergeInfo; } } return result; }
public void writeDBFormat(int format, long maxFilesPerDir, boolean overwrite) throws SVNException { File formatFile = getDBFormatFile(); SVNErrorManager.assertionFailure(format >= 1 && format <= DB_FORMAT, "unexpected format " + String.valueOf(format), SVNLogType.FSFS); String contents = null; if (format >= LAYOUT_FORMAT_OPTION_MINIMAL_FORMAT) {
SVNErrorManager.assertionFailure(checksum != null, "Checksum should be computed", SVNLogType.FSFS);
public static InputStream readSpecialFile(File localAbsPath) throws SVNException { if (!SVNFileUtil.symlinksSupported()) { return SVNFileUtil.openFileForReading(localAbsPath, SVNLogType.WC); } /* * First determine what type of special file we are detranslating. */ final SVNFileType filetype = SVNFileType.getType(localAbsPath); if (SVNFileType.FILE == filetype) { /* * Nothing special to do here, just create stream from the original * file's contents. */ return SVNFileUtil.openFileForReading(localAbsPath, SVNLogType.WC); } else if (SVNFileType.SYMLINK == filetype) { /* Determine the destination of the link. */ String linkPath = SVNFileUtil.getSymlinkName(localAbsPath); if (linkPath == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot detranslate symbolic link ''{0}''; file does not exist or not a symbolic link", localAbsPath); SVNErrorManager.error(err, SVNLogType.DEFAULT); } String symlinkContents = "link " + linkPath; return new ByteArrayInputStream(symlinkContents.getBytes()); } else { SVNErrorManager.assertionFailure(false, "ERR_MALFUNCTION", SVNLogType.WC); } return null; }
protected Map<String, SVNMergeRangeList>[] getFullMergeInfo(boolean getRecorded, boolean getImplicit, boolean[] inherited, SVNMergeInfoInheritance inherit, SVNRepository repos, File target, long start, long end) throws SVNException { Map<String, SVNMergeRangeList>[] result = new Map[2]; SVNErrorManager.assertionFailure(SVNRevision.isValidRevisionNumber(start) && SVNRevision.isValidRevisionNumber(end) && start > end, null, SVNLogType.WC);
SVNErrorManager.assertionFailure(false, null, SVNLogType.DEFAULT); return tail;
public void commit() throws SVNException { if (openCount > 0) { openCount--; if (isLogTransactions()) { logCall("Commit transaction request (" + openCount + ")", 5); } if (openCount == 0) { try { db.commit(); if (isLogTransactions()) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.DEFAULT, "transaction committed"); } } catch (SqlJetException e) { createSqlJetError(e); } } } else { SVNErrorManager.assertionFailure(openCount > 0, "no opened transactions", SVNLogType.WC); } }
public void runOperation(SVNWCContext ctx, File wcRootAbspath, SVNSkel workItem) throws SVNException { File localRelPath = SVNFileUtil.createFilePath(workItem.first().next().getValue()); File localAbsPath = SVNFileUtil.createFilePath(wcRootAbspath, localRelPath); SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath)); if (kind != SVNNodeKind.NONE && kind != SVNNodeKind.DIR) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_NOT_DIRECTORY, "''{0}'' is not a directory", localAbsPath); SVNErrorManager.error(errorMessage, SVNLogType.WC); } else if (kind == SVNNodeKind.NONE) { SVNFileUtil.ensureDirectoryExists(localAbsPath); } else { SVNErrorManager.assertionFailure(kind == SVNNodeKind.DIR, null, SVNLogType.WC); } } }
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { checkCancelled(); SVNMergeRange range = new SVNMergeRange(logEntry.getRevision() - 1, logEntry.getRevision(), true); SVNMergeRangeList thisRangeList = new SVNMergeRangeList(range); SVNMergeRangeList intersection = thisRangeList.intersect(myRangeList, true); if (intersection == null || intersection.isEmpty()) { return; } SVNErrorManager.assertionFailure(intersection.getSize() == 1, "intersection list size is " + intersection.getSize(), SVNLogType.WC); if (myRealHandler != null) { myRealHandler.handleLogEntry(logEntry); } } }
public void beginTransaction(SqlJetTransactionMode mode) throws SVNException { if (mode != null) { openCount++; if (isLogTransactions()) { logCall("Being transaction request (" + openCount + "): " + mode, 5); } if (isNeedStartTransaction(mode)) { try { db.beginTransaction(mode); if (isLogTransactions()) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.DEFAULT, "transaction started"); } } catch (SqlJetException e) { createSqlJetError(e); } } } else { SVNErrorManager.assertionFailure(mode != null, "transaction mode is null", SVNLogType.WC); } }
InputStream inputStream = null; try { SVNErrorManager.assertionFailure(myHref != null, "myHref is null", SVNLogType.NETWORK); String deltaBaseVersionURL = myPath != null ? (String) myVersionURLs.get(myPath) : null; DeltaOutputStreamWrapper osWrapper = new DeltaOutputStreamWrapper(deltaBaseVersionURL != null, myPath);
SVNErrorManager.assertionFailure(false, null, SVNLogType.WC);