Mercurial > hg > easyhg
comparison src/grapher.cpp @ 691:5b3bcb2d0943
Update handling of auth extension load failures on Windows: hg itself is returning a successful error code, so we must check the output in the extension test phase. Also fix a failure & crash when trying to use fallback auth mechanism
author | Chris Cannam |
---|---|
date | Mon, 10 Dec 2018 12:03:04 +0000 |
parents | ae67ea0af696 |
children |
comparison
equal
deleted
inserted
replaced
690:bfafe078df9a | 691:5b3bcb2d0943 |
---|---|
22 | 22 |
23 #include <QSettings> | 23 #include <QSettings> |
24 | 24 |
25 #include <iostream> | 25 #include <iostream> |
26 | 26 |
27 //#define GRAPHER_VERBOSE_DEBUG 1 | |
28 | |
27 Grapher::Grapher(ChangesetScene *scene) : | 29 Grapher::Grapher(ChangesetScene *scene) : |
28 m_scene(scene) | 30 m_scene(scene) |
29 { | 31 { |
30 QSettings settings; | 32 QSettings settings; |
31 settings.beginGroup("Presentation"); | 33 settings.beginGroup("Presentation"); |
72 if (!m_items.contains(id)) { | 74 if (!m_items.contains(id)) { |
73 return; | 75 return; |
74 } | 76 } |
75 Changeset *cs = m_changesets[id]; | 77 Changeset *cs = m_changesets[id]; |
76 ChangesetItem *item = m_items[id]; | 78 ChangesetItem *item = m_items[id]; |
79 #ifdef GRAPHER_VERBOSE_DEBUG | |
77 DEBUG << "layoutRow: Looking at " << id.toStdString() << endl; | 80 DEBUG << "layoutRow: Looking at " << id.toStdString() << endl; |
81 #endif | |
78 | 82 |
79 int row = 0; | 83 int row = 0; |
80 int nparents = cs->parents().size(); | 84 int nparents = cs->parents().size(); |
81 | 85 |
82 if (nparents > 0) { | 86 if (nparents > 0) { |
127 // row (we need it later, to avoid overwriting the connecting line) | 131 // row (we need it later, to avoid overwriting the connecting line) |
128 if (!m_uncommittedParents.empty() && m_uncommittedParents[0] == id) { | 132 if (!m_uncommittedParents.empty() && m_uncommittedParents[0] == id) { |
129 m_uncommittedParentRow = row; | 133 m_uncommittedParentRow = row; |
130 } | 134 } |
131 | 135 |
136 #ifdef GRAPHER_VERBOSE_DEBUG | |
132 DEBUG << "putting " << cs->id().toStdString() << " at row " << row | 137 DEBUG << "putting " << cs->id().toStdString() << " at row " << row |
133 << endl; | 138 << endl; |
134 | 139 #endif |
140 | |
135 item->setRow(row); | 141 item->setRow(row); |
136 m_handled.insert(id); | 142 m_handled.insert(id); |
137 } | 143 } |
138 | 144 |
139 void Grapher::layoutCol(QString id) | 145 void Grapher::layoutCol(QString id) |
140 { | 146 { |
141 if (m_handled.contains(id)) { | 147 if (m_handled.contains(id)) { |
148 #ifdef GRAPHER_VERBOSE_DEBUG | |
142 DEBUG << "Already looked at " << id.toStdString() << endl; | 149 DEBUG << "Already looked at " << id.toStdString() << endl; |
150 #endif | |
143 return; | 151 return; |
144 } | 152 } |
145 if (!m_changesets.contains(id)) { | 153 if (!m_changesets.contains(id)) { |
146 throw LayoutException(QString("Changeset %1 not in ID map").arg(id)); | 154 throw LayoutException(QString("Changeset %1 not in ID map").arg(id)); |
147 } | 155 } |
148 if (!m_items.contains(id)) { | 156 if (!m_items.contains(id)) { |
149 return; | 157 return; |
150 } | 158 } |
151 | 159 |
152 Changeset *cs = m_changesets[id]; | 160 Changeset *cs = m_changesets[id]; |
161 #ifdef GRAPHER_VERBOSE_DEBUG | |
153 DEBUG << "layoutCol: Looking at " << id.toStdString() << endl; | 162 DEBUG << "layoutCol: Looking at " << id.toStdString() << endl; |
163 #endif | |
154 | 164 |
155 ChangesetItem *item = m_items[id]; | 165 ChangesetItem *item = m_items[id]; |
156 | 166 |
157 int col = 0; | 167 int col = 0; |
158 int row = item->row(); | 168 int row = item->row(); |
207 col = findAvailableColumn(item->row(), col, false); | 217 col = findAvailableColumn(item->row(), col, false); |
208 } | 218 } |
209 break; | 219 break; |
210 } | 220 } |
211 | 221 |
222 #ifdef GRAPHER_VERBOSE_DEBUG | |
212 DEBUG << "putting " << cs->id().toStdString() << " at col " << col << endl; | 223 DEBUG << "putting " << cs->id().toStdString() << " at col " << col << endl; |
213 | 224 #endif |
225 | |
214 m_alloc[row].insert(col); | 226 m_alloc[row].insert(col); |
215 item->setColumn(col); | 227 item->setColumn(col); |
216 m_handled.insert(id); | 228 m_handled.insert(id); |
217 | 229 |
218 // If we're the first parent of the uncommitted item, it should be | 230 // If we're the first parent of the uncommitted item, it should be |
244 // look for merging children and children distant from us but in a | 256 // look for merging children and children distant from us but in a |
245 // straight line, and make sure nobody is going to overwrite their | 257 // straight line, and make sure nobody is going to overwrite their |
246 // connection lines | 258 // connection lines |
247 | 259 |
248 foreach (QString childId, cs->children()) { | 260 foreach (QString childId, cs->children()) { |
261 #ifdef GRAPHER_VERBOSE_DEBUG | |
249 DEBUG << "reserving connection line space" << endl; | 262 DEBUG << "reserving connection line space" << endl; |
263 #endif | |
250 if (!m_items.contains(childId)) continue; | 264 if (!m_items.contains(childId)) continue; |
251 Changeset *child = m_changesets[childId]; | 265 Changeset *child = m_changesets[childId]; |
252 int childRow = m_items[childId]->row(); | 266 int childRow = m_items[childId]->row(); |
253 if (child->parents().size() > 1 || | 267 if (child->parents().size() > 1 || |
254 child->isOnBranch(cs->branch())) { | 268 child->isOnBranch(cs->branch())) { |
270 child->parents().size() == 1) { | 284 child->parents().size() == 1) { |
271 special.push_back(childId); | 285 special.push_back(childId); |
272 } | 286 } |
273 } | 287 } |
274 if (special.size() == 2) { | 288 if (special.size() == 2) { |
289 #ifdef GRAPHER_VERBOSE_DEBUG | |
275 DEBUG << "handling split-in-two for children " << special[0] << " and " << special[1] << endl; | 290 DEBUG << "handling split-in-two for children " << special[0] << " and " << special[1] << endl; |
291 #endif | |
276 for (int i = 0; i < 2; ++i) { | 292 for (int i = 0; i < 2; ++i) { |
277 int off = i * 2 - 1; // 0 -> -1, 1 -> 1 | 293 int off = i * 2 - 1; // 0 -> -1, 1 -> 1 |
278 ChangesetItem *it = m_items[special[i]]; | 294 ChangesetItem *it = m_items[special[i]]; |
279 it->setColumn(findAvailableColumn(it->row(), col + off, true)); | 295 it->setColumn(findAvailableColumn(it->row(), col + off, true)); |
280 for (int r = row-1; r >= it->row(); --r) { | 296 for (int r = row-1; r >= it->row(); --r) { |
350 } | 366 } |
351 } | 367 } |
352 m_branchHomes[branch] = home; | 368 m_branchHomes[branch] = home; |
353 } | 369 } |
354 | 370 |
371 #ifdef GRAPHER_VERBOSE_DEBUG | |
355 foreach (QString branch, m_branchRanges.keys()) { | 372 foreach (QString branch, m_branchRanges.keys()) { |
356 DEBUG << branch.toStdString() << ": " << m_branchRanges[branch].first << " - " << m_branchRanges[branch].second << ", home " << m_branchHomes[branch] << endl; | 373 DEBUG << branch.toStdString() << ": " << m_branchRanges[branch].first << " - " << m_branchRanges[branch].second << ", home " << m_branchHomes[branch] << endl; |
357 } | 374 } |
375 #endif | |
358 } | 376 } |
359 | 377 |
360 static bool | 378 static bool |
361 compareChangesetsByDate(Changeset *const &a, Changeset *const &b) | 379 compareChangesetsByDate(Changeset *const &a, Changeset *const &b) |
362 { | 380 { |
628 // guaranteed. So, sort explicitly using the date comparator | 646 // guaranteed. So, sort explicitly using the date comparator |
629 // above | 647 // above |
630 | 648 |
631 qStableSort(csets.begin(), csets.end(), compareChangesetsByDate); | 649 qStableSort(csets.begin(), csets.end(), compareChangesetsByDate); |
632 | 650 |
651 #ifdef GRAPHER_VERBOSE_DEBUG | |
633 foreach (Changeset *cs, csets) { | 652 foreach (Changeset *cs, csets) { |
634 DEBUG << "id " << cs->id().toStdString() << ", ts " << cs->timestamp() | 653 DEBUG << "id " << cs->id().toStdString() << ", ts " << cs->timestamp() |
635 << ", date " << cs->datetime().toStdString() << endl; | 654 << ", date " << cs->datetime().toStdString() << endl; |
636 } | 655 } |
656 #endif | |
637 | 657 |
638 m_handled.clear(); | 658 m_handled.clear(); |
639 foreach (Changeset *cs, csets) { | 659 foreach (Changeset *cs, csets) { |
640 layoutRow(cs->id()); | 660 layoutRow(cs->id()); |
641 } | 661 } |
682 // We've given the uncommitted item a column, but not a row yet -- | 702 // We've given the uncommitted item a column, but not a row yet -- |
683 // it always goes at the top | 703 // it always goes at the top |
684 | 704 |
685 if (m_uncommitted) { | 705 if (m_uncommitted) { |
686 --minrow; | 706 --minrow; |
707 #ifdef GRAPHER_VERBOSE_DEBUG | |
687 DEBUG << "putting uncommitted item at row " << minrow << endl; | 708 DEBUG << "putting uncommitted item at row " << minrow << endl; |
709 #endif | |
688 m_uncommitted->setRow(minrow); | 710 m_uncommitted->setRow(minrow); |
689 } | 711 } |
690 | 712 |
691 // Changeset items that have nothing to either side of them can be | 713 // Changeset items that have nothing to either side of them can be |
692 // made double-width | 714 // made double-width |