public class DirCacheCheckout extends Object
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkout()
Execute this checkout
|
static void |
checkoutEntry(Repository repository,
File f,
DirCacheEntry entry)
Updates the file in the working tree with content and mode from an entry
in the index.
|
static void |
checkoutEntry(Repository repo,
File f,
DirCacheEntry entry,
ObjectReader or)
Updates the file in the working tree with content and mode from an entry
in the index.
|
List<String> |
getConflicts() |
List<String> |
getRemoved() |
List<String> |
getToBeDeleted() |
Map<String,ObjectId> |
getUpdated() |
void |
prescanOneTree()
Scan index and merge tree (no HEAD).
|
void |
preScanTwoTrees()
Scan head, index and merge tree.
|
void |
setFailOnConflict(boolean failOnConflict)
If
true , will scan first to see if it's possible to check
out, otherwise throw CheckoutConflictException . |
public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree) throws IOException
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 TreeIOException
public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc, ObjectId mergeCommitTree) throws IOException
FileTreeIterator
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 toIOException
public DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree, WorkingTreeIterator workingTree) throws IOException
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 TreeIOException
public DirCacheCheckout(Repository repo, DirCache dc, ObjectId mergeCommitTree) throws IOException
FileTreeIterator
repo
- the repository in which we do the checkoutdc
- the (already locked) Dircache for this repomergeCommitTree
- the id of the tree of theIOException
public List<String> getConflicts()
public List<String> getToBeDeleted()
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 of
DirCacheCheckout
.public void preScanTwoTrees() throws CorruptObjectException, IOException
CorruptObjectException
IOException
public void prescanOneTree() throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException
public boolean checkout() throws IOException
false
if this method could not delete all the files
which should be deleted (e.g. because of of the files was
locked). In this case getToBeDeleted()
lists the files
which should be tried to be deleted outside of this method.
Although false
is returned the checkout was
successful and the working tree was updated for all other files.
true
is returned when no such problem occurredIOException
public void setFailOnConflict(boolean failOnConflict)
true
, will scan first to see if it's possible to check
out, otherwise throw CheckoutConflictException
. If
false
, it will silently deal with the problem.failOnConflict
- public static void checkoutEntry(Repository repository, File f, DirCacheEntry entry) throws IOException
checkoutEntry(Repository, File f, DirCacheEntry, ObjectReader)
instead which allows to reuse one ObjectReader
for 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
repository
- f
- the file to be modified. The parent directory for this file
has to exist alreadyentry
- the entry containing new mode and contentIOException
public static void checkoutEntry(Repository repo, File f, DirCacheEntry entry, ObjectReader or) throws IOException
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
repo
- f
- the file to be modified. The parent directory for this file
has to exist alreadyentry
- the entry containing new mode and contentor
- object reader to use for checkoutIOException
Copyright © 2013. All rights reserved.