comparison src/grapher.cpp @ 511:f1fe20ff3c07

Refactor: set closed branch statuses before creating items
author Chris Cannam
date Tue, 18 Oct 2011 11:33:58 +0100
parents c623ce6b3104
children 67d18eaca830
comparison
equal deleted inserted replaced
510:c623ce6b3104 511:f1fe20ff3c07
417 if (!m_changesets.contains(parentId)) continue; 417 if (!m_changesets.contains(parentId)) continue;
418 Changeset *parent = m_changesets[parentId]; 418 Changeset *parent = m_changesets[parentId];
419 parent->addChild(id); 419 parent->addChild(id);
420 } 420 }
421 } 421 }
422
423 // Ensure the closed branches are all marked as closed
424
425 foreach (QString closedId, m_closedIds) {
426
427 if (!m_changesets.contains(closedId)) continue;
428
429 Changeset *cs = m_changesets[closedId];
430 QString branch = cs->branch();
431
432 while (cs) {
433
434 if (cs->children().size() > 1 || !cs->isOnBranch(branch)) {
435 break;
436 }
437
438 cs->setClosed(true);
439
440 if (cs->parents().size() >= 1) {
441 //!!! this is wrong, not adequate for merges in-branch
442 QString pid = cs->parents()[0];
443 if (!m_changesets.contains(pid)) break;
444 cs = m_changesets[pid];
445 } else {
446 cs = 0;
447 }
448 }
449 }
422 450
423 // Create (but don't yet position) the changeset items 451 // Create (but don't yet position) the changeset items
424 452
425 foreach (Changeset *cs, csets) { 453 foreach (Changeset *cs, csets) {
426 QString id = cs->id(); 454 QString id = cs->id();
430 item->setZValue(0); 458 item->setZValue(0);
431 m_items[id] = item; 459 m_items[id] = item;
432 m_scene->addChangesetItem(item); 460 m_scene->addChangesetItem(item);
433 } 461 }
434 462
435 // Ensure the closed branches are all marked as closed 463 // Ensure the closing changeset items are appropriately marked
436 464
437 foreach (QString closedId, m_closedIds) { 465 foreach (QString closedId, m_closedIds) {
438
439 if (!m_items.contains(closedId)) continue; 466 if (!m_items.contains(closedId)) continue;
440 467 m_items[closedId]->setClosingCommit(true);
441 Changeset *cs = m_changesets[closedId];
442 ChangesetItem *item = m_items[closedId];
443
444 QString branch = cs->branch();
445
446 item->setClosingCommit(true);
447
448 while (cs && item) {
449
450 if (cs->children().size() > 1 || !cs->isOnBranch(branch)) {
451 break;
452 }
453
454 cs->setClosed(true);
455
456 int pcount = cs->parents().size();
457 if (pcount >= 1) {
458 QString pid = cs->parents()[0];
459 if (!m_items.contains(pid)) break;
460 cs = m_changesets[pid];
461 item = m_items[pid];
462 } else {
463 item = 0;
464 }
465 }
466 } 468 }
467 469
468 // Add the connecting lines 470 // Add the connecting lines
469 471
470 foreach (Changeset *cs, csets) { 472 foreach (Changeset *cs, csets) {