# HG changeset patch # User Artem Tikhomirov # Date 1302717359 -7200 # Node ID c6fa4dbfc4585cb7d863d874db1f5e831de67306 # Parent ec1820f64d2be892a84d286bf1034b81e7e81abd Complete Outgoing cmdline, with both lite (revisions) and complete (changeset) information dump diff -r ec1820f64d2b -r c6fa4dbfc458 cmdline/org/tmatesoft/hg/console/Outgoing.java --- 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 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()); + } + }); }