comparison mainwindow.cpp @ 305:7708149d252a

Avoid exception when incremental log is called for in a situation where the heads have not actually been determined yet -- we could end up adding all existing history as an incremental update and getting a duplicate changeset error
author Chris Cannam
date Sat, 26 Feb 2011 23:04:05 +0000
parents bb4702918ba6
children b280a2dc0512 978b8c03118a
comparison
equal deleted inserted replaced
303:bb4702918ba6 305:7708149d252a
323 m_runner->requestAction(HgAction(ACT_LOG, m_workFolderPath, params)); 323 m_runner->requestAction(HgAction(ACT_LOG, m_workFolderPath, params));
324 } 324 }
325 325
326 void MainWindow::hgLogIncremental(QStringList prune) 326 void MainWindow::hgLogIncremental(QStringList prune)
327 { 327 {
328 // Sometimes we can be called with prune empty -- it represents
329 // the current heads, but if we have none already and for some
330 // reason are being prompted for an incremental update, we may run
331 // into trouble. In that case, make this a full log instead
332
333 if (prune.empty()) {
334 hgLog();
335 return;
336 }
337
328 QStringList params; 338 QStringList params;
329 params << "log"; 339 params << "log";
330 340
331 foreach (QString p, prune) { 341 foreach (QString p, prune) {
332 params << "--prune" << Changeset::hashOf(p); 342 params << "--prune" << Changeset::hashOf(p);
904 return ret; 914 return ret;
905 } 915 }
906 916
907 void MainWindow::clearState() 917 void MainWindow::clearState()
908 { 918 {
919 DEBUG << "MainWindow::clearState" << endl;
909 foreach (Changeset *cs, m_currentParents) delete cs; 920 foreach (Changeset *cs, m_currentParents) delete cs;
910 m_currentParents.clear(); 921 m_currentParents.clear();
911 foreach (Changeset *cs, m_currentHeads) delete cs; 922 foreach (Changeset *cs, m_currentHeads) delete cs;
912 m_currentHeads.clear(); 923 m_currentHeads.clear();
913 m_currentBranch = ""; 924 m_currentBranch = "";
1903 oldHeadIds = Changeset::getIds(m_currentHeads); 1914 oldHeadIds = Changeset::getIds(m_currentHeads);
1904 Changesets newHeads = Changeset::parseChangesets(output); 1915 Changesets newHeads = Changeset::parseChangesets(output);
1905 QStringList newHeadIds = Changeset::getIds(newHeads); 1916 QStringList newHeadIds = Changeset::getIds(newHeads);
1906 if (oldHeadIds != newHeadIds) { 1917 if (oldHeadIds != newHeadIds) {
1907 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl; 1918 DEBUG << "Heads changed, will prompt an incremental log if appropriate" << endl;
1919 DEBUG << "Old heads: " << oldHeadIds.join(",") << endl;
1920 DEBUG << "New heads: " << newHeadIds.join(",") << endl;
1908 headsChanged = true; 1921 headsChanged = true;
1909 foreach (Changeset *cs, m_currentHeads) delete cs; 1922 foreach (Changeset *cs, m_currentHeads) delete cs;
1910 m_currentHeads = newHeads; 1923 m_currentHeads = newHeads;
1911 } 1924 }
1912 } 1925 }