Package org.eclipse.jgit.dircache
Class DirCacheCheckout
- java.lang.Object
-
- org.eclipse.jgit.dircache.DirCacheCheckout
-
public class DirCacheCheckout extends Object
This class handles checking out one or two trees merging with the index.
-
-
Constructor Summary
Constructors Constructor Description DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree)Constructs a DirCacheCeckout for checking out one tree, merging with the index.DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree)Constructs a DirCacheCeckout for checking out one tree, merging with the index.DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree)Constructs a DirCacheCeckout for merging and checking out two trees (HEAD and mergeCommitTree) and the index.DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree)Constructs a DirCacheCeckout for merging and checking out two trees (HEAD and mergeCommitTree) and the index.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancheckout()Execute this checkoutstatic voidcheckoutEntry(Repository repository, File f, DirCacheEntry entry)Deprecated.Use the overloaded form that acceptsObjectReader.static voidcheckoutEntry(Repository repo, File f, DirCacheEntry entry, ObjectReader or)Deprecated.Do not pass File object.static voidcheckoutEntry(Repository repo, DirCacheEntry entry, ObjectReader or)Updates the file in the working tree with content and mode from an entry in the index.static voidcheckValidPath(String path)Deprecated.List<String>getConflicts()List<String>getRemoved()List<String>getToBeDeleted()Map<String,ObjectId>getUpdated()voidprescanOneTree()Scan index and merge tree (no HEAD).voidpreScanTwoTrees()Scan head, index and merge tree.voidsetFailOnConflict(boolean failOnConflict)Iftrue, will scan first to see if it's possible to check out, otherwise throwCheckoutConflictException.
-
-
-
Constructor Detail
-
DirCacheCheckout
public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree) throws IOException
Constructs a DirCacheCeckout for merging and checking out two trees (HEAD and mergeCommitTree) and the index.- Parameters:
repo- the repository in which we do the checkoutheadCommitTree- the id of the tree of the head commitdc- the (already locked) Dircache for this repomergeCommitTree- the id of the tree we want to fast-forward toworkingTree- an iterator over the repositories Working Tree- Throws:
IOException
-
DirCacheCheckout
public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree) throws IOException
Constructs a DirCacheCeckout for merging and checking out two trees (HEAD and mergeCommitTree) and the index. As iterator over the working tree this constructor creates a standardFileTreeIterator- Parameters:
repo- the repository in which we do the checkoutheadCommitTree- the id of the tree of the head commitdc- the (already locked) Dircache for this repomergeCommitTree- the id of the tree we want to fast-forward to- Throws:
IOException
-
DirCacheCheckout
public DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree) throws IOException
Constructs a DirCacheCeckout for checking out one tree, merging with the index.- Parameters:
repo- the repository in which we do the checkoutdc- the (already locked) Dircache for this repomergeCommitTree- the id of the tree we want to fast-forward toworkingTree- an iterator over the repositories Working Tree- Throws:
IOException
-
DirCacheCheckout
public DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree) throws IOException
Constructs a DirCacheCeckout for checking out one tree, merging with the index. As iterator over the working tree this constructor creates a standardFileTreeIterator- Parameters:
repo- the repository in which we do the checkoutdc- the (already locked) Dircache for this repomergeCommitTree- the id of the tree of the- Throws:
IOException
-
-
Method Detail
-
getConflicts
public List<String> getConflicts()
- Returns:
- a list of conflicts created by this checkout
-
getToBeDeleted
public List<String> getToBeDeleted()
- Returns:
- a list of paths (relative to the start of the working tree) of
files which couldn't be deleted during last call to
checkout().checkout()detected that these files should be deleted but the deletion in the filesystem failed (e.g. because a file was locked). To have a consistent state of the working tree these files have to be deleted by the callers ofDirCacheCheckout.
-
preScanTwoTrees
public void preScanTwoTrees() throws CorruptObjectException, IOExceptionScan head, index and merge tree. Used during normal checkout or merge operations.- Throws:
CorruptObjectExceptionIOException
-
prescanOneTree
public void prescanOneTree() throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOExceptionScan index and merge tree (no HEAD). Used e.g. for initial checkout when there is no head yet.
-
checkout
public boolean checkout() throws IOExceptionExecute this checkout- Returns:
falseif this method could not delete all the files which should be deleted (e.g. because of of the files was locked). In this casegetToBeDeleted()lists the files which should be tried to be deleted outside of this method. Althoughfalseis returned the checkout was successful and the working tree was updated for all other files.trueis returned when no such problem occurred- Throws:
IOException
-
setFailOnConflict
public void setFailOnConflict(boolean failOnConflict)
Iftrue, will scan first to see if it's possible to check out, otherwise throwCheckoutConflictException. Iffalse, it will silently deal with the problem.- Parameters:
failOnConflict-
-
checkoutEntry
@Deprecated public static void checkoutEntry(Repository repository, File f, DirCacheEntry entry) throws IOException
Deprecated.Use the overloaded form that acceptsObjectReader.Updates the file in the working tree with content and mode from an entry in the index. The new content is first written to a new temporary file in the same directory as the real file. Then that new file is renamed to the final filename. Use this method only for checkout of a single entry. Otherwise usecheckoutEntry(Repository, File f, DirCacheEntry, ObjectReader)instead which allows to reuse oneObjectReaderfor multiple entries.TODO: this method works directly on File IO, we may need another abstraction (like WorkingTreeIterator). This way we could tell e.g. Eclipse that Files in the workspace got changed
- Parameters:
repository-f- this parameter is ignored.entry- the entry containing new mode and content- Throws:
IOException
-
checkoutEntry
@Deprecated public static void checkoutEntry(Repository repo, File f, DirCacheEntry entry, ObjectReader or) throws IOException
Deprecated.Do not pass File object.Updates the file in the working tree with content and mode from an entry in the index. The new content is first written to a new temporary file in the same directory as the real file. Then that new file is renamed to the final filename.TODO: this method works directly on File IO, we may need another abstraction (like WorkingTreeIterator). This way we could tell e.g. Eclipse that Files in the workspace got changed
- Parameters:
repo-f- this parameter is ignored.entry- the entry containing new mode and contentor- object reader to use for checkout- Throws:
IOException
-
checkoutEntry
public static void checkoutEntry(Repository repo, DirCacheEntry entry, ObjectReader or) throws IOException
Updates the file in the working tree with content and mode from an entry in the index. The new content is first written to a new temporary file in the same directory as the real file. Then that new file is renamed to the final filename.TODO: this method works directly on File IO, we may need another abstraction (like WorkingTreeIterator). This way we could tell e.g. Eclipse that Files in the workspace got changed
- Parameters:
repo- repository managing the destination work tree.entry- the entry containing new mode and contentor- object reader to use for checkout- Throws:
IOException- Since:
- 3.6
-
checkValidPath
@Deprecated public static void checkValidPath(String path) throws InvalidPathException
Deprecated.Check if path is a valid path for a checked out file name or ref name.- Parameters:
path-- Throws:
InvalidPathException- if the path is invalid- Since:
- 3.3
-
-