]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / VCBackend.cpp
index c8afe18d3d5f6d2a1442a5c429f7f356da2f659f..5d8e33d4eaeb0951c70c6e357e22e80456729b6f 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"
@@ -41,7 +44,7 @@ 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);
 }
 
 
@@ -209,14 +212,14 @@ bool RCS::checkOutEnabled()
 }
 
 
-string RCS::repoSynchro()
+string RCS::repoUpdate()
 {
        lyxerr << "Sorry, not implemented." << endl;
        return string();
 }
 
 
-bool RCS::repoSynchroEnabled()
+bool RCS::repoUpdateEnabled()
 {
        return false;
 }
@@ -270,7 +273,11 @@ void RCS::getLog(FileName const & tmpf)
 
 bool RCS::toggleReadOnlyEnabled()
 {
-       return true;
+       // This got broken somewhere along lfuns dispatch reorganization.
+       // reloadBuffer would be needed after this, but thats problematic
+       // since we are inside Buffer::dispatch.
+       // return true;
+       return false;
 }
 
 
@@ -397,14 +404,14 @@ bool CVS::checkOutEnabled()
 }
 
 
-string CVS::repoSynchro()
+string CVS::repoUpdate()
 {
        lyxerr << "Sorry, not implemented." << endl;
        return string();
 }
 
 
-bool CVS::repoSynchroEnabled()
+bool CVS::repoUpdateEnabled()
 {
        return false;
 }
@@ -513,6 +520,8 @@ FileName const SVN::findFile(FileName const & file)
 void SVN::scanMaster()
 {
        locker_.clear();
+       // vcstatus code is somewhat superflous, until we want
+       // to implement read-only toggle for svn.
        vcstatus = NOLOCKING;
        if (checkLockMode()) {
                if (isLocked()) {
@@ -520,7 +529,7 @@ void SVN::scanMaster()
                        vcstatus = LOCKED;
                } else {
                        locker_ = "Unlocked";
-                       vcstatus = LOCKED;
+                       vcstatus = UNLOCKED;
                }
        }
 }
@@ -560,9 +569,8 @@ bool SVN::checkLockMode()
 
 bool SVN::isLocked() const
 {
-       //refresh file info
-       FileName file(file_.absFilename());
-       return !file.isReadOnly();
+       file_.refresh();
+       return !file_.isReadOnly();
 }
 
 
@@ -597,7 +605,7 @@ string SVN::checkIn(string const & msg)
                fileLock(false, tmpf, log);
 
        tmpf.erase();
-       return "SVN: " + log;
+       return log.empty() ? string() : "SVN: " + log;
 }
 
 
@@ -641,11 +649,12 @@ void SVN::fileLock(bool lock, FileName const & tmpf, string &status)
        if (!locked_mode_ || (isLocked() == lock))
                return;
 
-       string arg = lock ? "lock " : "unlock ";
+       string const arg = lock ? "lock " : "unlock ";
        doVCCommand("svn "+ arg + quoteName(onlyFilename(owner_->absFileName()))
                    + " > " + 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) {
@@ -685,13 +694,13 @@ string SVN::checkOut()
                frontend::Alert::error(_("Revision control error."),
                        bformat(_("Error when updating from repository.\n"
                                "You have to manually resolve the conflicts NOW!\n'%1$s'.\n\n"
-                               "After pressing OK, LyX will try to reopen resolved document."),
+                               "After pressing OK, LyX will try to reopen the resolved document."),
                        from_local8bit(res)));
 
        fileLock(true, tmpf, log);
 
        tmpf.erase();
-       return "SVN: " + log;
+       return log.empty() ? string() : "SVN: " + log;
 }
 
 
@@ -704,7 +713,7 @@ bool SVN::checkOutEnabled()
 }
 
 
-string SVN::repoSynchro()
+string SVN::repoUpdate()
 {
        FileName tmpf = FileName::tempName("lyxvcout");
        if (tmpf.empty()) {
@@ -720,23 +729,30 @@ string SVN::repoSynchro()
                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"
-                               "Synchronizing with repository will discard "
-                               "any uncommitted changes in the directory:\n%1$s"
+                               "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 const ret = frontend::Alert::prompt(_("Changes detected"),
+               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"));
-               if (ret) {
+                       hideDialogs("file", 0);
+               }
+               if (ret == 1 ) {
                        tmpf.erase();
                        return string();
                }
        }
 
-       doVCCommand("svn revert -R " + quoteName(owner_->filePath())
-       + " > " + quoteName(tmpf.toFilesystemEncoding()),
-       FileName(owner_->filePath()));
-       res = "Revert log:\n" + tmpf.fileContents("UTF-8");
-       doVCCommand("svn update " + quoteName(owner_->filePath())
+       // 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");
@@ -747,7 +763,7 @@ string SVN::repoSynchro()
 }
 
 
-bool SVN::repoSynchroEnabled()
+bool SVN::repoUpdateEnabled()
 {
        return true;
 }