Mercurial > hg > easyhg
comparison mainwindow.cpp @ 198:4adbd5c9c15d
* Cut down number of command invocations by gleaning default remote path and current branch from hg files directly
author | Chris Cannam |
---|---|
date | Mon, 03 Jan 2011 14:31:22 +0000 |
parents | 2afac743acdf |
children | f16fe0db11f3 |
comparison
equal
deleted
inserted
replaced
197:2afac743acdf | 198:4adbd5c9c15d |
---|---|
198 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params)); | 198 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params)); |
199 } | 199 } |
200 | 200 |
201 void MainWindow::hgQueryPaths() | 201 void MainWindow::hgQueryPaths() |
202 { | 202 { |
203 // Quickest is to just read the file -- but fall back on hg | |
204 // command if we get confused | |
205 | |
206 QFileInfo hgrc(workFolderPath + "/.hg/hgrc"); | |
207 | |
208 if (hgrc.exists()) { | |
209 | |
210 QSettings s(hgrc.canonicalFilePath(), QSettings::IniFormat); | |
211 s.beginGroup("paths"); | |
212 remoteRepoPath = s.value("default").toString(); | |
213 | |
214 // We have to do this here, because commandCompleted won't be called | |
215 MultiChoiceDialog::addRecentArgument("local", workFolderPath); | |
216 MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath); | |
217 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath); | |
218 | |
219 hgQueryBranch(); | |
220 return; | |
221 } | |
222 | |
203 QStringList params; | 223 QStringList params; |
204 params << "paths"; | 224 params << "paths"; |
205 runner->requestAction(HgAction(ACT_QUERY_PATHS, workFolderPath, params)); | 225 runner->requestAction(HgAction(ACT_QUERY_PATHS, workFolderPath, params)); |
206 } | 226 } |
207 | 227 |
208 void MainWindow::hgQueryBranch() | 228 void MainWindow::hgQueryBranch() |
209 { | 229 { |
230 // Quickest is to just read the file -- but fall back on hg | |
231 // command if we get confused | |
232 | |
233 QFile hgbr(workFolderPath + "/.hg/branch"); | |
234 | |
235 if (hgbr.exists() && hgbr.open(QFile::ReadOnly)) { | |
236 | |
237 QByteArray ba = hgbr.readLine(); | |
238 currentBranch = QString::fromUtf8(ba).trimmed(); | |
239 | |
240 // We have to do this here, because commandCompleted won't be called | |
241 hgStat(); | |
242 return; | |
243 } | |
244 | |
210 QStringList params; | 245 QStringList params; |
211 params << "branch"; | 246 params << "branch"; |
212 runner->requestAction(HgAction(ACT_QUERY_BRANCH, workFolderPath, params)); | 247 runner->requestAction(HgAction(ACT_QUERY_BRANCH, workFolderPath, params)); |
213 } | 248 } |
214 | 249 |
1397 } | 1432 } |
1398 | 1433 |
1399 void MainWindow::commandFailed(HgAction action, QString output) | 1434 void MainWindow::commandFailed(HgAction action, QString output) |
1400 { | 1435 { |
1401 DEBUG << "MainWindow::commandFailed" << endl; | 1436 DEBUG << "MainWindow::commandFailed" << endl; |
1437 if (fsWatcher) fsWatcher->blockSignals(false); | |
1402 | 1438 |
1403 // Some commands we just have to ignore bad return values from: | 1439 // Some commands we just have to ignore bad return values from: |
1404 | 1440 |
1405 switch(action.action) { | 1441 switch(action.action) { |
1406 case ACT_NONE: | 1442 case ACT_NONE: |
1462 } | 1498 } |
1463 | 1499 |
1464 void MainWindow::commandCompleted(HgAction completedAction, QString output) | 1500 void MainWindow::commandCompleted(HgAction completedAction, QString output) |
1465 { | 1501 { |
1466 HGACTIONS action = completedAction.action; | 1502 HGACTIONS action = completedAction.action; |
1503 if (fsWatcher) fsWatcher->blockSignals(false); | |
1467 | 1504 |
1468 if (action == ACT_NONE) return; | 1505 if (action == ACT_NONE) return; |
1469 | 1506 |
1470 bool headsChanged = false; | 1507 bool headsChanged = false; |
1471 QStringList oldHeadIds; | 1508 QStringList oldHeadIds; |
1494 case ACT_QUERY_BRANCH: | 1531 case ACT_QUERY_BRANCH: |
1495 currentBranch = output.trimmed(); | 1532 currentBranch = output.trimmed(); |
1496 break; | 1533 break; |
1497 | 1534 |
1498 case ACT_STAT: | 1535 case ACT_STAT: |
1499 if (fsWatcher) fsWatcher->blockSignals(false); | |
1500 lastStatOutput = output; | 1536 lastStatOutput = output; |
1501 updateFileSystemWatcher(); | 1537 updateFileSystemWatcher(); |
1502 break; | 1538 break; |
1503 | 1539 |
1504 case ACT_RESOLVE_LIST: | 1540 case ACT_RESOLVE_LIST: |
1702 break; | 1738 break; |
1703 | 1739 |
1704 case ACT_LOG: | 1740 case ACT_LOG: |
1705 // we're done | 1741 // we're done |
1706 noMore = true; | 1742 noMore = true; |
1743 break; | |
1707 | 1744 |
1708 default: | 1745 default: |
1709 if (shouldHgStat) { | 1746 if (shouldHgStat) { |
1710 shouldHgStat = false; | 1747 shouldHgStat = false; |
1711 hgQueryPaths(); | 1748 hgQueryPaths(); |