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();
}
// 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)) {
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;
}
}
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;
}