comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 195:c9b305df0b89

Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 15 Apr 2011 05:17:44 +0200
parents 37f3d4a596e4
children ffc5f6d59f7e
comparison
equal deleted inserted replaced
194:344e8d7e4d6e 195:c9b305df0b89
57 private int startRev = 0, endRev = TIP; 57 private int startRev = 0, endRev = TIP;
58 private Calendar date; 58 private Calendar date;
59 private Path file; 59 private Path file;
60 private boolean followHistory; // makes sense only when file != null 60 private boolean followHistory; // makes sense only when file != null
61 private ChangesetTransformer csetTransform; 61 private ChangesetTransformer csetTransform;
62 private HgChangelog.ParentWalker parentHelper;
62 63
63 public HgLogCommand(HgRepository hgRepo) { 64 public HgLogCommand(HgRepository hgRepo) {
64 repo = hgRepo; 65 repo = hgRepo;
65 } 66 }
66 67
182 if (csetTransform != null) { 183 if (csetTransform != null) {
183 throw new ConcurrentModificationException(); 184 throw new ConcurrentModificationException();
184 } 185 }
185 try { 186 try {
186 count = 0; 187 count = 0;
188 HgChangelog.ParentWalker pw = parentHelper; // leave it uninitialized unless we iterate whole repo
189 if (file == null) {
190 pw = getParentHelper();
191 }
187 // ChangesetTransfrom creates a blank PathPool, and #file(String, boolean) above 192 // ChangesetTransfrom creates a blank PathPool, and #file(String, boolean) above
188 // may utilize it as well. CommandContext? How about StatusCollector there as well? 193 // may utilize it as well. CommandContext? How about StatusCollector there as well?
189 csetTransform = new ChangesetTransformer(repo, handler); 194 csetTransform = new ChangesetTransformer(repo, handler, pw);
190 if (file == null) { 195 if (file == null) {
191 repo.getChangelog().range(startRev, endRev, this); 196 repo.getChangelog().range(startRev, endRev, this);
192 } else { 197 } else {
193 HgDataFile fileNode = repo.getFileNode(file); 198 HgDataFile fileNode = repo.getFileNode(file);
194 fileNode.history(startRev, endRev, this); 199 fileNode.history(startRev, endRev, this);
242 // FIXME 247 // FIXME
243 } 248 }
244 count++; 249 count++;
245 csetTransform.next(revisionNumber, nodeid, cset); 250 csetTransform.next(revisionNumber, nodeid, cset);
246 } 251 }
252
253 private HgChangelog.ParentWalker getParentHelper() {
254 if (parentHelper == null) {
255 parentHelper = repo.getChangelog().new ParentWalker();
256 parentHelper.init();
257 }
258 return parentHelper;
259 }
260
247 261
248 public interface Handler { 262 public interface Handler {
249 /** 263 /**
250 * @param changeset not necessarily a distinct instance each time, {@link HgChangeset#clone() clone()} if need a copy. 264 * @param changeset not necessarily a distinct instance each time, {@link HgChangeset#clone() clone()} if need a copy.
251 */ 265 */