當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectReader.release方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.lib.ObjectReader.release方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectReader.release方法的具體用法?Java ObjectReader.release怎麽用?Java ObjectReader.release使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.lib.ObjectReader的用法示例。


在下文中一共展示了ObjectReader.release方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAddMissingSymlink

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
public void testAddMissingSymlink () throws Exception {
    if (isWindows()) {
        return;
    }
    String path = "folder/file";
    File f = new File(workDir, path);
    
    // try with commandline client
    File link = new File(workDir, "link");
    Files.createSymbolicLink(Paths.get(link.getAbsolutePath()), Paths.get(path));
    getClient(workDir).add(new File[] { link }, NULL_PROGRESS_MONITOR);
    DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
    assertEquals(FileMode.SYMLINK, e.getFileMode());
    assertEquals(0, e.getLength());
    ObjectReader reader = repository.getObjectDatabase().newReader();
    assertTrue(reader.has(e.getObjectId()));
    byte[] bytes = reader.open(e.getObjectId()).getBytes();
    assertEquals(path, RawParseUtils.decode(bytes));
    reader.release();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:AddTest.java

示例2: prepareTreeParser

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
private static AbstractTreeIterator prepareTreeParser(
		Repository repository, RevCommit commit) throws IOException,
		MissingObjectException, IncorrectObjectTypeException {
	// from the commit we can build the tree which allows us to construct
	// the TreeParser
	RevWalk walk = new RevWalk(repository);
	RevTree tree = walk.parseTree(commit.getTree().getId());
	CanonicalTreeParser result = new CanonicalTreeParser();
	ObjectReader reader = repository.newObjectReader();
	try {
		result.reset(reader, tree.getId());
	} finally {
		reader.release();
	}
	walk.dispose();
	return result;
}
 
開發者ID:DrDub,項目名稱:gitrecommender,代碼行數:18,代碼來源:UpdateLog.java

示例3: checkout

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
public void checkout () throws IOException, GitException {
    TreeWalk treeWalk = new TreeWalk(repository);
    Collection<String> relativePaths = Utils.getRelativePaths(repository.getWorkTree(), roots);
    if (!relativePaths.isEmpty()) {
        treeWalk.setFilter(PathFilterGroup.createFromStrings(relativePaths));
    }
    treeWalk.setRecursive(true);
    treeWalk.reset();
    treeWalk.addTree(new DirCacheIterator(cache));
    treeWalk.addTree(new FileTreeIterator(repository));
    String lastAddedPath = null;
    ObjectReader od = repository.newObjectReader();
    try {
    while (treeWalk.next() && !monitor.isCanceled()) {
        File path = new File(repository.getWorkTree(), treeWalk.getPathString());
        if (treeWalk.getPathString().equals(lastAddedPath)) {
            // skip conflicts
            continue;
        } else {
            lastAddedPath = treeWalk.getPathString();
        }
        DirCacheIterator dit = treeWalk.getTree(0, DirCacheIterator.class);
        FileTreeIterator fit = treeWalk.getTree(1, FileTreeIterator.class);
        if (dit != null && (recursively || directChild(roots, repository.getWorkTree(), path)) && (fit == null || fit.isModified(dit.getDirCacheEntry(), checkContent, od))) {
            // update entry
            listener.notifyFile(path, treeWalk.getPathString());
            checkoutEntry(repository, path, dit.getDirCacheEntry(), od);
        }
    }
    } finally {
        od.release();
        treeWalk.release();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:CheckoutIndex.java

示例4: testDiffRenameDetectionProblem

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
public void testDiffRenameDetectionProblem () throws Exception {
    File file = new File(workDir, "file");
    File renamed = new File(workDir, "renamed");
    File patchFile = new File(workDir.getParentFile(), "diff.patch");
    write(file, "hey, i will be renamed\n");
    add(file);
    commit(file);
    
    file.renameTo(renamed);
    write(renamed, "hey, i will be renamed\nand now i am\n");
    OutputStream out = new BufferedOutputStream(new FileOutputStream(patchFile));
    DiffFormatter formatter = new DiffFormatter(out);
    formatter.setRepository(repository);
    ObjectReader or = null;
    try {
        formatter.setDetectRenames(true);
        AbstractTreeIterator firstTree = new DirCacheIterator(repository.readDirCache());;
        AbstractTreeIterator secondTree = new FileTreeIterator(repository);
        formatter.format(firstTree, secondTree);
        formatter.flush();
        fail("Fixed in JGit, modify and simplify the sources in ExportDiff command");
    } catch (IOException ex) {
        assertEquals("Missing blob 7b34a309b8dbae2686c9e597efef28a612e48aff", ex.getMessage());
    } finally {
        if (or != null) {
            or.release();
        }
        formatter.release();
    }
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:ExportDiffTest.java

示例5: prepareTreeParser

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
private AbstractTreeIterator prepareTreeParser(final ObjectId commit) throws IOException {
    final RevWalk walk = new RevWalk(git.getRepository());
    final RevTree tree = walk.parseTree(walk.parseCommit(commit).getTree().getId());
    final CanonicalTreeParser treeParser = new CanonicalTreeParser();

    final ObjectReader reader = git.getRepository().newObjectReader();
    try {
        treeParser.reset(reader, tree.getId());
    } finally {
        reader.release();
        walk.dispose();
    }
    return treeParser;
}
 
開發者ID:sdaschner,項目名稱:asciiblog,代碼行數:15,代碼來源:ChangeCalculator.java

示例6: getTreeIterator

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
private AbstractTreeIterator getTreeIterator(Git git, CodeRevision rev) throws IOException {
	final CanonicalTreeParser p = new CanonicalTreeParser();
	Repository db = git.getRepository();
	final ObjectReader or = db.newObjectReader();
	try {
		p.reset(or, new RevWalk(db).parseTree(ObjectId.fromString(rev.getCommitId())));
		return p;
	} finally {
		or.release();
	}
}
 
開發者ID:bugminer,項目名稱:bugminer,代碼行數:12,代碼來源:GitStrategy.java

示例7: getBlob

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
/**
 * Returns the blob information for the file at the specified path and commit
 *
 * @param repoItem
 * @param commit
 * @return
 * @throws Exception
 */
public byte[] getBlob(String repoItem, String commit) throws Exception
{
    byte[] data;

    String parentPath = repository.getDirectory().getParent();

    ObjectId commitId = repository.resolve(commit);

    ObjectReader reader = repository.newObjectReader();
    RevWalk revWalk = new RevWalk(reader);
    RevCommit revCommit = revWalk.parseCommit(commitId);
    RevTree tree = revCommit.getTree();
    TreeWalk treeWalk = TreeWalk.forPath(reader, repoItem, tree);

    if (treeWalk != null)
    {
        data = reader.open(treeWalk.getObjectId(0)).getBytes();
    }
    else
    {
        throw new IllegalStateException("Did not find expected file '" + repoItem + "'");
    }

    reader.release();

    return data;
}
 
開發者ID:aesanch2,項目名稱:salesforce-migration-assistant,代碼行數:36,代碼來源:SMAGit.java

示例8: getAllMetadata

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
/**
 * Replicates ls-tree for the current commit.
 *
 * @return Map containing the full path and the data for all items in the repository.
 * @throws IOException
 */
public Map<String, byte[]> getAllMetadata() throws Exception
{
    Map<String, byte[]> contents = new HashMap<String, byte[]>();
    ObjectReader reader = repository.newObjectReader();
    ObjectId commitId = repository.resolve(curCommit);
    RevWalk revWalk = new RevWalk(reader);
    RevCommit commit = revWalk.parseCommit(commitId);
    RevTree tree = commit.getTree();
    TreeWalk treeWalk = new TreeWalk(reader);
    treeWalk.addTree(tree);
    treeWalk.setRecursive(false);

    while (treeWalk.next())
    {
        if (treeWalk.isSubtree())
        {
            treeWalk.enterSubtree();
        }
        else
        {
            String member = treeWalk.getPathString();
            if (member.contains(SOURCEDIR))
            {
                byte[] data = getBlob(member, curCommit);
                contents.put(member, data);
            }
        }
    }

    reader.release();

    return contents;
}
 
開發者ID:aesanch2,項目名稱:salesforce-migration-assistant,代碼行數:40,代碼來源:SMAGit.java

示例9: getTreeIterator

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
private AbstractTreeIterator getTreeIterator(final String name)
		throws IOException {
	final ObjectId id = repository.getRepository().resolve(name);
	if (id == null) {
		throw new IllegalArgumentException(name);
	}
	final CanonicalTreeParser p = new CanonicalTreeParser();
	final ObjectReader or = repository.getRepository().newObjectReader();
	try {
		p.reset(or, new RevWalk(repository.getRepository()).parseTree(id));
		return p;
	} finally {
		or.release();
	}
}
 
開發者ID:mast-group,項目名稱:commitmining-tools,代碼行數:16,代碼來源:EditListRetriever.java

示例10: run

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
@Override
  protected void run() throws GitException {
      Repository repository = getRepository();
      DiffFormatter formatter = new DiffFormatter(out);
      formatter.setRepository(repository);
      ObjectReader or = null;
      String workTreePath = repository.getWorkTree().getAbsolutePath();
      try {
          Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots);
          if (!pathFilters.isEmpty()) {
              formatter.setPathFilter(PathFilterGroup.create(pathFilters));
          }
          if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) {
              // work-around for autocrlf
              formatter.setDiffComparator(new AutoCRLFComparator());
          }
          or = repository.newObjectReader();
          AbstractTreeIterator firstTree = getIterator(firstCommit, or);
          AbstractTreeIterator secondTree = getIterator(secondCommit, or);
          List<DiffEntry> diffEntries;
          if (secondTree instanceof WorkingTreeIterator) {
              // remote when fixed in JGit, see ExportDiffTest.testDiffRenameDetectionProblem
              formatter.setDetectRenames(false);
              diffEntries = formatter.scan(firstTree, secondTree);
              formatter.setDetectRenames(true);
              RenameDetector detector = formatter.getRenameDetector();
              detector.reset();
              detector.addAll(diffEntries);
diffEntries = detector.compute(new ContentSource.Pair(ContentSource.create(or), ContentSource.create((WorkingTreeIterator) secondTree)), NullProgressMonitor.INSTANCE);
          } else {
              formatter.setDetectRenames(true);
              diffEntries = formatter.scan(firstTree, secondTree);
          }
          for (DiffEntry ent : diffEntries) {
              if (monitor.isCanceled()) {
                  break;
              }
              listener.notifyFile(new File(workTreePath + File.separator + ent.getNewPath()), ent.getNewPath());
              formatter.format(ent);
          }
          formatter.flush();
      } catch (IOException ex) {
          throw new GitException(ex);
      } finally {
          if (or != null) {
              or.release();
          }
          formatter.release();
      }
  }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:51,代碼來源:ExportDiffCommand.java

示例11: testAddSymlink

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
public void testAddSymlink () throws Exception {
    if (isWindows()) {
        return;
    }
    String path = "folder/file";
    File f = new File(workDir, path);
    f.getParentFile().mkdir();
    write(f, "file");
    add(f);
    commit(f);
    
    Thread.sleep(1100);
    
    // try with commandline client
    File link = new File(workDir, "link");
    runExternally(workDir, Arrays.asList("ln", "-s", path, link.getName()));
    long ts = Files.readAttributes(Paths.get(link.getAbsolutePath()), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).lastModifiedTime().toMillis();
    runExternally(workDir, Arrays.asList("git", "add", link.getName()));
    DirCacheEntry e = repository.readDirCache().getEntry(link.getName());
    assertEquals(FileMode.SYMLINK, e.getFileMode());
    ObjectId id = e.getObjectId();
    assertEquals(ts, e.getLastModified() / 1000 * 1000);
    ObjectReader reader = repository.getObjectDatabase().newReader();
    assertTrue(reader.has(e.getObjectId()));
    byte[] bytes = reader.open(e.getObjectId()).getBytes();
    assertEquals(path, RawParseUtils.decode(bytes));
    
    // now with internal
    File link2 = new File(workDir, "link2");
    Files.createSymbolicLink(Paths.get(link2.getAbsolutePath()), Paths.get(path));
    ts = Files.readAttributes(Paths.get(link2.getAbsolutePath()), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS).lastModifiedTime().toMillis();
    getClient(workDir).add(new File[] { link2 }, NULL_PROGRESS_MONITOR);
    
    DirCacheEntry e2 = repository.readDirCache().getEntry(link2.getName());
    assertEquals(FileMode.SYMLINK, e2.getFileMode());
    assertEquals(id, e2.getObjectId());
    assertEquals(0, e2.getLength());
    assertEquals(ts, e2.getLastModified() / 1000 * 1000);
    assertTrue(reader.has(e2.getObjectId()));
    bytes = reader.open(e2.getObjectId()).getBytes();
    assertEquals(path, RawParseUtils.decode(bytes));
    reader.release();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:AddTest.java

示例12: toSoyData

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
public Map<String, Object> toSoyData(HttpServletRequest req, RevCommit commit, KeySet ks)
    throws IOException {
  checkKeys(ks);
  checkNotNull(req, "request");
  repo = ServletUtils.getRepository(req);
  view = ViewFilter.getView(req);

  Map<String, Object> data = Maps.newHashMapWithExpectedSize(KeySet.DEFAULT.keys.size());
  if (ks.contains("author")) {
    data.put("author", toSoyData(commit.getAuthorIdent(), dateFormatter));
  }
  if (ks.contains("committer")) {
    data.put("committer", toSoyData(commit.getCommitterIdent(), dateFormatter));
  }
  if (ks.contains("sha")) {
    data.put("sha", ObjectId.toString(commit));
  }
  if (ks.contains("abbrevSha")) {
    ObjectReader reader = repo.getObjectDatabase().newReader();
    try {
      data.put("abbrevSha", reader.abbreviate(commit).name());
    } finally {
      reader.release();
    }
  }
  if (ks.contains("url")) {
    data.put("url", GitilesView.revision()
        .copyFrom(view)
        .setRevision(commit)
        .toUrl());
  }
  if (ks.contains("logUrl")) {
    data.put("logUrl", urlFromView(view, commit, GitilesView.log()));
  }
  if (ks.contains("archiveUrl")) {
    data.put("archiveUrl", urlFromView(view, commit,
        GitilesView.archive().setExtension(archiveFormat.getDefaultSuffix())));
  }
  if (ks.contains("archiveType")) {
    data.put("archiveType", archiveFormat.getShortName());
  }
  if (ks.contains("tree")) {
    data.put("tree", ObjectId.toString(commit.getTree()));
  }
  if (ks.contains("treeUrl")) {
    data.put("treeUrl", GitilesView.path().copyFrom(view).setPathPart("/").toUrl());
  }
  if (ks.contains("parents")) {
    data.put("parents", toSoyData(view, commit.getParents()));
  }
  if (ks.contains("shortMessage")) {
    data.put("shortMessage", commit.getShortMessage());
  }
  if (ks.contains("branches")) {
    data.put("branches", getRefsById(commit, Constants.R_HEADS));
  }
  if (ks.contains("tags")) {
    data.put("tags", getRefsById(commit, Constants.R_TAGS));
  }
  if (ks.contains("message")) {
    if (linkifier != null) {
      data.put("message", linkifier.linkify(req, commit.getFullMessage()));
    } else {
      data.put("message", commit.getFullMessage());
    }
  }
  if (ks.contains("diffTree")) {
    data.put("diffTree", computeDiffTree(commit));
  }
  checkState(ks.keys.size() == data.size(), "bad commit data keys: %s != %s", ks.keys,
      data.keySet());
  return ImmutableMap.copyOf(data);
}
 
開發者ID:afrojer,項目名稱:gitiles,代碼行數:74,代碼來源:CommitSoyData.java

示例13: cloneCommit

import org.eclipse.jgit.lib.ObjectReader; //導入方法依賴的package包/類
private void cloneCommit() throws Exception {
	ObjectReader objectReader = m_headRepository.newObjectReader();
	try {
		File mineDir = new File(m_target, this.m_name);
		
		if (!mineDir.exists()) {
			mineDir.mkdir();
			mineDir.setWritable(true);
			mineDir.setExecutable(true);
		}
		
		TreeWalk treeWalk = new TreeWalk(objectReader);
		treeWalk.addTree(m_current.getTree());
		
		while (treeWalk.next()) {
			String path = treeWalk.getPathString();
			File file = new File(mineDir, path);
			if (treeWalk.isSubtree()) {
				file.mkdir();
				treeWalk.enterSubtree();
			} else {
				FileOutputStream outputStream = new FileOutputStream(file);
				ObjectId objectId = treeWalk.getObjectId(0);
				ObjectLoader objectLoader = objectReader.open(objectId);
				try {
					objectLoader.copyTo(outputStream);
				} finally {
					outputStream.close();
				}

				if (FileMode.EXECUTABLE_FILE.equals(treeWalk.getRawMode(0))) {
					file.setExecutable(true);
				}
			}
		}
		
		GlobalMessages.commitPulled(this.m_i, this.m_current.getName());
		
		m_runningThreads--;
		
	} catch (Exception e) {
		errorHandlingMining(e, this.m_current);
	} finally {
		// Release resources
		objectReader.release();
	}
}
 
開發者ID:gingerswede,項目名稱:doris,代碼行數:48,代碼來源:GitRepository.java


注:本文中的org.eclipse.jgit.lib.ObjectReader.release方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。