Example usage for org.eclipse.jgit.internal.storage.file GC GC

List of usage examples for org.eclipse.jgit.internal.storage.file GC GC

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.file GC GC.

Prototype

public GC(FileRepository repo) 

Source Link

Document

Creates a new garbage collector with default values.

Usage

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

License:Open Source License

/**
 * Execute garbage collection//from  w w w  . ja  va 2s  .  co  m
 */
public void execute(IProgressMonitor monitor) throws CoreException {
    GC gc = new GC((FileRepository) repository);
    gc.setProgressMonitor(new EclipseGitProgressTransformer(monitor));
    try {
        gc.gc();
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), e.getMessage(), e));
    } catch (ParseException e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.getPluginId(), e.getMessage(), e));
    }
}

From source file:org.eclipse.egit.ui.internal.repository.RepositoryStatisticsPage.java

License:Open Source License

protected Control createContents(Composite parent) {
    Table table = new Table(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    String[] titles = { UIText.RepositoryStatistics_Description, UIText.RepositoryStatistics_LooseObjects,
            UIText.RepositoryStatistics_PackedObjects };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(titles[i]);/*  w  ww  .j a  v a  2 s . c o m*/
    }

    Repository repo = (Repository) getElement().getAdapter(Repository.class);
    if (repo == null)
        return table;
    if (repo instanceof FileRepository) {
        GC gc = new GC((FileRepository) repo);
        try {
            RepoStatistics stats = gc.getStatistics();

            table.setLinesVisible(true);
            table.setHeaderVisible(true);
            GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
            data.heightHint = 200;
            table.setLayoutData(data);

            TableItem item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfObjects);
            item.setText(1, bigIntFmt.format(stats.numberOfLooseObjects));
            item.setText(2, bigIntFmt.format(stats.numberOfPackedObjects));

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfPackfiles);
            item.setText(2, bigIntFmt.format(stats.numberOfPackFiles).toString());

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfRefs);
            item.setText(1, bigIntFmt.format(stats.numberOfLooseRefs).toString());
            item.setText(2, bigIntFmt.format(stats.numberOfPackedRefs).toString());

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_SpaceNeededOnFilesystem);
            item.setText(1, describeSize(stats.sizeOfLooseObjects));
            item.setText(2, describeSize(stats.sizeOfPackedObjects));

            for (int i = 0; i < titles.length; i++) {
                table.getColumn(i).pack();
            }
            parent.pack();
        } catch (IOException e) {
        }
    }
    return table;
}

From source file:org.eclipse.orion.server.git.jobs.GitJobUtils.java

License:Open Source License

/**
 * Calls pack refs for a given repository
 * /*from ww  w.  j  a v a 2s .c om*/
 * @param Repository
 *            the git repository
 */
public static void packRefs(Repository repo, ProgressMonitor monitor) {
    if (repo != null && repo instanceof FileRepository) {
        GC gc = new GC(((FileRepository) repo));
        gc.setProgressMonitor(monitor);
        try {
            gc.packRefs();
        } catch (IOException ex) {
            // ignore IOException since packing is an optimization (not essential for the callers doClone/doFetch) 
        }
    }
}