Class SVNPatchTarget
java.lang.Object
org.tmatesoft.svn.core.internal.wc.patch.SVNPatchTarget
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Fileprivate booleanprivate Fileprivate intprivate booleanprivate booleanprivate Stringprivate Stringprivate booleanprivate RandomAccessFileprivate booleanprivate Listprivate Mapprivate SVNNodeKindprivate Listprivate booleanprivate static final intprivate booleanprivate booleanprivate SVNPatchprivate OutputStreamprivate Fileprivate OutputStreamprivate SVNPatchFileStreamprivate Fileprivate Fileprivate booleanprivate SVNPatchFileStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidWrite the modified text of hunk described by HI to the patched stream of TARGET.static SVNPatchTargetapplyPatch(SVNPatch patch, File absWCPath, int stripCount, SVNAdminArea wc) Apply a PATCH to a working copy at ABS_WC_PATH.voidcopyLinesToTarget(int line) Copy lines to the patched stream until the specified LINE has been reached.static String[]decomposePath(File path) private static StringDetect the EOL marker used in file and return it.private FilegetChildPath(File basePath, File childPath) intgetFile()getHunkInfo(SVNPatchHunk hunk, int fuzz) Determine the line at which a HUNK applies to the TARGET file, and return an appropriate hunk_info object in *HI, allocated from RESULT_POOL.getHunks()getKind()getLines()getPatch()static SVNPatchTargetinitPatchTarget(SVNPatch patch, File baseDir, int stripCount, SVNAdminArea wc) Attempt to initialize a patch TARGET structure for a target file described by PATCH.voidinstallPatchedTarget(File absWCPath, boolean dryRun, SVNAdminArea wc) Install a patched TARGET into the working copy at ABS_WC_PATH.booleanisAdded()static booleanisChildPath(File baseFile, File file) booleanbooleanisEof()booleanbooleanbooleanbooleanbooleanbooleanprivate booleanmatchHunk(SVNPatchHunk hunk, int fuzz) Indicate in *MATCHED whether the original text of HUNK matches the patch TARGET at its current line.voidreadLine(StringBuffer line) Read a *LINE from TARGET.voidWrite the diff text of the hunk described by HI to the reject stream of TARGET, and mark TARGET as having had rejects.private voidresolveTargetPath(File pathFromPatchfile, File absWCPath, int stripCount, SVNAdminArea wc) Resolve the exact path for a patch TARGET at path PATH_FROM_PATCHFILE, which is the path of the target as it appeared in the patch file.intscanForMatch(SVNPatchHunk hunk, boolean matchFirst, int upperLine, int fuzz) Scan lines of TARGET for a match of the original text of HUNK, up to but not including the specified UPPER_LINE.voidseekToLine(int line) Seek to the specified LINE in TARGET.voidUse client context CTX to send a suitable notification for a patch TARGET.static Fileprivate voidtryWrite(OutputStream stream, StringBuffer buffer) Attempt to write LEN bytes of DATA to STREAM, the underlying file of which is at ABSPATH.
-
Field Details
-
MAX_FUZZ
private static final int MAX_FUZZ- See Also:
-
patch
-
lines
-
hunks
-
localMods
private boolean localMods -
executable
private boolean executable -
skipped
private boolean skipped -
eolStr
-
keywords
-
eolStyle
-
kind
-
currentLine
private int currentLine -
modified
private boolean modified -
hadRejects
private boolean hadRejects -
deleted
private boolean deleted -
eof
private boolean eof -
added
private boolean added -
absPath
-
relPath
-
canonPathFromPatchfile
-
file
-
stream
-
patchedPath
-
patchedRaw
-
patched
-
rejectPath
-
reject
-
parentDirExists
private boolean parentDirExists
-
-
Constructor Details
-
SVNPatchTarget
private SVNPatchTarget()
-
-
Method Details
-
isLocalMods
public boolean isLocalMods() -
getEolStr
-
getKeywords
-
getEolStyle
-
getFile
-
getPatchedRaw
-
getCanonPathFromPatchfile
-
getPatch
-
getCurrentLine
public int getCurrentLine() -
isModified
public boolean isModified() -
isEof
public boolean isEof() -
getLines
-
isSkipped
public boolean isSkipped() -
getHunks
-
getKind
-
getStream
-
getPatched
-
getReject
-
getPatchedPath
-
isAdded
public boolean isAdded() -
isDeleted
public boolean isDeleted() -
isExecutable
public boolean isExecutable() -
getRejectPath
-
getAbsPath
-
getRelPath
-
isHadRejects
public boolean isHadRejects() -
isParentDirExists
public boolean isParentDirExists() -
initPatchTarget
public static SVNPatchTarget initPatchTarget(SVNPatch patch, File baseDir, int stripCount, SVNAdminArea wc) throws SVNException, IOException Attempt to initialize a patch TARGET structure for a target file described by PATCH. Use client context CTX to send notifiations and retrieve WC_CTX. STRIP_COUNT specifies the number of leading path components which should be stripped from target paths in the patch. Upon success, return the patch target structure. Else, return NULL.- Throws:
SVNExceptionIOException
-
detectFileEOL
Detect the EOL marker used in file and return it. If it cannot be detected, return NULL. The file is searched starting at the current file cursor position. The first EOL marker found will be returnd. So if the file has inconsistent EOL markers, this won't be detected. Upon return, the original file cursor position is always preserved, even if an error is thrown.- Throws:
IOException
-
resolveTargetPath
private void resolveTargetPath(File pathFromPatchfile, File absWCPath, int stripCount, SVNAdminArea wc) throws SVNException, IOException Resolve the exact path for a patch TARGET at path PATH_FROM_PATCHFILE, which is the path of the target as it appeared in the patch file. Put a canonicalized version of PATH_FROM_PATCHFILE into TARGET->CANON_PATH_FROM_PATCHFILE. WC_CTX is a context for the working copy the patch is applied to. If possible, determine TARGET->WC_PATH, TARGET->ABS_PATH, TARGET->KIND, TARGET->ADDED, and TARGET->PARENT_DIR_EXISTS. Indicate in TARGET->SKIPPED whether the target should be skipped. STRIP_COUNT specifies the number of leading path components which should be stripped from target paths in the patch.- Throws:
SVNExceptionIOException
-
isChildPath
- Throws:
IOException
-
getChildPath
- Throws:
IOException
-
stripPath
-
rejectHunk
Write the diff text of the hunk described by HI to the reject stream of TARGET, and mark TARGET as having had rejects.- Throws:
IOExceptionSVNException
-
applyHunk
Write the modified text of hunk described by HI to the patched stream of TARGET.- Throws:
SVNExceptionIOException
-
seekToLine
Seek to the specified LINE in TARGET. Mark any lines not read before in TARGET->LINES.- Throws:
SVNExceptionIOException
-
readLine
Read a *LINE from TARGET. If the line has not been read before mark the line in TARGET->LINES.- Throws:
SVNExceptionIOException
-
copyLinesToTarget
Copy lines to the patched stream until the specified LINE has been reached. Indicate in *EOF whether end-of-file was encountered while reading from the target. If LINE is zero, copy lines until end-of-file has been reached.- Throws:
IOExceptionSVNException
-
installPatchedTarget
public void installPatchedTarget(File absWCPath, boolean dryRun, SVNAdminArea wc) throws SVNException Install a patched TARGET into the working copy at ABS_WC_PATH. Use client context CTX to retrieve WC_CTX, and possibly doing notifications. If DRY_RUN is TRUE, don't modify the working copy.- Throws:
SVNException
-
decomposePath
-
applyPatch
public static SVNPatchTarget applyPatch(SVNPatch patch, File absWCPath, int stripCount, SVNAdminArea wc) throws SVNException, IOException Apply a PATCH to a working copy at ABS_WC_PATH. STRIP_COUNT specifies the number of leading path components which should be stripped from target paths in the patch.- Throws:
SVNExceptionIOException
-
getHunkInfo
Determine the line at which a HUNK applies to the TARGET file, and return an appropriate hunk_info object in *HI, allocated from RESULT_POOL. Use fuzz factor FUZZ. Set HI->FUZZ to FUZZ. If no correct line can be determined, set HI->REJECTED to TRUE. When this function returns, neither TARGET->CURRENT_LINE nor the file offset in the target file will have changed.- Throws:
SVNExceptionIOException
-
scanForMatch
public int scanForMatch(SVNPatchHunk hunk, boolean matchFirst, int upperLine, int fuzz) throws SVNException, IOException Scan lines of TARGET for a match of the original text of HUNK, up to but not including the specified UPPER_LINE. Use fuzz factor FUZZ. If UPPER_LINE is zero scan until EOF occurs when reading from TARGET. Return the line at which HUNK was matched in *MATCHED_LINE. If the hunk did not match at all, set *MATCHED_LINE to zero. If the hunk matched multiple times, and MATCH_FIRST is TRUE, return the line number at which the first match occured in *MATCHED_LINE. If the hunk matched multiple times, and MATCH_FIRST is FALSE, return the line number at which the last match occured in *MATCHED_LINE.- Throws:
SVNExceptionIOException
-
matchHunk
Indicate in *MATCHED whether the original text of HUNK matches the patch TARGET at its current line. Lines within FUZZ lines of the start or end of HUNK will always match. When this function returns, neither TARGET->CURRENT_LINE nor the file offset in the target file will have changed. HUNK->ORIGINAL_TEXT will be reset.- Throws:
SVNExceptionIOException
-
tryWrite
Attempt to write LEN bytes of DATA to STREAM, the underlying file of which is at ABSPATH. Fail if not all bytes could be written to the stream.- Throws:
IOException
-
sendPatchNotification
Use client context CTX to send a suitable notification for a patch TARGET.- Throws:
SVNException
-