# HG changeset patch # User Chris Cannam # Date 1318934038 -3600 # Node ID f1fe20ff3c07b38eda3fa64b60876a892adf6f40 # Parent c623ce6b3104b755814bff920a37c8e139a8ac51 Refactor: set closed branch statuses before creating items diff -r c623ce6b3104 -r f1fe20ff3c07 src/grapher.cpp --- a/src/grapher.cpp Tue Oct 18 11:30:00 2011 +0100 +++ b/src/grapher.cpp Tue Oct 18 11:33:58 2011 +0100 @@ -419,6 +419,34 @@ parent->addChild(id); } } + + // Ensure the closed branches are all marked as closed + + foreach (QString closedId, m_closedIds) { + + if (!m_changesets.contains(closedId)) continue; + + Changeset *cs = m_changesets[closedId]; + QString branch = cs->branch(); + + while (cs) { + + if (cs->children().size() > 1 || !cs->isOnBranch(branch)) { + break; + } + + cs->setClosed(true); + + if (cs->parents().size() >= 1) { + //!!! this is wrong, not adequate for merges in-branch + QString pid = cs->parents()[0]; + if (!m_changesets.contains(pid)) break; + cs = m_changesets[pid]; + } else { + cs = 0; + } + } + } // Create (but don't yet position) the changeset items @@ -432,37 +460,11 @@ m_scene->addChangesetItem(item); } - // Ensure the closed branches are all marked as closed + // Ensure the closing changeset items are appropriately marked foreach (QString closedId, m_closedIds) { - if (!m_items.contains(closedId)) continue; - - Changeset *cs = m_changesets[closedId]; - ChangesetItem *item = m_items[closedId]; - - QString branch = cs->branch(); - - item->setClosingCommit(true); - - while (cs && item) { - - if (cs->children().size() > 1 || !cs->isOnBranch(branch)) { - break; - } - - cs->setClosed(true); - - int pcount = cs->parents().size(); - if (pcount >= 1) { - QString pid = cs->parents()[0]; - if (!m_items.contains(pid)) break; - cs = m_changesets[pid]; - item = m_items[pid]; - } else { - item = 0; - } - } + m_items[closedId]->setClosingCommit(true); } // Add the connecting lines