using namespace lyx::support;
-
namespace lyx {
bool VCS::makeRCSRevision(string const &version, string &revis) const
{
string rev = revis;
-
+
if (isStrInt(rev)) {
int back = convert<int>(rev);
// if positive use as the last number in the whole revision string
}
-bool VCS::checkparentdirs(FileName const & file, std::string const & pathname)
+bool VCS::checkparentdirs(FileName const & file, std::string const & vcsdir)
{
FileName dirname = file.onlyPath();
- FileName tocheck = FileName(addName(dirname.absFileName(),pathname));
- LYXERR(Debug::LYXVC, "check file: " << tocheck.absFileName());
- bool result = tocheck.exists();
- while ( !result && !dirname.empty() ) {
+ do {
+ FileName tocheck = FileName(addName(dirname.absFileName(), vcsdir));
+ LYXERR(Debug::LYXVC, "check file: " << tocheck.absFileName());
+ if (tocheck.exists())
+ return true;
//this construct because of #8295
dirname = FileName(dirname.absFileName()).parentPath();
- LYXERR(Debug::LYXVC, "check directory: " << dirname.absFileName());
- tocheck = FileName(addName(dirname.absFileName(),pathname));
- result = tocheck.exists();
- }
- return result;
+ } while (!dirname.empty());
+ return false;
}
-
+
/////////////////////////////////////////////////////////////////////
//
// RCS
RCS::RCS(FileName const & m, Buffer * b) : VCS(b)
{
+ // Here we know that the buffer file is either already in RCS or
+ // about to be registered
master_ = m;
scanMaster();
}
if (ret)
return LyXVC::ErrorCommand;
log = "RCS: Proceeded";
- return LyXVC::Success;
+ return LyXVC::VCSuccess;
}
// This got broken somewhere along lfuns dispatch reorganization.
// reloadBuffer would be needed after this, but thats problematic
// since we are inside Buffer::dispatch.
- // return return status() != UNVERSIONED;
+ // return true;
return false;
}
CVS::CVS(FileName const & m, Buffer * b) : VCS(b)
{
+ // Here we know that the buffer file is either already in CVS or
+ // about to be registered
master_ = m;
have_rev_info_ = false;
scanMaster();
LYXERR(Debug::LYXVC, "\tlooking for `" << tmpf << '\'');
string line;
static regex const reg("/(.*)/(.*)/(.*)/(.*)/(.*)");
- vcstatus = UNVERSIONED;
while (getline(ifs, line)) {
LYXERR(Debug::LYXVC, "\t line: " << line);
if (contains(line, tmpf)) {
if (unedit())
return LyXVC::ErrorCommand;
log = "CVS: Proceeded";
- return LyXVC::Success;
+ return LyXVC::VCSuccess;
case LocallyModified:
case LocallyAdded: {
int rc = doVCCommand("cvs -q commit -m \"" + msg + "\" "
if (rc)
return LyXVC::ErrorCommand;
log = "CVS: Proceeded";
- return LyXVC::Success;
+ return LyXVC::VCSuccess;
}
case NeedsMerge:
case NeedsCheckout:
SVN::SVN(FileName const & m, Buffer * b) : VCS(b)
{
+ // Here we know that the buffer file is either already in SVN or
+ // about to be registered
master_ = m;
locked_mode_ = 0;
scanMaster();
void SVN::scanMaster()
{
- // vcstatus code other than UNVERSIONED is somewhat superflous,
+ // vcstatus code is somewhat superflous,
// until we want to implement read-only toggle for svn.
- FileName f = findFile(owner_->fileName());
- if (f.empty()) {
- vcstatus = UNVERSIONED;
- } else {
- vcstatus = NOLOCKING;
- if (checkLockMode()) {
- if (isLocked())
- vcstatus = LOCKED;
- else
- vcstatus = UNLOCKED;
- }
+ vcstatus = NOLOCKING;
+ if (checkLockMode()) {
+ if (isLocked())
+ vcstatus = LOCKED;
+ else
+ vcstatus = UNLOCKED;
}
}
f.push_back(owner_->fileName());
f.push_back(newFile);
string log;
- if (checkIn(f, msg, log) != LyXVC::Success) {
+ if (checkIn(f, msg, log) != LyXVC::VCSuccess) {
cmd = "svn revert -q " +
quoteName(onlyFileName(owner_->absFileName())) + ' ' +
quoteName(relFile);
return string();
vector<support::FileName> f(1, newFile);
string log;
- if (checkIn(f, msg, log) == LyXVC::Success)
+ if (checkIn(f, msg, log) == LyXVC::VCSuccess)
return log;
return string();
}
os << " > " << quoteName(tmpf.toFilesystemEncoding());
LyXVC::CommandResult ret =
doVCCommand(os.str(), FileName(owner_->filePath())) ?
- LyXVC::ErrorCommand : LyXVC::Success;
+ LyXVC::ErrorCommand : LyXVC::VCSuccess;
string res = scanLogFile(tmpf, log);
if (!res.empty()) {
tmpf.removeFile();
if (!log.empty())
log.insert(0, "SVN: ");
- if (ret == LyXVC::Success && log.empty())
+ if (ret == LyXVC::VCSuccess && log.empty())
log = "SVN: Proceeded";
return ret;
}
GIT::GIT(FileName const & m, Buffer * b) : VCS(b)
{
+ // Here we know that the buffer file is either already in GIT or
+ // about to be registered
master_ = m;
scanMaster();
}
return FileName();
}
- // --porcelain selects a format that is supposed to be stable across
- // git versions
string const fname = onlyFileName(file.absFileName());
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under git control for `"
<< fname << '\'');
- bool found = 0 == doVCCommandCall("git status --porcelain " +
- quoteName(fname) + " > " +
- quoteName(tmpf.toFilesystemEncoding()),
+ doVCCommandCall("git ls-files " +
+ quoteName(fname) + " > " +
+ quoteName(tmpf.toFilesystemEncoding()),
file.onlyPath());
- if (found)
- {
- // The output contains a line starting with "??" for unknown
- // files, no line for known unmodified files and a line
- // starting with "M" or something else for modified/deleted
- // etc. files.
- ifstream ifs(tmpf.toFilesystemEncoding().c_str());
- string test;
- if ((ifs >> test))
- found = (test != "??");
- // else is no error
- }
+ bool found = !tmpf.isFileEmpty();
tmpf.removeFile();
LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
return found ? file : FileName();
void GIT::scanMaster()
{
- // vcstatus code other than UNVERSIONED is somewhat superflous,
+ // vcstatus code is somewhat superflous,
// until we want to implement read-only toggle for git.
- FileName f = findFile(owner_->fileName());
- if (f.empty())
- vcstatus = UNVERSIONED;
- else
- vcstatus = NOLOCKING;
+ vcstatus = NOLOCKING;
}
f.push_back(owner_->fileName());
f.push_back(newFile);
string log;
- if (checkIn(f, msg, log) != LyXVC::Success) {
+ if (checkIn(f, msg, log) != LyXVC::VCSuccess) {
cmd = "git checkout -q " +
quoteName(onlyFileName(owner_->absFileName())) + ' ' +
quoteName(relFile);
os << " > " << quoteName(tmpf.toFilesystemEncoding());
LyXVC::CommandResult ret =
doVCCommand(os.str(), FileName(owner_->filePath())) ?
- LyXVC::ErrorCommand : LyXVC::Success;
+ LyXVC::ErrorCommand : LyXVC::VCSuccess;
string res = scanLogFile(tmpf, log);
if (!res.empty()) {
tmpf.removeFile();
if (!log.empty())
log.insert(0, "GIT: ");
- if (ret == LyXVC::Success && log.empty())
+ if (ret == LyXVC::VCSuccess && log.empty())
log = "GIT: Proceeded";
return ret;
}
return false;
}
- doVCCommand("git log -n 1 --pretty=format:%H . > " + quoteName(tmpf.toFilesystemEncoding()),
+ doVCCommand("git describe --abbrev --dirty --long > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (tmpf.empty())
pointer += ":";
- if (rev <= 0)
- if (!getFileRevisionInfo())
- return false;
-
FileName tmpf = FileName::tempName("lyxvcrev_" + revis + "_");
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);