]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
SVN: Return an empty string when the log message is empty.
[lyx.git] / src / VCBackend.cpp
index eece840988f54e6b2599495436aed9b986d2e2e7..bf117d249462f3e94d3b4d8b0afae8da2f1afddf 100644 (file)
 
 #include "VCBackend.h"
 #include "Buffer.h"
+#include "LyXFunc.h"
+#include "FuncRequest.h"
 
 #include "frontends/alert.h"
+#include "frontends/Application.h"
 
 #include "support/debug.h"
 #include "support/filetools.h"
@@ -36,13 +39,15 @@ using boost::smatch;
 namespace lyx {
 
 
-int VCS::doVCCommandCall(string const & cmd, FileName const & path){
+int VCS::doVCCommandCall(string const & cmd, FileName const & path)
+{
        LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
        Systemcall one;
        support::PathChanger p(path);
-       return one.startscript(Systemcall::Wait, cmd);
+       return one.startscript(Systemcall::Wait, cmd, false);
 }
 
+
 int VCS::doVCCommand(string const & cmd, FileName const & path)
 {
        if (owner_)
@@ -185,11 +190,13 @@ string RCS::checkIn(string const & msg)
        return ret ? string() : "RCS: Proceeded";
 }
 
+
 bool RCS::checkInEnabled()
 {
        return owner_ && !owner_->isReadonly();
 }
 
+
 string RCS::checkOut()
 {
        owner_->markClean();
@@ -204,6 +211,20 @@ bool RCS::checkOutEnabled()
        return owner_ && owner_->isReadonly();
 }
 
+
+string RCS::repoUpdate()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool RCS::repoUpdateEnabled()
+{
+       return false;
+}
+
+
 string RCS::lockingToggle()
 {
        lyxerr << "Sorry, not implemented." << endl;
@@ -379,6 +400,19 @@ bool CVS::checkOutEnabled()
 }
 
 
+string CVS::repoUpdate()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool CVS::repoUpdateEnabled()
+{
+       return false;
+}
+
+
 string CVS::lockingToggle()
 {
        lyxerr << "Sorry, not implemented." << endl;
@@ -431,6 +465,7 @@ void CVS::getLog(FileName const & tmpf)
                    FileName(owner_->filePath()));
 }
 
+
 bool CVS::toggleReadOnlyEnabled()
 {
        return false;
@@ -565,7 +600,7 @@ string SVN::checkIn(string const & msg)
                fileLock(false, tmpf, log);
 
        tmpf.erase();
-       return "SVN: " + log;
+       return log.empty() ? string() : "SVN: " + log;
 }
 
 
@@ -614,6 +649,7 @@ void SVN::fileLock(bool lock, FileName const & tmpf, string &status)
                    + " > " + quoteName(tmpf.toFilesystemEncoding()),
                    FileName(owner_->filePath()));
 
+       // Lock error messages go unfortunately on stderr and are unreachible this way.
        ifstream ifs(tmpf.toFilesystemEncoding().c_str());
        string line;
        while (ifs) {
@@ -659,7 +695,7 @@ string SVN::checkOut()
        fileLock(true, tmpf, log);
 
        tmpf.erase();
-       return "SVN: " + log;
+       return log.empty() ? string() : "SVN: " + log;
 }
 
 
@@ -672,6 +708,62 @@ bool SVN::checkOutEnabled()
 }
 
 
+string SVN::repoUpdate()
+{
+       FileName tmpf = FileName::tempName("lyxvcout");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return N_("Error: Could not generate logfile.");
+       }
+
+       doVCCommand("svn diff " + quoteName(owner_->filePath())
+       + " > " + quoteName(tmpf.toFilesystemEncoding()),
+       FileName(owner_->filePath()));
+       docstring res = tmpf.fileContents("UTF-8");
+       if (!res.empty()) {
+               LYXERR(Debug::LYXVC, "Diff detected:\n" << res);
+               docstring const file = from_utf8(owner_->filePath());
+               docstring text = bformat(_("There were detected changes "
+                               "in the working directory:\n%1$s\n\n"
+                               "In case of file conflict version of the local directory files "
+                               "will be preferred."
+                               "\n\nContinue?"), file);
+               int ret = frontend::Alert::prompt(_("Changes detected"),
+                               text, 0, 1, _("&Yes"), _("&No"), _("View &Log ..."));
+               if (ret == 2 ) {
+                       dispatch(FuncRequest(LFUN_DIALOG_SHOW, "file " + tmpf.absFilename()));
+                       ret = frontend::Alert::prompt(_("Changes detected"),
+                               text, 0, 1, _("&Yes"), _("&No"));
+                       hideDialogs("file", 0);
+               }
+               if (ret == 1 ) {
+                       tmpf.erase();
+                       return string();
+               }
+       }
+
+       // Reverting looks too harsh, see bug #6255.
+       // doVCCommand("svn revert -R " + quoteName(owner_->filePath())
+       // + " > " + quoteName(tmpf.toFilesystemEncoding()),
+       // FileName(owner_->filePath()));
+       // res = "Revert log:\n" + tmpf.fileContents("UTF-8");
+       doVCCommand("svn update --accept mine-full " + quoteName(owner_->filePath())
+       + " > " + quoteName(tmpf.toFilesystemEncoding()),
+       FileName(owner_->filePath()));
+       res += "Update log:\n" + tmpf.fileContents("UTF-8");
+
+       LYXERR(Debug::LYXVC, res);
+       tmpf.erase();
+       return to_utf8(res);
+}
+
+
+bool SVN::repoUpdateEnabled()
+{
+       return true;
+}
+
+
 string SVN::lockingToggle()
 {
        FileName tmpf = FileName::tempName("lyxvcout");
@@ -708,7 +800,7 @@ string SVN::lockingToggle()
                + _("Do not forget to commit the locking property into the repository."),
                true);
 
-       return N_("SVN: Locking property set.");
+       return string("SVN: ") +  N_("Locking property set.");
 }
 
 
@@ -717,6 +809,7 @@ bool SVN::lockingToggleEnabled()
        return true;
 }
 
+
 void SVN::revert()
 {
        // Reverts to the version in CVS repository and