# HG changeset patch # User Jari Korhonen # Date 1276902096 -10800 # Node ID 43e3b271d293c61f6df65425416c589ecd1e6a90 # Parent ff8d64625aa3f018dd317c5d69fdd418df542028 Version 0.5.2. Added hg tag, .hgignore editing. diff -r ff8d64625aa3 -r 43e3b271d293 common.h --- a/common.h Sat Jun 19 00:23:09 2010 +0300 +++ b/common.h Sat Jun 19 02:01:36 2010 +0300 @@ -8,7 +8,7 @@ #include #define APPNAME "HgExplorer" -#define APPVERSION "0.5.1" +#define APPVERSION "0.5.2" #define MY_ICON_SIZE 32 #define REPOMENU_TITLE "Repository actions" #define WORKFOLDERMENU_TITLE "Workfolder actions" diff -r ff8d64625aa3 -r 43e3b271d293 mainwindow.cpp --- a/mainwindow.cpp Sat Jun 19 00:23:09 2010 +0300 +++ b/mainwindow.cpp Sat Jun 19 02:01:36 2010 +0300 @@ -8,6 +8,7 @@ #include #include #include +#include #include "mainwindow.h" #include "settingsdialog.h" @@ -244,18 +245,18 @@ } } -int MainWindow::getCommitComment(QString& comment) +int MainWindow::getCommentOrTag(QString& commentOrTag, QString question, QString dlgTitle) { int ret; QDialog dlg(this); - QLabel *commentLabel = new QLabel(tr("Comment:")); - QLineEdit *commentEdit = new QLineEdit; - commentEdit -> setFixedWidth(400); + QLabel *commentLabel = new QLabel(question); + QLineEdit *commentOrTagEdit = new QLineEdit; + commentOrTagEdit -> setFixedWidth(400); QHBoxLayout *commentLayout = new QHBoxLayout; commentLayout -> addWidget(commentLabel); - commentLayout -> addWidget(commentEdit); + commentLayout -> addWidget(commentOrTagEdit); QPushButton *btnOk = new QPushButton(tr("Ok")); QPushButton *btnCancel = new QPushButton(tr("Cancel")); @@ -269,13 +270,13 @@ dlg.setLayout(mainLayout); - dlg.setWindowTitle(tr("Save (commit)")); + dlg.setWindowTitle(dlgTitle); connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept())); connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject())); ret = dlg.exec(); - comment = commentEdit -> text(); + commentOrTag = commentOrTagEdit -> text(); return ret; } @@ -286,12 +287,10 @@ QStringList params; QString comment; - if (QDialog::Accepted == getCommitComment(comment)) + if (QDialog::Accepted == getCommentOrTag(comment, tr("Comment:"), tr("Save (commit)"))) { if (!comment.isEmpty()) { - QString currentFile = hgExp -> getCurrentFileListLine(); - if ((justMerged == false) && (areAllSelectedCommitable(hgExp -> workFolderFileList))) { //User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files) @@ -317,6 +316,60 @@ } } +QString MainWindow::filterTag(QString tag) +{ + for(int i = 0; i < tag.size(); i++) + { + if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.'))) + { + //ok + } + else + { + tag[i] = QChar('_'); + } + } + return tag; +} + + +void MainWindow::hgTag() +{ + if (runningAction == ACT_NONE) + { + QStringList params; + QString tag; + + if (QDialog::Accepted == getCommentOrTag(tag, tr("Tag:"), tr("Tag"))) + { + if (!tag.isEmpty()) + { + params << "tag" << "--user" << userInfo << filterTag(tag); + + runner -> startProc(getHgBinaryName(), workFolderPath, params); + runningAction = ACT_TAG; + } + } + } +} + + +void MainWindow::hgIgnore() +{ + if (runningAction == ACT_NONE) + { + QString hgIgnorePath; + + hgIgnorePath = "file:///"; + hgIgnorePath += workFolderPath; + hgIgnorePath += ".hgignore"; + + QDesktopServices::openUrl(QUrl(hgIgnorePath, QUrl::TolerantMode)); + } +} + + + void MainWindow::hgFileDiff() { if (runningAction == ACT_NONE) @@ -525,7 +578,6 @@ } - QString MainWindow::listAllUpIpV4Addresses() { QString ret; @@ -889,6 +941,7 @@ case ACT_CHGSETDIFF: case ACT_REVERT: case ACT_SERVE: + case ACT_TAG: shouldHgStat = true; break; @@ -964,6 +1017,8 @@ connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert())); connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge())); connect(hgRetryMergeAct, SIGNAL(triggered()), this, SLOT(hgRetryMerge())); + connect(hgTagAct, SIGNAL(triggered()), this, SLOT(hgTag())); + connect(hgIgnoreAct, SIGNAL(triggered()), this, SLOT(hgIgnore())); connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings())); @@ -1049,6 +1104,8 @@ hgResolveMarkAct -> setEnabled(localRepoActionsEnabled); hgAnnotateAct -> setEnabled(localRepoActionsEnabled); hgServeAct -> setEnabled(localRepoActionsEnabled); + hgTagAct -> setEnabled(localRepoActionsEnabled); + hgIgnoreAct -> setEnabled(localRepoActionsEnabled); hgExp -> enableDisableOtherTabs(tabPage); @@ -1114,6 +1171,11 @@ hgRetryMergeAct -> setEnabled(false); } + if (hgExp -> localRepoHeadsList->count() < 1) + { + hgTagAct -> setEnabled(false); + } + QString currentFile = hgExp -> getCurrentFileListLine(); if (!currentFile.isEmpty()) { @@ -1227,6 +1289,12 @@ hgRetryMergeAct = new QAction(tr("Retry merge"), this); hgRetryMergeAct -> setStatusTip(tr("Retry merge after failed merge attempt.")); + hgTagAct = new QAction(tr("Tag revision"), this); + hgTagAct -> setStatusTip(tr("Give decsriptive name (tag) to current workfolder parent revision.")); + + hgIgnoreAct = new QAction(tr("Edit .hgignore"), this); + hgIgnoreAct -> setStatusTip(tr("Edit .hgignore file (file contains names of files that should be ignored by mercurial)")); + hgServeAct = new QAction(tr("Serve (via http)"), this); hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access")); @@ -1257,6 +1325,10 @@ advancedMenu -> addAction(hgResolveListAct); advancedMenu -> addAction(hgResolveMarkAct); advancedMenu -> addSeparator(); + advancedMenu -> addAction(hgTagAct); + advancedMenu -> addSeparator(); + advancedMenu -> addAction(hgIgnoreAct); + advancedMenu -> addSeparator(); advancedMenu -> addAction(hgServeAct); helpMenu = menuBar()->addMenu(tr("Help")); @@ -1297,7 +1369,6 @@ workFolderToolBar->addAction(hgAddAct); workFolderToolBar->addAction(hgRemoveAct); workFolderToolBar -> setMovable(false); - } diff -r ff8d64625aa3 -r 43e3b271d293 mainwindow.h --- a/mainwindow.h Sat Jun 19 00:23:09 2010 +0300 +++ b/mainwindow.h Sat Jun 19 02:01:36 2010 +0300 @@ -42,6 +42,7 @@ ACT_SERVE, ACT_RESOLVE_MARK, ACT_RETRY_MERGE, + ACT_TAG, }; @@ -97,7 +98,9 @@ void hgAnnotate(); void hgResolveList(); void hgResolveMark(); + void hgTag(); void hgServe(); + void hgIgnore(); private: void hgHeads(); @@ -110,7 +113,7 @@ void createStatusBar(); void readSettings(); void splitChangeSets(QStringList *list, QString hgLogOutput); - int getCommitComment(QString& comment); + int getCommentOrTag(QString& commentOrTag, QString question, QString dlgTitle); void presentLongStdoutToUser(QString stdo); void countModifications(QListWidget *workList, int& added, int& modified, int& removed, int& notTracked, int& selected, @@ -120,7 +123,7 @@ bool isSelectedDeletable(QListWidget *workList); bool areAllSelectedCommitable(QListWidget *workList); QString listAllUpIpV4Addresses(); - + QString filterTag(QString tag); //Actions enabled flags bool remoteRepoActionsEnabled; @@ -151,6 +154,8 @@ QAction *hgAnnotateAct; QAction *hgResolveListAct; QAction *hgResolveMarkAct; + QAction *hgTagAct; + QAction *hgIgnoreAct; QAction *hgServeAct; //Menus