Mercurial > hg > easyhg
comparison src/mainwindow.cpp @ 419:69b2338c06e1 ignore
Add "Ignore this directory"; some fixes to ignore logic (though not yet enough)
author | Chris Cannam |
---|---|
date | Thu, 16 Jun 2011 20:35:05 +0100 |
parents | 93cb9005bb6f |
children | 653e9694a694 |
comparison
equal
deleted
inserted
replaced
418:93cb9005bb6f | 419:69b2338c06e1 |
---|---|
615 foreach (QString file, files) { | 615 foreach (QString file, files) { |
616 QString s = QFileInfo(file).suffix(); | 616 QString s = QFileInfo(file).suffix(); |
617 if (s != "") suffixes.insert(s); | 617 if (s != "") suffixes.insert(s); |
618 } | 618 } |
619 | 619 |
620 QString directory; | |
621 bool dirCount = 0; | |
622 foreach (QString file, files) { | |
623 QString d = QFileInfo(file).path(); | |
624 if (d != directory) { | |
625 ++dirCount; | |
626 directory = d; | |
627 } | |
628 } | |
629 if (dirCount != 1) directory = ""; | |
630 | |
620 HgIgnoreDialog::IgnoreType itype = | 631 HgIgnoreDialog::IgnoreType itype = |
621 HgIgnoreDialog::confirmIgnore | 632 HgIgnoreDialog::confirmIgnore |
622 (this, files, QStringList::fromSet(suffixes)); | 633 (this, files, QStringList::fromSet(suffixes), directory); |
623 | 634 |
624 DEBUG << "hgIgnoreFiles: Ignore type is " << itype << endl; | 635 DEBUG << "hgIgnoreFiles: Ignore type is " << itype << endl; |
625 | 636 |
626 // Now, .hgignore can be switched from regex to glob syntax | 637 // Now, .hgignore can be switched from regex to glob syntax |
627 // part-way through -- and glob is much simpler for us, so we | 638 // part-way through -- and glob is much simpler for us, so we |
672 } else if (itype == HgIgnoreDialog::IgnoreGivenFilesOnly) { | 683 } else if (itype == HgIgnoreDialog::IgnoreGivenFilesOnly) { |
673 // The default for glob seems to be to ignore the file | 684 // The default for glob seems to be to ignore the file |
674 // anywhere -- anchor the path to / to make it specific to | 685 // anywhere -- anchor the path to / to make it specific to |
675 // this file only | 686 // this file only |
676 //!!! check this! | 687 //!!! check this! |
688 //!!! ... no, it doesn't work. does this mean we need regex syntax? | |
677 foreach (QString f, files) { | 689 foreach (QString f, files) { |
678 out << "/" + f << endl; | 690 out << "/" + f << endl; |
679 } | 691 } |
680 } else { | 692 } else if (itype == HgIgnoreDialog::IgnoreAllFilesOfGivenNames) { |
681 foreach (QString f, files) { | 693 foreach (QString f, files) { |
682 out << f << endl; | 694 out << QFileInfo(f).fileName() << endl; |
683 } | 695 } |
684 } | 696 } else if (itype == HgIgnoreDialog::IgnoreWholeDirectory) { |
697 out << directory + "/" << endl; | |
698 } | |
699 | |
700 f.close(); | |
701 | |
685 | 702 |
686 //!!! report, and offer to edit .hgignore now | 703 //!!! report, and offer to edit .hgignore now |
704 | |
705 // (tell the user at least what lines have been added to the | |
706 // hgignore file and how to edit it) | |
687 | 707 |
708 // (also, if the hgignore is not tracked, suggest that they add | |
709 // it) | |
688 | 710 |
689 hgRefresh(); | 711 hgRefresh(); |
690 } | 712 } |
691 | 713 |
692 void MainWindow::hgUnIgnoreFiles(QStringList files) | 714 void MainWindow::hgUnIgnoreFiles(QStringList files) |