comparison src/grapher.cpp @ 515:fc35aa6d433e

A better effort to do the right thing wrt marking changesets as closed based on their relationship to closed heads
author Chris Cannam
date Thu, 20 Oct 2011 11:36:49 +0100
parents 67d18eaca830
children 2981d2defa61
comparison
equal deleted inserted replaced
514:306a62fe851e 515:fc35aa6d433e
422 Changeset *parent = m_changesets[parentId]; 422 Changeset *parent = m_changesets[parentId];
423 parent->addChild(id); 423 parent->addChild(id);
424 } 424 }
425 } 425 }
426 426
427 // Ensure the closed branches are all marked as closed 427 // Ensure the closed branch changesets are all marked as closed.
428 428 // A changeset should be marked as closed (i) if it is in the list
429 foreach (QString closedId, m_closedIds) { 429 // of closed heads [and has no children]; or (ii) all of its
430 // children that have the same branch name as it are marked as
431 // closed [and there is at least one of those]
432
433 QStringList potentiallyClosed;
434 potentiallyClosed = QStringList::fromSet(m_closedIds);
435
436 while (!potentiallyClosed.empty()) {
430 437
431 if (!m_changesets.contains(closedId)) continue; 438 QString id = *potentiallyClosed.begin();
432 439
433 Changeset *cs = m_changesets[closedId]; 440 if (m_changesets.contains(id)) {
434 QString branch = cs->branch(); 441
435 442 Changeset *cs = m_changesets[id];
436 while (cs) { 443 QString branch = cs->branch();
437 444
438 if (cs->children().size() > 1 || !cs->isOnBranch(branch)) { 445 bool closed = false;
439 break; 446
440 } 447 if (m_closedIds.contains(id)) {
441 448 closed = true;
442 cs->setClosed(true);
443
444 if (cs->parents().size() >= 1) {
445 //!!! this is wrong, not adequate for merges in-branch
446 QString pid = cs->parents()[0];
447 if (!m_changesets.contains(pid)) break;
448 cs = m_changesets[pid];
449 } else { 449 } else {
450 cs = 0; 450 closed = true;
451 } 451 foreach (QString childId, cs->children()) {
452 } 452 if (!m_changesets.contains(childId)) continue;
453 Changeset *ccs = m_changesets[childId];
454 if (ccs->isOnBranch(branch)) {
455 if (!ccs->closed()) {
456 closed = false;
457 break;
458 }
459 }
460 }
461 }
462
463 if (closed) {
464 // set closed on this cset and its direct simple parents
465 while (cs) {
466 cs->setClosed(true);
467 if (cs->parents().size() == 1) {
468 QString pid = cs->parents()[0];
469 if (!m_changesets.contains(pid)) break;
470 cs = m_changesets[pid];
471 if (cs->children().size() > 1) {
472 potentiallyClosed.push_back(pid); // examine later
473 cs = 0;
474 }
475 } else if (cs->parents().size() > 1) {
476 foreach (QString pid, cs->parents()) {
477 potentiallyClosed.push_back(pid); // examine later
478 }
479 cs = 0;
480 } else {
481 cs = 0;
482 }
483 }
484 }
485 }
486
487 potentiallyClosed.erase(potentiallyClosed.begin());
453 } 488 }
454 489
455 // Create (but don't yet position) the changeset items 490 // Create (but don't yet position) the changeset items
456 491
457 foreach (Changeset *cs, csets) { 492 foreach (Changeset *cs, csets) {