]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
Save translators work
[lyx.git] / src / VCBackend.cpp
index aed6d012682f3ab1ea9158199e8280ba2ed5bde1..421a748451923bb63b707f4c6f12601e9c08e414 100644 (file)
@@ -80,7 +80,7 @@ FileName const RCS::findFile(FileName const & file)
        FileName tmp(file.absFilename() + ",v");
        LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
        if (tmp.isReadableFile()) {
-               LYXERR(Debug::LYXVC, "Yes " << file << " is under rcs.");
+               LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
                return tmp;
        }
 
@@ -88,7 +88,7 @@ FileName const RCS::findFile(FileName const & file)
        tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v");
        LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
        if (tmp.isReadableFile()) {
-               LYXERR(Debug::LYXVC, "Yes " << file << " it is under rcs.");
+               LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
                return tmp;
        }
 
@@ -204,6 +204,18 @@ bool RCS::checkOutEnabled()
        return owner_ && owner_->isReadonly();
 }
 
+string RCS::lockingToggle()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool RCS::lockingToggleEnabled()
+{
+       return false;
+}
+
 
 void RCS::revert()
 {
@@ -356,7 +368,7 @@ string CVS::checkOut()
        // cvs update or perhaps for cvs this should be a noop
        // we need to detect conflict (eg "C" in output)
        // before we can do this.
-       lyxerr << "Sorry not implemented." << endl;
+       lyxerr << "Sorry, not implemented." << endl;
        return string();
 }
 
@@ -367,6 +379,19 @@ bool CVS::checkOutEnabled()
 }
 
 
+string CVS::lockingToggle()
+{
+       lyxerr << "Sorry, not implemented." << endl;
+       return string();
+}
+
+
+bool CVS::lockingToggleEnabled()
+{
+       return false;
+}
+
+
 void CVS::revert()
 {
        // Reverts to the version in CVS repository and
@@ -389,7 +414,7 @@ void CVS::undoLast()
        // merge the current with the previous version
        // in a reverse patch kind of way, so that the
        // result is to revert the last changes.
-       lyxerr << "Sorry not implemented." << endl;
+       lyxerr << "Sorry, not implemented." << endl;
 }
 
 
@@ -501,7 +526,7 @@ bool SVN::checkLockMode()
 }
 
 
-bool SVN::isLocked()
+bool SVN::isLocked() const
 {
        //refresh file info
        FileName file(file_.absFilename());
@@ -533,7 +558,7 @@ string SVN::checkIn(string const & msg)
        string res = scanLogFile(tmpf, log);
        if (!res.empty())
                frontend::Alert::error(_("Revision control error."),
-                               _("Error when commiting to repository.\n"
+                               _("Error when committing to repository.\n"
                                "You have to manually resolve the problem.\n"
                                "After pressing OK, LyX will reopen the document."));
        else
@@ -569,6 +594,10 @@ string SVN::scanLogFile(FileName const & f, string & status)
                        ifs.close();
                        return line;
                }
+               if (contains(line, "svn:needs-lock")) {
+                       ifs.close();
+                       return line;
+               }
        }
        ifs.close();
        return string();
@@ -596,8 +625,9 @@ void SVN::fileLock(bool lock, FileName const & tmpf, string &status)
        if (!isLocked() && lock)
                frontend::Alert::error(_("Revision control error."),
                        _("Error when acquiring write lock.\n"
-                       "Most probably some other user edit the current document now!\n"
-                       "Check also the access to the repository."));
+                       "Most probably another user is editing\n"
+                       "the current document now!\n"
+                       "Also check the access to the repository."));
        if (isLocked() && !lock)
                frontend::Alert::error(_("Revision control error."),
                        _("Error when releasing write lock.\n"
@@ -642,6 +672,51 @@ bool SVN::checkOutEnabled()
 }
 
 
+string SVN::lockingToggle()
+{
+       FileName tmpf = FileName::tempName("lyxvcout");
+       if (tmpf.empty()) {
+               LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+               return N_("Error: Could not generate logfile.");
+       }
+
+       int ret = doVCCommand("svn proplist " + quoteName(onlyFilename(owner_->absFileName()))
+                   + " > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+       if (ret)
+               return string();
+
+       string log;
+       string res = scanLogFile(tmpf, log);
+       bool locking = contains(res, "svn:needs-lock");
+       if (!locking)
+               ret = doVCCommand("svn propset svn:needs-lock ON "
+                   + quoteName(onlyFilename(owner_->absFileName()))
+                   + " > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+       else
+               ret = doVCCommand("svn propdel svn:needs-lock "
+                   + quoteName(onlyFilename(owner_->absFileName()))
+                   + " > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+       if (ret)
+               return string();
+
+       tmpf.erase();
+       frontend::Alert::warning(_("VCN File Locking"),
+               (locking ? _("Locking property unset.") : _("Locking property set.")) + "\n"
+               + _("Do not forget to commit the locking property into the repository."),
+               true);
+
+       return string("SVN: ") +  N_("Locking property set.");
+}
+
+
+bool SVN::lockingToggleEnabled()
+{
+       return true;
+}
+
 void SVN::revert()
 {
        // Reverts to the version in CVS repository and
@@ -659,7 +734,7 @@ void SVN::undoLast()
        // merge the current with the previous version
        // in a reverse patch kind of way, so that the
        // result is to revert the last changes.
-       lyxerr << "Sorry not implemented." << endl;
+       lyxerr << "Sorry, not implemented." << endl;
 }