Example usage for org.eclipse.jgit.dircache DirCacheCheckout checkoutEntry

List of usage examples for org.eclipse.jgit.dircache DirCacheCheckout checkoutEntry

Introduction

In this page you can find the example usage for org.eclipse.jgit.dircache DirCacheCheckout checkoutEntry.

Prototype

@Deprecated
public static void checkoutEntry(Repository repo, DirCacheEntry entry, ObjectReader or) throws IOException 

Source Link

Document

Updates the file in the working tree with content and mode from an entry in the index.

Usage

From source file:com.itemis.maven.plugins.unleash.scm.providers.merge.UnleashGitMerger.java

License:Eclipse Distribution License

private void checkout() throws NoWorkTreeException, IOException {
    // Iterate in reverse so that "folder/file" is deleted before
    // "folder". Otherwise this could result in a failing path because
    // of a non-empty directory, for which delete() would fail.
    for (int i = this.toBeDeleted.size() - 1; i >= 0; i--) {
        String fileName = this.toBeDeleted.get(i);
        File f = new File(this.db.getWorkTree(), fileName);
        if (!f.delete()) {
            if (!f.isDirectory()) {
                this.failingPaths.put(fileName, MergeFailureReason.COULD_NOT_DELETE);
            }//from   ww  w.  j av  a2  s  .  c  o m
        }
        this.modifiedFiles.add(fileName);
    }
    for (Map.Entry<String, DirCacheEntry> entry : this.toBeCheckedOut.entrySet()) {
        DirCacheCheckout.checkoutEntry(this.db, entry.getValue(), this.reader);
        this.modifiedFiles.add(entry.getKey());
    }
}

From source file:com.itemis.maven.plugins.unleash.scm.providers.merge.UnleashGitMerger.java

License:Eclipse Distribution License

/**
 * Reverts the worktree after an unsuccessful merge. We know that for all
 * modified files the old content was in the old index and the index
 * contained only stage 0. In case if inCore operation just clear the
 * history of modified files./*from  www  .j a  v  a 2 s . c  o m*/
 *
 * @throws IOException
 * @throws CorruptObjectException
 * @throws NoWorkTreeException
 * @since 3.4
 */
@Override
protected void cleanUp() throws NoWorkTreeException, CorruptObjectException, IOException {
    if (this.inCore) {
        this.modifiedFiles.clear();
        return;
    }

    DirCache dc = this.db.readDirCache();
    Iterator<String> mpathsIt = this.modifiedFiles.iterator();
    while (mpathsIt.hasNext()) {
        String mpath = mpathsIt.next();
        DirCacheEntry entry = dc.getEntry(mpath);
        if (entry != null) {
            DirCacheCheckout.checkoutEntry(this.db, entry, this.reader);
        }
        mpathsIt.remove();
    }
}

From source file:org.eclipse.egit.core.op.DiscardChangesOperation.java

License:Open Source License

private void discardChange(IResource res, Repository repository) throws IOException {
    String resRelPath = RepositoryMapping.getMapping(res).getRepoRelativePath(res);
    DirCache dc = repository.lockDirCache();
    DirCacheEntry entry = dc.getEntry(resRelPath);
    File file = new File(res.getLocationURI());
    DirCacheCheckout.checkoutEntry(repository, file, entry);
    dc.unlock();//w  ww  .  j ava2 s .c  o m
}