Am 06.11.2010 um 13:32 schrieb sa...@lyx.org: > Author: sanda > Date: Sat Nov 6 13:32:47 2010 > New Revision: 36162 > URL: http://www.lyx.org/trac/changeset/36162 > > Log: > Comment
Thank you, better indeed. I made an attempt to really compute a SVN::isRevertWithConfirmation() result. I used "svn status" to substitute "svn diff" - this should be cheaper. The isModified() helper method can be used for SVN::isCheckInWithConfirmation() too. Does this make sense? Stephan
Index: src/VCBackend.h =================================================================== --- src/VCBackend.h (Revision 36161) +++ src/VCBackend.h (Arbeitskopie) @@ -376,6 +376,8 @@ bool isLocked() const; /// acquire/release write lock for the current file void fileLock(bool lock, support::FileName const & tmpf, std::string & status); + /// check for local modification + bool isModified(); private: support::FileName file_; Index: src/VCBackend.cpp =================================================================== --- src/VCBackend.cpp (Revision 36161) +++ src/VCBackend.cpp (Arbeitskopie) @@ -1073,21 +1073,26 @@ return N_("Error: Could not generate logfile."); } - doVCCommand("svn commit -m \"" + msg + "\" " - + quoteName(onlyFileName(owner_->absFileName())) - + " > " + quoteName(tmpf.toFilesystemEncoding()), - FileName(owner_->filePath())); - string log; - string res = scanLogFile(tmpf, log); - if (!res.empty()) - frontend::Alert::error(_("Revision control error."), + + if (isModified()) { + doVCCommand("svn commit -m \"" + msg + "\" " + + quoteName(onlyFileName(owner_->absFileName())) + + " > " + quoteName(tmpf.toFilesystemEncoding()), + FileName(owner_->filePath())); + + string res = scanLogFile(tmpf, log); + if (!res.empty()) + frontend::Alert::error(_("Revision control error."), _("Error when committing to repository.\n" - "You have to manually resolve the problem.\n" - "LyX will reopen the document after you press OK.")); - else + "You have to manually resolve the problem.\n" + "LyX will reopen the document after you press OK.")); + else + fileLock(false, tmpf, log); + } else { fileLock(false, tmpf, log); - + } + tmpf.erase(); return log.empty() ? string() : "SVN: " + log; } @@ -1102,30 +1107,36 @@ } -bool SVN::isCheckInWithConfirmation() +bool SVN::isModified() { - // FIXME one day common getDiff and perhaps OpMode for all backends - + // FIXME one day common getDiff/isModified and perhaps OpMode for all backends FileName tmpf = FileName::tempName("lyxvcout"); if (tmpf.empty()) { LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf); return true; } - doVCCommandCall("svn diff " + quoteName(owner_->absFileName()) - + " > " + quoteName(tmpf.toFilesystemEncoding()), - FileName(owner_->filePath())); + doVCCommand("svn status " + quoteName(onlyFileName(owner_->absFileName())) + + " > " + quoteName(tmpf.toFilesystemEncoding()), + FileName(owner_->filePath())); + + ifstream ifs(tmpf.toFilesystemEncoding().c_str()); + string line; + bool result = false; + + while (!result && ifs) { + getline(ifs, line); + result = !line.empty(); + } + return result; +} - docstring diff = tmpf.fileContents("UTF-8"); - tmpf.erase(); - - if (diff.empty()) - return false; - - return true; +bool SVN::isCheckInWithConfirmation() +{ + return isModified(); } - - + + // FIXME Correctly return code should be checked instead of this. // This would need another solution than just plain startscript. // Hint from Andre': QProcess::readAllStandardError()... @@ -1342,7 +1353,7 @@ bool SVN::isRevertWithConfirmation() { //FIXME owner && diff - return true; + return !owner_->isClean() || isModified(); }