#include "support/lstrings.h"
#include "support/Path.h"
#include "support/Systemcall.h"
-
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <fstream>
using namespace std;
using namespace lyx::support;
-using boost::regex;
-using boost::regex_match;
-using boost::smatch;
+
namespace lyx {
string cmd = "ci -q -u -i -t-\"";
cmd += msg;
cmd += "\" ";
- cmd += quoteName(onlyFilename(owner_->absFileName()));
+ cmd += quoteName(onlyFileName(owner_->absFileName()));
doVCCommand(cmd, FileName(owner_->filePath()));
}
string RCS::checkIn(string const & msg)
{
int ret = doVCCommand("ci -q -u -m\"" + msg + "\" "
- + quoteName(onlyFilename(owner_->absFileName())),
+ + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
return ret ? string() : "RCS: Proceeded";
}
string RCS::checkOut()
{
owner_->markClean();
- int ret = doVCCommand("co -q -l " + quoteName(onlyFilename(owner_->absFileName())),
+ int ret = doVCCommand("co -q -l " + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
return ret ? string() : "RCS: Proceeded";
}
void RCS::revert()
{
doVCCommand("co -f -u" + version_ + " "
- + quoteName(onlyFilename(owner_->absFileName())),
+ + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
// We ignore changes and just reload!
owner_->markClean();
{
LYXERR(Debug::LYXVC, "LyXVC: undoLast");
doVCCommand("rcs -o" + version_ + " "
- + quoteName(onlyFilename(owner_->absFileName())),
+ + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
}
void RCS::getLog(FileName const & tmpf)
{
- doVCCommand("rlog " + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("rlog " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
}
if (isStrInt(rev)) {
int back = convert<int>(rev);
- if (back > 0)
- return false;
+ // if positive use as the last number in the whole revision string
+ if (back > 0) {
+ string base;
+ rsplit(version_, base , '.' );
+ rev = base + "." + rev;
+ }
if (back == 0)
rev = version_;
// we care about the last number from revision string
}
}
- FileName tmpf = FileName::tempName("lyxvcrev");
+ FileName tmpf = FileName::tempName("lyxvcrev_" + rev + "_");
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
}
doVCCommand("co -p" + rev + " "
- + quoteName(onlyFilename(owner_->absFileName()))
+ + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (tmpf.isFileEmpty())
// First we look for the CVS/Entries in the same dir
// where we have file.
FileName const entries(onlyPath(file.absFileName()) + "/CVS/Entries");
- string const tmpf = '/' + onlyFilename(file.absFileName()) + '/';
+ string const tmpf = '/' + onlyFileName(file.absFileName()) + '/';
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under cvs in `" << entries
<< "' for `" << tmpf << '\'');
if (entries.isReadableFile()) {
LYXERR(Debug::LYXVC, "LyXVC::CVS: scanMaster. \n Checking: " << master_);
// Ok now we do the real scan...
ifstream ifs(master_.toFilesystemEncoding().c_str());
- string tmpf = '/' + onlyFilename(file_.absFileName()) + '/';
+ string tmpf = '/' + onlyFileName(file_.absFileName()) + '/';
LYXERR(Debug::LYXVC, "\tlooking for `" << tmpf << '\'');
string line;
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
void CVS::registrer(string const & msg)
{
doVCCommand("cvs -q add -m \"" + msg + "\" "
- + quoteName(onlyFilename(owner_->absFileName())),
+ + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
}
string CVS::checkIn(string const & msg)
{
int ret = doVCCommand("cvs -q commit -m \"" + msg + "\" "
- + quoteName(onlyFilename(owner_->absFileName())),
+ + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
return ret ? string() : "CVS: Proceeded";
}
bool CVS::checkInEnabled()
{
- return true;
+ return !owner_->isReadonly();
}
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;
- return string();
+ // to be sure we test it again...
+ if (!checkOutEnabled())
+ return string();
+
+ int ret = doVCCommand("cvs -q edit "
+ + quoteName(onlyFileName(owner_->absFileName())),
+ FileName(owner_->filePath()));
+ if (ret)
+ return string();
+
+ ret = doVCCommand("cvs update "
+ + quoteName(onlyFileName(owner_->absFileName())),
+ FileName(owner_->filePath()));
+ return ret ? string() : "CVS: Proceeded";
}
bool CVS::checkOutEnabled()
{
- return false;
+ return owner_->isReadonly();
}
{
// Reverts to the version in CVS repository and
// gets the updated version from the repository.
- string const fil = quoteName(onlyFilename(owner_->absFileName()));
+ string const fil = quoteName(onlyFileName(owner_->absFileName()));
// This is sensitive operation, so at lest some check about
// existence of cvs program and its file
if (doVCCommand("cvs log "+ fil, FileName(owner_->filePath())))
return;
FileName f(owner_->absFileName());
f.removeFile();
- doVCCommand("cvs update " + fil,
+ doVCCommand("cvs -q update " + fil,
FileName(owner_->filePath()));
owner_->markClean();
}
void CVS::getLog(FileName const & tmpf)
{
- doVCCommand("cvs log " + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("cvs log " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
}
// First we look for the .svn/entries in the same dir
// where we have file.
FileName const entries(onlyPath(file.absFileName()) + "/.svn/entries");
- string const tmpf = onlyFilename(file.absFileName());
+ string const tmpf = onlyFileName(file.absFileName());
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under svn in `" << entries
<< "' for `" << tmpf << '\'');
if (entries.isReadableFile()) {
void SVN::registrer(string const & /*msg*/)
{
- doVCCommand("svn add -q " + quoteName(onlyFilename(owner_->absFileName())),
+ doVCCommand("svn add -q " + quoteName(onlyFileName(owner_->absFileName())),
FileName(owner_->filePath()));
}
}
doVCCommand("svn commit -m \"" + msg + "\" "
- + quoteName(onlyFilename(owner_->absFileName()))
+ + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
return;
string const arg = lock ? "lock " : "unlock ";
- doVCCommand("svn "+ arg + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("svn "+ arg + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
return N_("Error: Could not generate logfile.");
}
- doVCCommand("svn update --non-interactive " + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("svn update --non-interactive " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
return N_("Error: Could not generate logfile.");
}
- int ret = doVCCommand("svn proplist " + quoteName(onlyFilename(owner_->absFileName()))
+ int ret = doVCCommand("svn proplist " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (ret)
bool locking = contains(res, "svn:needs-lock");
if (!locking)
ret = doVCCommand("svn propset svn:needs-lock ON "
- + quoteName(onlyFilename(owner_->absFileName()))
+ + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
else
ret = doVCCommand("svn propdel svn:needs-lock "
- + quoteName(onlyFilename(owner_->absFileName()))
+ + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (ret)
{
// Reverts to the version in CVS repository and
// gets the updated version from the repository.
- string const fil = quoteName(onlyFilename(owner_->absFileName()));
+ string const fil = quoteName(onlyFileName(owner_->absFileName()));
doVCCommand("svn revert -q " + fil,
FileName(owner_->filePath()));
return N_("Error: Could not generate logfile.");
}
- doVCCommand("svn info --xml " + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("svn info --xml " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
void SVN::getLog(FileName const & tmpf)
{
- doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("svn log " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
}
return false;
}
- FileName tmpf = FileName::tempName("lyxvcrev");
+ string revname = convert<string>(rev);
+ FileName tmpf = FileName::tempName("lyxvcrev_" + revname + "_");
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return N_("Error: Could not generate logfile.");
}
- doVCCommand("svn cat -r " + convert<string>(rev) + " "
- + quoteName(onlyFilename(owner_->absFileName()))
+ doVCCommand("svn cat -r " + revname + " "
+ + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (tmpf.isFileEmpty())