]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
disable the del-suppresses-equation-label-at-end feature (not easy to describe, is...
[lyx.git] / src / VCBackend.cpp
index eece840988f54e6b2599495436aed9b986d2e2e7..31ae50e3f28dc991488ab7418d71b9dc74af1165 100644 (file)
@@ -36,13 +36,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);
 }
 
+
 int VCS::doVCCommand(string const & cmd, FileName const & path)
 {
        if (owner_)
@@ -185,11 +187,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 +208,20 @@ bool RCS::checkOutEnabled()
        return owner_ && owner_->isReadonly();
 }
 
+
+string RCS::repoSynchro()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool RCS::repoSynchroEnabled()
+{
+       return false;
+}
+
+
 string RCS::lockingToggle()
 {
        lyxerr << "Sorry, not implemented." << endl;
@@ -379,6 +397,19 @@ bool CVS::checkOutEnabled()
 }
 
 
+string CVS::repoSynchro()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool CVS::repoSynchroEnabled()
+{
+       return false;
+}
+
+
 string CVS::lockingToggle()
 {
        lyxerr << "Sorry, not implemented." << endl;
@@ -431,6 +462,7 @@ void CVS::getLog(FileName const & tmpf)
                    FileName(owner_->filePath()));
 }
 
+
 bool CVS::toggleReadOnlyEnabled()
 {
        return false;
@@ -672,6 +704,55 @@ bool SVN::checkOutEnabled()
 }
 
 
+string SVN::repoSynchro()
+{
+       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"
+                               "Synchronizing with repository will discard "
+                               "any uncommitted changes in the directory:\n%1$s"
+                               "\n\nContinue?"), file);
+               int const ret = frontend::Alert::prompt(_("Changes detected"),
+                               text, 0, 1, _("&Yes"), _("&No"));
+               if (ret) {
+                       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())
+       + " > " + 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::repoSynchroEnabled()
+{
+       return true;
+}
+
+
 string SVN::lockingToggle()
 {
        FileName tmpf = FileName::tempName("lyxvcout");
@@ -708,7 +789,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 +798,7 @@ bool SVN::lockingToggleEnabled()
        return true;
 }
 
+
 void SVN::revert()
 {
        // Reverts to the version in CVS repository and