public class DirCacheCheckout extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DirCacheCheckout.CheckoutMetadata
Metadata used in checkout process
|
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 repo,
DirCacheEntry entry,
ObjectReader or)
Updates the file in the working tree with content and mode from an entry
in the index.
|
static void |
checkoutEntry(Repository repo,
DirCacheEntry entry,
ObjectReader or,
boolean deleteRecursive,
DirCacheCheckout.CheckoutMetadata checkoutMetadata)
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,DirCacheCheckout.CheckoutMetadata> |
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 Map<String,DirCacheCheckout.CheckoutMetadata> getUpdated()
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
WorkingTreeModifiedEvent
is fired if the
working tree was modified; even if the checkout fails.false
if this method could not delete all the files
which should be deleted (e.g. because one 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 repo, DirCacheEntry entry, ObjectReader or) throws IOException
Note: if the entry path on local file system exists as a non-empty
directory, and the target entry type is a link or file, the checkout will
fail with IOException
since existing non-empty directory cannot
be renamed to file or link without deleting it recursively.
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
- repository managing the destination work tree.entry
- the entry containing new mode and contentor
- object reader to use for checkoutIOException
public static void checkoutEntry(Repository repo, DirCacheEntry entry, ObjectReader or, boolean deleteRecursive, DirCacheCheckout.CheckoutMetadata checkoutMetadata) throws IOException
Note: if the entry path on local file system exists as a file, it will be deleted and if it exists as a directory, it will be deleted recursively, independently if has any content.
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
- repository managing the destination work tree.entry
- the entry containing new mode and contentor
- object reader to use for checkoutdeleteRecursive
- true to recursively delete final path if it exists on the file
systemcheckoutMetadata
- containing
IOException
Copyright © 2017 Eclipse JGit Project. All rights reserved.