Package org.eclipse.jgit.revplot

Examples of org.eclipse.jgit.revplot.PlotWalk$PlotRefComparator


  @Override
  protected RevWalk createWalk() {
    if (objects)
      throw die(CLIText.get().cannotUseObjectsWithGlog);
    final PlotWalk w = new PlotWalk(db);
    w.sort(RevSort.BOUNDARY, true);
    return w;
  }
View Full Code Here


  }

  @Test
  public void testPlots() throws Exception {
    Repository repository = GitBlitSuite.getTicgitRepository();
    PlotWalk pw = new PlotWalk(repository);
    PlotCommitList<PlotLane> commits = new PlotCommitList<PlotLane>();
    commits.source(pw);
    commits.fillTo(25);
    for (PlotCommit<PlotLane> commit : commits) {
      System.out.println(commit);
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    InputStream is = null;
    Repository r = null;
    PlotWalk rw = null;
    try {
      String repository = request.getParameter("r");
      String objectId = request.getParameter("h");
      String length = request.getParameter("l");

      r = repositoryManager.getRepository(repository);

      rw = new PlotWalk(r);
      if (StringUtils.isEmpty(objectId)) {
        objectId = JGitUtils.getHEADRef(r);
      }

      rw.markStart(rw.lookupCommit(r.resolve(objectId)));

      // default to the items-per-page setting, unless specified
      int maxCommits = settings.getInteger(Keys.web.itemsPerPage, 50);
      int requestedCommits = maxCommits;
      if (!StringUtils.isEmpty(length)) {
        int l = Integer.parseInt(length);
        if (l > 0) {
          requestedCommits = l;
        }
      }

      // fetch the requested commits plus some extra so that the last
      // commit displayed *likely* has correct lane assignments
      CommitList commitList = new CommitList();
      commitList.source(rw);
      commitList.fillTo(2*Math.max(requestedCommits, maxCommits));

      // determine the appropriate width for the image
      int numLanes = 1;
      int numCommits = Math.min(requestedCommits, commitList.size());
      if (numCommits > 1) {
        // determine graph width
        Set<String> parents = new TreeSet<String>();
        for (int i = 0; i < commitList.size(); i++) {
          PlotCommit<Lane> commit = commitList.get(i);
          boolean checkLane = false;

          if (i < numCommits) {
            // commit in visible list
            checkLane = true;

            // remember parents
            for (RevCommit p : commit.getParents()) {
              parents.add(p.getName());
            }
          } else if (parents.contains(commit.getName())) {
            // commit outside visible list, but it is a parent of a
            // commit in the visible list so we need to know it's lane
            // assignment
            checkLane = true;
          }

          if (checkLane) {
            int pos = commit.getLane().getPosition();
            numLanes = Math.max(numLanes, pos + 1);
          }
        }
      }

      int graphWidth = numLanes * LANE_WIDTH + RIGHT_PAD;
      int rowHeight = ROW_HEIGHT;

      // create an image buffer and render the lanes
      BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);

      Graphics2D g = null;
      try {
        g = image.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        LanesRenderer renderer = new LanesRenderer();
        for (int i = 0; i < commitList.size(); i++) {
          PlotCommit<Lane> commit = commitList.get(i);
          Graphics row = g.create(0, i*rowHeight, graphWidth, rowHeight);
          try {
            renderer.paint(row, commit, rowHeight, graphWidth);
          } finally {
            row.dispose();
            row = null;
          }
        }
      } finally {
        if (g != null) {
          g.dispose();
          g = null;
        }
      }

      // write the image buffer to the client
      response.setContentType("image/png");
      if (numCommits > 1) {
        response.setHeader("Cache-Control", "public, max-age=60, must-revalidate");
        response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commitList.get(0)).getTime());
      }
      OutputStream os = response.getOutputStream();
      ImageIO.write(image, "png", os);
      os.flush();
      image.flush();
      image = null;
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (is != null) {
        is.close();
        is = null;
      }
      if (rw != null) {
        rw.dispose();
        rw = null;
      }
      if (r != null) {
        r.close();
        r = null;
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    InputStream is = null;
    Repository r = null;
    PlotWalk rw = null;
    try {
      String repository = request.getParameter("r");
      if (StringUtils.isEmpty(repository)) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        response.getWriter().append("Bad request");
        return;
      }
      String objectId = request.getParameter("h");
      String length = request.getParameter("l");

      r = repositoryManager.getRepository(repository);
      if (r == null) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        response.getWriter().append("Bad request");
        return;
      }

      rw = new PlotWalk(r);
      if (StringUtils.isEmpty(objectId)) {
        objectId = JGitUtils.getHEADRef(r);
      }

      ObjectId id = r.resolve(objectId);
      if (id ==  null) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        response.getWriter().append("Bad request");
        return;
      }
      rw.markStart(rw.lookupCommit(id));

      // default to the items-per-page setting, unless specified
      int maxCommits = settings.getInteger(Keys.web.itemsPerPage, 50);
      int requestedCommits = maxCommits;
      if (!StringUtils.isEmpty(length)) {
        int l = Integer.parseInt(length);
        if (l > 0) {
          requestedCommits = l;
        }
      }

      // fetch the requested commits plus some extra so that the last
      // commit displayed *likely* has correct lane assignments
      CommitList commitList = new CommitList();
      commitList.source(rw);
      commitList.fillTo(2*Math.max(requestedCommits, maxCommits));

      // determine the appropriate width for the image
      int numLanes = 1;
      int numCommits = Math.min(requestedCommits, commitList.size());
      if (numCommits > 1) {
        // determine graph width
        Set<String> parents = new TreeSet<String>();
        for (int i = 0; i < commitList.size(); i++) {
          PlotCommit<Lane> commit = commitList.get(i);
          boolean checkLane = false;

          if (i < numCommits) {
            // commit in visible list
            checkLane = true;

            // remember parents
            for (RevCommit p : commit.getParents()) {
              parents.add(p.getName());
            }
          } else if (parents.contains(commit.getName())) {
            // commit outside visible list, but it is a parent of a
            // commit in the visible list so we need to know it's lane
            // assignment
            checkLane = true;
          }

          if (checkLane) {
            int pos = commit.getLane().getPosition();
            numLanes = Math.max(numLanes, pos + 1);
          }
        }
      }

      int graphWidth = numLanes * LANE_WIDTH + RIGHT_PAD;
      int rowHeight = ROW_HEIGHT;

      // create an image buffer and render the lanes
      BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);

      Graphics2D g = null;
      try {
        g = image.createGraphics();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        LanesRenderer renderer = new LanesRenderer();
        for (int i = 0; i < commitList.size(); i++) {
          PlotCommit<Lane> commit = commitList.get(i);
          Graphics row = g.create(0, i*rowHeight, graphWidth, rowHeight);
          try {
            renderer.paint(row, commit, rowHeight, graphWidth);
          } finally {
            row.dispose();
            row = null;
          }
        }
      } finally {
        if (g != null) {
          g.dispose();
          g = null;
        }
      }

      // write the image buffer to the client
      response.setContentType("image/png");
      if (numCommits > 1) {
        response.setHeader("Cache-Control", "public, max-age=60, must-revalidate");
        response.setDateHeader("Last-Modified", JGitUtils.getCommitDate(commitList.get(0)).getTime());
      }
      OutputStream os = response.getOutputStream();
      ImageIO.write(image, "png", os);
      os.flush();
      image.flush();
      image = null;
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (is != null) {
        is.close();
        is = null;
      }
      if (rw != null) {
        rw.dispose();
        rw = null;
      }
      if (r != null) {
        r.close();
        r = null;
View Full Code Here

  }

  @Test
  public void testPlots() throws Exception {
    Repository repository = GitBlitSuite.getTicgitRepository();
    PlotWalk pw = new PlotWalk(repository);
    PlotCommitList<PlotLane> commits = new PlotCommitList<PlotLane>();
    commits.source(pw);
    commits.fillTo(25);
    for (PlotCommit<PlotLane> commit : commits) {
      System.out.println(commit);
View Full Code Here

  @Override
  protected RevWalk createWalk() {
    if (objects)
      throw die(CLIText.get().cannotUseObjectsWithGlog);
    final PlotWalk w = new PlotWalk(db);
    w.sort(RevSort.BOUNDARY, true);
    return w;
  }
View Full Code Here

  @Override
  protected RevWalk createWalk() {
    if (objects)
      throw die(CLIText.get().cannotUseObjectsWithGlog);
    final PlotWalk w = new PlotWalk(db);
    w.sort(RevSort.BOUNDARY, true);
    return w;
  }
View Full Code Here

          return;
        }

        final PlotCommit<?> c = (PlotCommit<?>) sel.getFirstElement();
        commentViewer.setInput(c);
        final PlotWalk walk = new PlotWalk(input.getRepository());
        try {
          final RevCommit unfilteredCommit = walk.parseCommit(c);
          for (RevCommit parent : unfilteredCommit.getParents())
            walk.parseBody(parent);
          fileViewer.setInput(unfilteredCommit);
        } catch (IOException e) {
          fileViewer.setInput(c);
        } finally {
          walk.dispose();
        }

        if (input.getSingleFile() != null)
          fileViewer.selectFirstInterestingElement();
      }
View Full Code Here

public class ListChildrenOfCommit {

    public static void main(String[] args) throws IOException, GitAPIException {
        Repository repository = CookbookHelper.openJGitCookbookRepository();

        PlotWalk revWalk = new PlotWalk(repository);
        ObjectId rootId = repository.resolve("refs/heads/master");
        RevCommit root = revWalk.parseCommit(rootId);
        revWalk.markStart(root);
        PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<PlotLane>();
        plotCommitList.source(revWalk);
        plotCommitList.fillTo(Integer.MAX_VALUE);

        System.out.println("Printing children of commit " + root);
        for (RevCommit com : revWalk) {
            System.out.println("Child: " + com);
        }

        System.out.println("Printing with next()");
        System.out.println("next: " + revWalk.next());

        repository.close();
    }
View Full Code Here

    public void show() {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                model.getCommitList().clear();
                PlotWalk walk = null;
                try {
                    walk = new PlotWalk(model.getRepository());
                    walk.sort(RevSort.BOUNDARY, true);
                    if (model.hasPaths()) {
                        walk.setTreeFilter(model.createPathFilter());
                    }
                    for (Ref ref : model.getReferences())
                        walk.markStart(walk.parseCommit(ref.getObjectId()));
                    model.getCommitList().source(walk);
                    model.getCommitList().fillTo(Integer.MAX_VALUE);
                } catch (Throwable error) {
                    model.setContent(error.getMessage());
                } finally {
                    if (walk != null) {
                        walk.dispose();
                    }
                }
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.revplot.PlotWalk$PlotRefComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.