# HG changeset patch # User Artem Tikhomirov # Date 1296159921 -3600 # Node ID ee2c750b036dab5886dd0800c7ea5b2c2b388f8f # Parent ace7042a5ce6500b126014efae477f12392ea516 Changelog to HgChangelog diff -r ace7042a5ce6 -r ee2c750b036d cmdline/org/tmatesoft/hg/console/Incoming.java --- a/cmdline/org/tmatesoft/hg/console/Incoming.java Thu Jan 27 21:24:37 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Incoming.java Thu Jan 27 21:25:21 2011 +0100 @@ -23,7 +23,7 @@ import java.util.List; import org.tmatesoft.hg.core.Nodeid; -import org.tmatesoft.hg.repo.Changelog; +import org.tmatesoft.hg.repo.HgChangelog; import org.tmatesoft.hg.repo.HgRepository; diff -r ace7042a5ce6 -r ee2c750b036d cmdline/org/tmatesoft/hg/console/Log.java --- a/cmdline/org/tmatesoft/hg/console/Log.java Thu Jan 27 21:24:37 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Log.java Thu Jan 27 21:25:21 2011 +0100 @@ -25,7 +25,7 @@ import org.tmatesoft.hg.core.LogCommand.FileRevision; import org.tmatesoft.hg.core.Nodeid; import org.tmatesoft.hg.core.Path; -import org.tmatesoft.hg.repo.Changelog; +import org.tmatesoft.hg.repo.HgChangelog; import org.tmatesoft.hg.repo.HgDataFile; import org.tmatesoft.hg.repo.HgRepository; diff -r ace7042a5ce6 -r ee2c750b036d cmdline/org/tmatesoft/hg/console/Outgoing.java --- a/cmdline/org/tmatesoft/hg/console/Outgoing.java Thu Jan 27 21:24:37 2011 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Outgoing.java Thu Jan 27 21:25:21 2011 +0100 @@ -22,7 +22,7 @@ import java.util.List; import org.tmatesoft.hg.core.Nodeid; -import org.tmatesoft.hg.repo.Changelog; +import org.tmatesoft.hg.repo.HgChangelog; import org.tmatesoft.hg.repo.HgRepository; diff -r ace7042a5ce6 -r ee2c750b036d src/org/tmatesoft/hg/repo/Changelog.java --- a/src/org/tmatesoft/hg/repo/Changelog.java Thu Jan 27 21:24:37 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2010-2011 TMate Software Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * For information on how to redistribute this software under - * the terms of a license other than GNU General Public License - * contact TMate Software at support@svnkit.com - */ -package org.tmatesoft.hg.repo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.tmatesoft.hg.core.Nodeid; -import org.tmatesoft.hg.internal.RevlogStream; - - -/** - * Representation of the Mercurial changelog file (list of ChangeSets) - * - * @author Artem Tikhomirov - * @author TMate Software Ltd. - */ -public class Changelog extends Revlog { - - /*package-local*/ Changelog(HgRepository hgRepo, RevlogStream content) { - super(hgRepo, content); - } - - public void all(final Changeset.Inspector inspector) { - range(0, content.revisionCount() - 1, inspector); - } - - public void range(int start, int end, final Changeset.Inspector inspector) { - RevlogStream.Inspector i = new RevlogStream.Inspector() { - - public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { - Changeset cset = Changeset.parse(data, 0, data.length); - // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse - inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); - } - }; - content.iterate(start, end, true, i); - } - - public List range(int start, int end) { - final ArrayList rv = new ArrayList(end - start + 1); - RevlogStream.Inspector i = new RevlogStream.Inspector() { - - public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { - Changeset cset = Changeset.parse(data, 0, data.length); - rv.add(cset); - } - }; - content.iterate(start, end, true, i); - return rv; - } - - public void range(final Changeset.Inspector inspector, final int... revisions) { - if (revisions == null || revisions.length == 0) { - return; - } - RevlogStream.Inspector i = new RevlogStream.Inspector() { - - public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { - if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { - Changeset cset = Changeset.parse(data, 0, data.length); - inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); - } - } - }; - Arrays.sort(revisions); - content.iterate(revisions[0], revisions[revisions.length - 1], true, i); - } -} diff -r ace7042a5ce6 -r ee2c750b036d src/org/tmatesoft/hg/repo/HgChangelog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/tmatesoft/hg/repo/HgChangelog.java Thu Jan 27 21:25:21 2011 +0100 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2010-2011 TMate Software Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For information on how to redistribute this software under + * the terms of a license other than GNU General Public License + * contact TMate Software at support@svnkit.com + */ +package org.tmatesoft.hg.repo; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.tmatesoft.hg.core.Nodeid; +import org.tmatesoft.hg.internal.RevlogStream; + + +/** + * Representation of the Mercurial changelog file (list of ChangeSets) + * + * @author Artem Tikhomirov + * @author TMate Software Ltd. + */ +public class HgChangelog extends Revlog { + + /*package-local*/ HgChangelog(HgRepository hgRepo, RevlogStream content) { + super(hgRepo, content); + } + + public void all(final Changeset.Inspector inspector) { + range(0, content.revisionCount() - 1, inspector); + } + + public void range(int start, int end, final Changeset.Inspector inspector) { + RevlogStream.Inspector i = new RevlogStream.Inspector() { + + public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { + Changeset cset = Changeset.parse(data, 0, data.length); + // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse + inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); + } + }; + content.iterate(start, end, true, i); + } + + public List range(int start, int end) { + final ArrayList rv = new ArrayList(end - start + 1); + RevlogStream.Inspector i = new RevlogStream.Inspector() { + + public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { + Changeset cset = Changeset.parse(data, 0, data.length); + rv.add(cset); + } + }; + content.iterate(start, end, true, i); + return rv; + } + + public void range(final Changeset.Inspector inspector, final int... revisions) { + if (revisions == null || revisions.length == 0) { + return; + } + RevlogStream.Inspector i = new RevlogStream.Inspector() { + + public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, byte[] data) { + if (Arrays.binarySearch(revisions, revisionNumber) >= 0) { + Changeset cset = Changeset.parse(data, 0, data.length); + inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); + } + } + }; + Arrays.sort(revisions); + content.iterate(revisions[0], revisions[revisions.length - 1], true, i); + } +} diff -r ace7042a5ce6 -r ee2c750b036d src/org/tmatesoft/hg/repo/HgRepository.java --- a/src/org/tmatesoft/hg/repo/HgRepository.java Thu Jan 27 21:24:37 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgRepository.java Thu Jan 27 21:25:21 2011 +0100 @@ -64,7 +64,7 @@ private final PathRewrite dataPathHelper; private final PathRewrite repoPathHelper; - private Changelog changelog; + private HgChangelog changelog; private HgManifest manifest; private HgTags tags; // XXX perhaps, shall enable caching explicitly @@ -99,11 +99,11 @@ return repoDir == null || !repoDir.exists() || !repoDir.isDirectory(); } - public Changelog getChangelog() { + public HgChangelog getChangelog() { if (this.changelog == null) { String storagePath = repoPathHelper.rewrite("00changelog.i"); RevlogStream content = resolve(Path.create(storagePath)); - this.changelog = new Changelog(this, content); + this.changelog = new HgChangelog(this, content); } return this.changelog; }