comparison src/org/tmatesoft/hg/core/HgLogCommand.java @ 507:a6435c1a42d0

Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 12 Dec 2012 14:17:12 +0100
parents b3c16d1aede0
children ca5202afea90
comparison
equal deleted inserted replaced
506:27398bbfd543 507:a6435c1a42d0
328 fileNode.indexWalk(0, TIP, this); 328 fileNode.indexWalk(0, TIP, this);
329 return completeHistory; 329 return completeHistory;
330 } 330 }
331 }; 331 };
332 final ProgressSupport progressHelper = getProgressSupport(handler); 332 final ProgressSupport progressHelper = getProgressSupport(handler);
333 progressHelper.start(4);
334 final CancelSupport cancelHelper = getCancelSupport(handler, true); 333 final CancelSupport cancelHelper = getCancelSupport(handler, true);
335 cancelHelper.checkCancelled(); 334
336 HgDataFile fileNode = repo.getFileNode(file); 335 LinkedList<HgDataFile> fileRenamesQueue = buildFileRenamesQueue();
337 // build tree of nodes according to parents in file's revlog 336 progressHelper.start(4 * fileRenamesQueue.size());
338 final TreeBuildInspector treeBuildInspector = new TreeBuildInspector(); 337 do {
339 final HistoryNode[] completeHistory = treeBuildInspector.go(fileNode); 338 HgDataFile fileNode = fileRenamesQueue.removeLast();
340 progressHelper.worked(1); 339 cancelHelper.checkCancelled();
341 cancelHelper.checkCancelled(); 340 // build tree of nodes according to parents in file's revlog
342 ElementImpl ei = new ElementImpl(treeBuildInspector.commitRevisions.length); 341 final TreeBuildInspector treeBuildInspector = new TreeBuildInspector();
343 final ProgressSupport ph2; 342 final HistoryNode[] completeHistory = treeBuildInspector.go(fileNode);
344 if (treeBuildInspector.commitRevisions.length < 100 /*XXX is it really worth it? */) {
345 ei.initTransform();
346 repo.getChangelog().range(ei, treeBuildInspector.commitRevisions);
347 progressHelper.worked(1); 343 progressHelper.worked(1);
348 ph2 = new ProgressSupport.Sub(progressHelper, 2);
349 } else {
350 ph2 = new ProgressSupport.Sub(progressHelper, 3);
351 }
352 ph2.start(completeHistory.length);
353 // XXX shall sort completeHistory according to changeset numbers?
354 for (int i = 0; i < completeHistory.length; i++ ) {
355 final HistoryNode n = completeHistory[i];
356 handler.treeElement(ei.init(n));
357 ph2.worked(1);
358 cancelHelper.checkCancelled(); 344 cancelHelper.checkCancelled();
359 } 345 ElementImpl ei = new ElementImpl(treeBuildInspector.commitRevisions.length);
346 final ProgressSupport ph2;
347 if (treeBuildInspector.commitRevisions.length < 100 /*XXX is it really worth it? */) {
348 ei.initTransform();
349 repo.getChangelog().range(ei, treeBuildInspector.commitRevisions);
350 progressHelper.worked(1);
351 ph2 = new ProgressSupport.Sub(progressHelper, 2);
352 } else {
353 ph2 = new ProgressSupport.Sub(progressHelper, 3);
354 }
355 ph2.start(completeHistory.length);
356 // XXX shall sort completeHistory according to changeset numbers?
357 for (int i = 0; i < completeHistory.length; i++ ) {
358 final HistoryNode n = completeHistory[i];
359 handler.treeElement(ei.init(n));
360 ph2.worked(1);
361 cancelHelper.checkCancelled();
362 }
363 } while (!fileRenamesQueue.isEmpty());
360 progressHelper.done(); 364 progressHelper.done();
361 } 365 }
362 366
367 /**
368 * Follows file renames and build a list of all corresponding file nodes. If {@link #followHistory} is <code>false</code>,
369 * the list contains one element only, file node with the name of the file as it was specified by the user.
370 *
371 * @return list of file renames, with most recent file first
372 */
373 private LinkedList<HgDataFile> buildFileRenamesQueue() {
374 LinkedList<HgDataFile> rv = new LinkedList<HgDataFile>();
375 if (!followHistory) {
376 rv.add(repo.getFileNode(file));
377 return rv;
378 }
379 HgDataFile fileNode;
380 Path fp = file;
381 boolean isCopy;
382 do {
383 fileNode = repo.getFileNode(fp);
384 rv.addLast(fileNode);
385 if (isCopy = fileNode.isCopy()) {
386 fp = fileNode.getCopySourceName();
387 }
388 } while (isCopy);
389 return rv;
390 }
391
363 // 392 //
364 393
365 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { 394 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
366 if (limit > 0 && count >= limit) { 395 if (limit > 0 && count >= limit) {
367 return; 396 return;