2003-08-23 00:17:00 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file LyXVC.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Allan Rae
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXVC.h"
|
|
|
|
#include "VCBackend.h"
|
|
|
|
#include "Buffer.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
#include "frontends/alert.h"
|
2002-03-25 22:07:48 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2002-03-25 22:07:48 +00:00
|
|
|
#include "support/filetools.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/gettext.h"
|
2007-11-13 23:50:28 +00:00
|
|
|
#include "support/lstrings.h"
|
2014-06-09 11:05:50 +00:00
|
|
|
#include "support/TempFile.h"
|
2002-03-25 22:07:48 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
namespace Alert = frontend::Alert;
|
2006-10-07 16:47:54 +00:00
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXVC::LyXVC()
|
|
|
|
{
|
2020-05-03 06:32:39 +00:00
|
|
|
owner_ = nullptr;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-19 09:55:08 +00:00
|
|
|
docstring LyXVC::vcstatus() const
|
2016-09-06 09:17:10 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2016-10-19 09:55:08 +00:00
|
|
|
return docstring();
|
2016-10-19 12:10:47 +00:00
|
|
|
if (locking())
|
2020-12-17 21:56:50 +00:00
|
|
|
return bformat(_("%1$s lock"), from_ascii(vcs_->vcname()));
|
2016-10-19 12:10:47 +00:00
|
|
|
else
|
2020-12-17 21:56:50 +00:00
|
|
|
return from_ascii(vcs_->vcname());
|
2016-09-06 09:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-15 21:01:19 +00:00
|
|
|
bool LyXVC::fileInVC(FileName const & fn)
|
|
|
|
{
|
|
|
|
if (!RCS::findFile(fn).empty())
|
|
|
|
return true;
|
|
|
|
if (!CVS::findFile(fn).empty())
|
|
|
|
return true;
|
2020-12-18 21:23:31 +00:00
|
|
|
if (SVN::findFile(fn))
|
2012-11-15 21:01:19 +00:00
|
|
|
return true;
|
2020-12-18 21:23:31 +00:00
|
|
|
if (GIT::findFile(fn))
|
2013-02-06 21:07:31 +00:00
|
|
|
return true;
|
2012-11-15 21:01:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
bool LyXVC::file_found_hook(FileName const & fn)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2006-12-02 16:07:15 +00:00
|
|
|
FileName found_file;
|
1999-11-09 23:52:04 +00:00
|
|
|
// Check if file is under RCS
|
2007-11-25 11:18:16 +00:00
|
|
|
if (!(found_file = RCS::findFile(fn)).empty()) {
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_.reset(new RCS(found_file, owner_));
|
1999-11-09 23:52:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Check if file is under CVS
|
2007-11-25 11:18:16 +00:00
|
|
|
if (!(found_file = CVS::findFile(fn)).empty()) {
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_.reset(new CVS(found_file, owner_));
|
1999-09-27 18:44:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-07-22 08:59:15 +00:00
|
|
|
// Check if file is under SVN
|
2020-12-18 21:23:31 +00:00
|
|
|
if (SVN::findFile(fn)) {
|
|
|
|
vcs_.reset(new SVN(owner_));
|
2008-07-22 08:59:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-06 21:07:31 +00:00
|
|
|
// Check if file is under GIT
|
2020-12-18 21:23:31 +00:00
|
|
|
if (GIT::findFile(fn)) {
|
|
|
|
vcs_.reset(new GIT(owner_));
|
2013-02-06 21:07:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-07-22 08:59:15 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// file is not under any VCS.
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_.reset(nullptr);
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
bool LyXVC::file_not_found_hook(FileName const & fn)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-18 20:53:45 +00:00
|
|
|
// Check if file is under version control.
|
2020-12-19 17:29:10 +00:00
|
|
|
// This happens if we are trying to load file that does not exist.
|
|
|
|
// It may yet exist in the repository and so could be checked out.
|
2012-11-15 21:01:19 +00:00
|
|
|
bool foundRCS = !RCS::findFile(fn).empty();
|
|
|
|
bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
|
2020-12-18 21:23:31 +00:00
|
|
|
bool foundSVN = (foundRCS || foundCVS) ? false : SVN::findFile(fn);
|
|
|
|
bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : GIT::findFile(fn);
|
2013-02-06 21:07:31 +00:00
|
|
|
if (foundRCS || foundCVS || foundSVN || foundGIT) {
|
2010-04-21 01:19:09 +00:00
|
|
|
docstring const file = makeDisplayPath(fn.absFileName(), 20);
|
2010-01-08 18:48:36 +00:00
|
|
|
docstring const text =
|
|
|
|
bformat(_("Do you want to retrieve the document"
|
|
|
|
" %1$s from version control?"), file);
|
|
|
|
int const ret = Alert::prompt(_("Retrieve from version control?"),
|
|
|
|
text, 0, 1, _("&Retrieve"), _("&Cancel"));
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2012-11-15 21:01:19 +00:00
|
|
|
// Since the retrieve commands are implemented using
|
|
|
|
// more general update commands we need to ensure that
|
|
|
|
// we do not change an existing file by accident.
|
|
|
|
if (fn.exists())
|
|
|
|
return false;
|
|
|
|
if (foundRCS)
|
|
|
|
return RCS::retrieve(fn);
|
|
|
|
else if (foundCVS)
|
|
|
|
return CVS::retrieve(fn);
|
2013-02-06 21:07:31 +00:00
|
|
|
else if (foundSVN)
|
2012-11-15 21:01:19 +00:00
|
|
|
return SVN::retrieve(fn);
|
2013-02-06 21:07:31 +00:00
|
|
|
else
|
|
|
|
return GIT::retrieve(fn);
|
2010-01-08 18:48:36 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-20 17:35:27 +00:00
|
|
|
void LyXVC::setBuffer(Buffer * buf)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-09 23:52:04 +00:00
|
|
|
owner_ = buf;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-08 00:14:55 +00:00
|
|
|
bool LyXVC::registrer()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2007-11-03 17:37:37 +00:00
|
|
|
FileName const filename = owner_->fileName();
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-05-31 01:14:53 +00:00
|
|
|
// there must be a file to save
|
2007-11-25 11:18:16 +00:00
|
|
|
if (!filename.isReadableFile()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
Alert::error(_("Document not saved"),
|
|
|
|
_("You must save the document "
|
|
|
|
"before it can be registered."));
|
2009-01-08 00:14:55 +00:00
|
|
|
return false;
|
2002-05-31 01:14:53 +00:00
|
|
|
}
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
// it is very likely here that the vcs is not created yet...
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_) {
|
2020-12-18 20:48:51 +00:00
|
|
|
FileName found = VCS::checkParentDirs(filename, ".git/index");
|
2008-07-22 08:59:15 +00:00
|
|
|
|
2020-12-18 20:48:51 +00:00
|
|
|
if (!found.empty()) {
|
2013-02-06 21:07:31 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: registering "
|
|
|
|
<< to_utf8(filename.displayName()) << " with GIT");
|
2020-12-18 21:23:31 +00:00
|
|
|
vcs_.reset(new GIT(owner_));
|
2002-03-26 12:11:43 +00:00
|
|
|
|
|
|
|
} else {
|
2020-12-18 20:48:51 +00:00
|
|
|
found = VCS::checkParentDirs(filename, ".svn/entries");
|
|
|
|
if (!found.empty()) {
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: registering "
|
|
|
|
<< to_utf8(filename.displayName()) << " with SVN");
|
2020-12-18 21:23:31 +00:00
|
|
|
vcs_.reset(new SVN(owner_));
|
2020-12-18 20:48:51 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// We only need to check the current directory, since CVS meta-data
|
|
|
|
// is in every sub-directory.
|
|
|
|
FileName const cvs_entries(onlyPath(filename.absFileName()) + "/CVS/Entries");
|
|
|
|
if (cvs_entries.isReadableFile()) {
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: registering "
|
|
|
|
<< to_utf8(filename.displayName()) << " with CVS");
|
|
|
|
vcs_.reset(new CVS(cvs_entries, owner_));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// If all else fails, use RCS
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: registering "
|
|
|
|
<< to_utf8(filename.displayName()) << " with RCS");
|
|
|
|
vcs_.reset(new RCS(FileName(), owner_));
|
|
|
|
}
|
|
|
|
}
|
2002-03-26 12:11:43 +00:00
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: registrer");
|
2007-11-13 23:00:36 +00:00
|
|
|
docstring response;
|
|
|
|
bool ok = Alert::askForText(response, _("LyX VC: Initial description"),
|
|
|
|
_("(no initial description)"));
|
2008-10-30 13:47:41 +00:00
|
|
|
if (!ok) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: user cancelled");
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_.reset(nullptr);
|
2009-01-08 00:14:55 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2008-10-30 13:47:41 +00:00
|
|
|
if (response.empty())
|
|
|
|
response = _("(no initial description)");
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_->registrer(to_utf8(response));
|
2009-01-08 00:14:55 +00:00
|
|
|
return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-05 20:31:58 +00:00
|
|
|
string LyXVC::rename(FileName const & fn)
|
|
|
|
{
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: rename");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_ || fileInVC(fn))
|
2013-02-05 20:31:58 +00:00
|
|
|
return string();
|
|
|
|
docstring response;
|
|
|
|
bool ok = Alert::askForText(response, _("LyX VC: Log message"),
|
|
|
|
_("(no log message)"));
|
|
|
|
if (!ok) {
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: user cancelled");
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
if (response.empty())
|
|
|
|
response = _("(no log message)");
|
2020-12-17 21:56:50 +00:00
|
|
|
string ret = vcs_->rename(fn, to_utf8(response));
|
2013-02-05 20:31:58 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string LyXVC::copy(FileName const & fn)
|
|
|
|
{
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: copy");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_ || fileInVC(fn))
|
2013-02-05 20:31:58 +00:00
|
|
|
return string();
|
|
|
|
docstring response;
|
|
|
|
bool ok = Alert::askForText(response, _("LyX VC: Log message"),
|
|
|
|
_("(no log message)"));
|
|
|
|
if (!ok) {
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: user cancelled");
|
|
|
|
return string();
|
|
|
|
}
|
|
|
|
if (response.empty())
|
|
|
|
response = _("(no log message)");
|
2020-12-17 21:56:50 +00:00
|
|
|
string ret = vcs_->copy(fn, to_utf8(response));
|
2013-02-05 20:31:58 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-04 20:40:28 +00:00
|
|
|
LyXVC::CommandResult LyXVC::checkIn(string & log)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: checkIn");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2013-02-04 20:40:28 +00:00
|
|
|
return ErrorBefore;
|
2010-01-10 21:18:41 +00:00
|
|
|
docstring empty(_("(no log message)"));
|
2007-11-13 23:00:36 +00:00
|
|
|
docstring response;
|
2010-10-25 13:27:48 +00:00
|
|
|
bool ok = true;
|
2020-12-17 21:56:50 +00:00
|
|
|
if (vcs_->isCheckInWithConfirmation())
|
2010-10-25 13:27:48 +00:00
|
|
|
ok = Alert::askForText(response, _("LyX VC: Log Message"));
|
2007-11-13 23:00:36 +00:00
|
|
|
if (ok) {
|
|
|
|
if (response.empty())
|
2010-01-10 21:18:41 +00:00
|
|
|
response = empty;
|
2011-03-07 00:37:26 +00:00
|
|
|
//shell collisions
|
2013-02-03 16:03:08 +00:00
|
|
|
response = subst(response, from_ascii("\""), from_ascii("\\\""));
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->checkIn(to_utf8(response), log);
|
1999-12-30 02:35:43 +00:00
|
|
|
} else {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: user cancelled");
|
2013-02-04 20:40:28 +00:00
|
|
|
return Cancelled;
|
1999-12-30 02:35:43 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 13:14:51 +00:00
|
|
|
string LyXVC::checkOut()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return string();
|
2008-07-22 10:16:12 +00:00
|
|
|
//RCS allows checkOut only in ReadOnly mode
|
2020-12-17 21:56:50 +00:00
|
|
|
if (vcs_->toggleReadOnlyEnabled() && !owner_->hasReadonlyFlag())
|
2010-03-11 19:40:11 +00:00
|
|
|
return string();
|
2008-07-22 10:16:12 +00:00
|
|
|
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: checkOut");
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->checkOut();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-14 19:18:06 +00:00
|
|
|
string LyXVC::repoUpdate()
|
2009-10-06 23:20:52 +00:00
|
|
|
{
|
2009-10-14 19:18:06 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: repoUpdate");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return string();
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->repoUpdate();
|
2009-10-06 23:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-25 14:48:11 +00:00
|
|
|
string LyXVC::lockingToggle()
|
|
|
|
{
|
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: toggle locking property");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return string();
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->lockingToggle();
|
2009-06-25 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-06 11:54:08 +00:00
|
|
|
bool LyXVC::revert()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: revert");
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return false;
|
1999-11-09 23:52:04 +00:00
|
|
|
|
2007-11-03 17:37:37 +00:00
|
|
|
docstring const file = owner_->fileName().displayName(20);
|
2006-09-11 08:54:10 +00:00
|
|
|
docstring text = bformat(_("Reverting to the stored version of the "
|
2008-07-22 10:16:30 +00:00
|
|
|
"document %1$s will lose all current changes.\n\n"
|
|
|
|
"Do you want to revert to the older version?"), file);
|
2010-10-25 13:27:48 +00:00
|
|
|
int ret = 0;
|
2020-12-17 21:56:50 +00:00
|
|
|
if (vcs_->isRevertWithConfirmation())
|
2010-10-25 13:27:48 +00:00
|
|
|
ret = Alert::prompt(_("Revert to stored version of document?"),
|
|
|
|
text, 0, 1, _("&Revert"), _("&Cancel"));
|
2003-03-29 07:09:13 +00:00
|
|
|
|
2020-12-17 21:56:50 +00:00
|
|
|
return ret == 0 && vcs_->revert();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXVC::undoLast()
|
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return;
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_->undoLast();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-03 18:21:54 +00:00
|
|
|
string LyXVC::toggleReadOnly()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2013-02-03 18:21:54 +00:00
|
|
|
return string();
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_->toggleReadOnlyEnabled())
|
2013-02-03 18:21:54 +00:00
|
|
|
return string();
|
2008-07-22 09:00:05 +00:00
|
|
|
|
2020-12-17 21:56:50 +00:00
|
|
|
switch (vcs_->status()) {
|
1999-11-09 23:52:04 +00:00
|
|
|
case VCS::UNLOCKED:
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: toggle to locked");
|
2013-02-03 18:21:54 +00:00
|
|
|
return checkOut();
|
2013-02-04 20:40:28 +00:00
|
|
|
case VCS::LOCKED: {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "LyXVC: toggle to unlocked");
|
2013-02-04 20:40:28 +00:00
|
|
|
string log;
|
2013-03-18 19:42:20 +00:00
|
|
|
if (checkIn(log) != VCSuccess)
|
2013-02-04 20:40:28 +00:00
|
|
|
return string();
|
|
|
|
return log;
|
|
|
|
}
|
2009-02-01 23:46:41 +00:00
|
|
|
case VCS::NOLOCKING:
|
2020-12-17 21:56:50 +00:00
|
|
|
Buffer * b = vcs_->owner();
|
2017-03-01 21:03:44 +00:00
|
|
|
bool const newstate = !b->hasReadonlyFlag();
|
2016-02-20 06:32:56 +00:00
|
|
|
string result = "LyXVC: toggle to ";
|
|
|
|
result += (newstate ? "readonly" : "readwrite");
|
|
|
|
LYXERR(Debug::LYXVC, result);
|
|
|
|
b->setReadonly(newstate);
|
|
|
|
return result;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2013-02-03 18:21:54 +00:00
|
|
|
return string();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 14:40:02 +00:00
|
|
|
bool LyXVC::inUse() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ != nullptr;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-19 14:06:27 +00:00
|
|
|
string const LyXVC::versionString() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return string();
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->versionString();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-12 07:21:11 +00:00
|
|
|
bool LyXVC::locking() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2012-11-25 18:07:57 +00:00
|
|
|
return false;
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->status() != VCS::NOLOCKING;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
|
2003-06-28 01:23:11 +00:00
|
|
|
string const LyXVC::getLogFile() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2001-02-06 17:41:42 +00:00
|
|
|
return string();
|
1999-10-25 14:18:30 +00:00
|
|
|
|
2014-06-09 11:05:50 +00:00
|
|
|
TempFile tempfile("lyxvclog");
|
|
|
|
tempfile.setAutoRemove(false);
|
|
|
|
FileName const tmpf = tempfile.name();
|
2004-02-25 12:00:53 +00:00
|
|
|
if (tmpf.empty()) {
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
|
2004-02-25 12:00:53 +00:00
|
|
|
return string();
|
|
|
|
}
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::LYXVC, "Generating logfile " << tmpf);
|
2020-12-17 21:56:50 +00:00
|
|
|
vcs_->getLog(tmpf);
|
2010-04-21 01:19:09 +00:00
|
|
|
return tmpf.absFileName();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2010-09-07 11:29:05 +00:00
|
|
|
string LyXVC::revisionInfo(RevisionInfo const info) const
|
2010-02-12 01:43:59 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
if (!vcs_)
|
2010-02-12 01:43:59 +00:00
|
|
|
return string();
|
|
|
|
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->revisionInfo(info);
|
2010-02-12 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-05 20:31:58 +00:00
|
|
|
bool LyXVC::renameEnabled() const
|
|
|
|
{
|
|
|
|
if (!inUse())
|
|
|
|
return false;
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->renameEnabled();
|
2013-02-05 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXVC::copyEnabled() const
|
|
|
|
{
|
2013-02-06 21:07:31 +00:00
|
|
|
if (!inUse())
|
|
|
|
return false;
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_->copyEnabled();
|
2013-02-05 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 14:40:02 +00:00
|
|
|
bool LyXVC::checkOutEnabled() const
|
2008-07-21 01:55:58 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->checkOutEnabled();
|
2008-07-21 01:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 14:40:02 +00:00
|
|
|
bool LyXVC::checkInEnabled() const
|
2008-07-21 01:55:58 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->checkInEnabled();
|
2008-07-21 01:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-05 20:31:58 +00:00
|
|
|
bool LyXVC::isCheckInWithConfirmation() const
|
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->isCheckInWithConfirmation();
|
2013-02-05 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 14:40:02 +00:00
|
|
|
bool LyXVC::lockingToggleEnabled() const
|
2009-06-25 14:48:11 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->lockingToggleEnabled();
|
2009-06-25 14:48:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 14:40:02 +00:00
|
|
|
bool LyXVC::undoLastEnabled() const
|
2008-07-21 01:55:58 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->undoLastEnabled();
|
2008-07-21 01:55:58 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 05:26:12 +00:00
|
|
|
|
|
|
|
bool LyXVC::repoUpdateEnabled() const
|
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->repoUpdateEnabled();
|
2010-10-08 05:26:12 +00:00
|
|
|
}
|
2017-07-03 17:53:14 +00:00
|
|
|
|
|
|
|
|
2010-02-15 07:10:59 +00:00
|
|
|
bool LyXVC::prepareFileRevision(string const & rev, std::string & f)
|
2010-02-12 12:16:34 +00:00
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->prepareFileRevision(rev, f);
|
2010-02-12 12:16:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool LyXVC::prepareFileRevisionEnabled()
|
|
|
|
{
|
2020-12-17 21:56:50 +00:00
|
|
|
return vcs_ && vcs_->prepareFileRevisionEnabled();
|
2010-02-12 12:16:34 +00:00
|
|
|
}
|
2008-07-21 01:55:58 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|