Mercurial > jhg
changeset 185:c6fa4dbfc458
Complete Outgoing cmdline, with both lite (revisions) and complete (changeset) information dump
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 13 Apr 2011 19:55:59 +0200 |
parents | ec1820f64d2b |
children | 44a34baabea0 |
files | cmdline/org/tmatesoft/hg/console/Outgoing.java |
diffstat | 1 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Outgoing.java Wed Apr 13 19:09:10 2011 +0200 +++ b/cmdline/org/tmatesoft/hg/console/Outgoing.java Wed Apr 13 19:55:59 2011 +0200 @@ -17,8 +17,10 @@ package org.tmatesoft.hg.console; import java.util.Collection; +import java.util.Collections; import java.util.List; +import org.tmatesoft.hg.core.HgBadStateException; import org.tmatesoft.hg.core.HgException; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.internal.RepositoryComparator; @@ -26,6 +28,7 @@ import org.tmatesoft.hg.repo.HgLookup; import org.tmatesoft.hg.repo.HgRemoteRepository; import org.tmatesoft.hg.repo.HgRepository; +import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; /** @@ -44,13 +47,14 @@ System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); return; } - HgRemoteRepository hgRemote = new HgLookup().detectRemote("hg4j-gc", hgRepo); + HgRemoteRepository hgRemote = new HgLookup().detectRemote(cmdLineOpts.getSingle(""), hgRepo); if (hgRemote.isInvalid()) { System.err.printf("Remote repository %s is not valid", hgRemote.getLocation()); return; } - HgChangelog.ParentWalker pw = hgRepo.getChangelog().new ParentWalker(); + HgChangelog changelog = hgRepo.getChangelog(); + HgChangelog.ParentWalker pw = changelog.new ParentWalker(); pw.init(); RepositoryComparator repoCompare = new RepositoryComparator(pw, hgRemote); @@ -65,7 +69,35 @@ } // find all local children of commonKnown List<Nodeid> result = pw.childrenOf(commonKnown); - dump("Result", result); + dump("Lite", result); + // another approach to get all changes after common: + // find index of earliest revision, and report all that were later + int earliestRevision = Integer.MAX_VALUE; + for (Nodeid n : commonKnown) { + if (pw.childrenOf(Collections.singletonList(n)).isEmpty()) { + // there might be (old) nodes, known both locally and remotely, with no children + // hence, we don't need to consider their local revision number + continue; + } + int lr = changelog.getLocalRevision(n); + if (lr < earliestRevision) { + earliestRevision = lr; + } + } + if (earliestRevision < 0 || earliestRevision >= changelog.getLastRevision()) { + throw new HgBadStateException(String.format("Invalid index of common known revision: %d in total of %d", earliestRevision, 1+changelog.getLastRevision())); + } + System.out.println("Full"); + // show all, starting from next to common + changelog.range(earliestRevision+1, changelog.getLastRevision(), new HgChangelog.Inspector() { + + public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { + System.out.printf("changeset: %d:%s\n", revisionNumber, nodeid.toString()); + System.out.printf("user: %s\n", cset.user()); + System.out.printf("date: %s\n", cset.dateString()); + System.out.printf("comment: %s\n\n", cset.comment()); + } + }); }