#include "VCBackend.h"
#include "Buffer.h"
+#include "DispatchResult.h"
#include "LyX.h"
#include "FuncRequest.h"
#include "support/TempFile.h"
#include <fstream>
+#include <iomanip>
+#include <sstream>
using namespace std;
using namespace lyx::support;
LYXERR(Debug::LYXVC, "doVCCommandCall: " << cmd);
Systemcall one;
support::PathChanger p(path);
- return one.startscript(Systemcall::Wait, cmd, string(), false);
+ return one.startscript(Systemcall::Wait, cmd, string(), string(), false);
}
owner_->setBusy(false);
if (ret && reportError)
frontend::Alert::error(_("Revision control error."),
- bformat(_("Some problem occured while running the command:\n"
+ bformat(_("Some problem occurred while running the command:\n"
"'%1$s'."),
from_utf8(cmd)));
return ret;
LYXERR(Debug::LYXVC, "LyXVC::RCS: scanMaster: " << master_);
ifstream ifs(master_.toFilesystemEncoding().c_str());
+ // limit the size of strings we read to avoid memory problems
+ ifs >> setw(65636);
string token;
bool read_enough = false;
bool RCS::checkInEnabled()
{
- return owner_ && !owner_->isReadonly();
+ return owner_ && !owner_->hasReadonlyFlag();
}
bool RCS::checkOutEnabled()
{
- return owner_ && owner_->isReadonly();
+ return owner_ && owner_->hasReadonlyFlag();
}
bool RCS::undoLastEnabled()
{
- return true;
+ return owner_->hasReadonlyFlag();
}
return rev_date_cache_;
case LyXVC::Time:
return rev_time_cache_;
- default: ;
+ default:
+ break;
}
return string();
+ quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
+ tmpf.refresh();
if (tmpf.isFileEmpty())
return false;
if (contains(line, tmpf)) {
// Ok extract the fields.
smatch sm;
-
- regex_match(line, sm, reg);
+ if (!regex_match(line, sm, reg)) {
+ LYXERR(Debug::LYXVC, "\t Cannot parse line. Skipping.");
+ continue;
+ }
//sm[0]; // whole matched string
//sm[1]; // filename
LYXERR(Debug::LYXVC, line << '\n');
if (prefixIs(line, "date:")) {
smatch sm;
- regex_match(line, sm, reg);
- //sm[0]; // whole matched string
- rev_date_cache_ = sm[1];
- rev_time_cache_ = sm[2];
- //sm[3]; // GMT offset
- rev_author_cache_ = sm[4];
+ if (regex_match(line, sm, reg)) {
+ //sm[0]; // whole matched string
+ rev_date_cache_ = sm[1];
+ rev_time_cache_ = sm[2];
+ //sm[3]; // GMT offset
+ rev_author_cache_ = sm[4];
+ } else
+ LYXERR(Debug::LYXVC, "\tCannot parse line. Skipping.");
break;
}
}
return rev_date_cache_;
case LyXVC::Time:
return rev_time_cache_;
- default: ;
+ default:
+ break;
}
}
return string();
doVCCommandWithOutput("cvs update -p -r" + rev + ' '
+ getTarget(File),
FileName(owner_->filePath()), tmpf);
+ tmpf.refresh();
if (tmpf.isFileEmpty())
return false;
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
- // Lock error messages go unfortunately on stderr and are unreachible this way.
+ // Lock error messages go unfortunately on stderr and are unreachable this way.
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
string line;
while (ifs) {
return rev_date_cache_;
case LyXVC::Time:
return rev_time_cache_;
- default: ;
-
+ default:
+ break;
}
return string();
+ quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
+ tmpf.refresh();
if (tmpf.isFileEmpty())
return false;
quoteName(fname) + " > " +
quoteName(tmpf.toFilesystemEncoding()),
file.onlyPath());
+ tmpf.refresh();
bool found = !tmpf.isFileEmpty();
LYXERR(Debug::LYXVC, "GIT control: " << (found ? "enabled" : "disabled"));
return found ? file : FileName();
// fill the rest of the attributes for a single file
if (rev_file_cache_.empty())
- if (!getFileRevisionInfo())
+ if (!getFileRevisionInfo()) {
rev_file_cache_ = "?";
+ rev_file_abbrev_cache_ = "?";
+ }
switch (info) {
case LyXVC::File:
if (rev_file_cache_ == "?")
return string();
return rev_file_cache_;
+ case LyXVC::FileAbbrev:
+ if (rev_file_abbrev_cache_ == "?")
+ return string();
+ return rev_file_abbrev_cache_;
case LyXVC::Author:
return rev_author_cache_;
case LyXVC::Date:
return rev_date_cache_;
case LyXVC::Time:
return rev_time_cache_;
- default: ;
-
+ default:
+ break;
}
return string();
return false;
}
- doVCCommand("git log -n 1 --pretty=format:%H%n%an%n%ai " + quoteName(onlyFileName(owner_->absFileName()))
+ doVCCommand("git log -n 1 --pretty=format:%H%n%h%n%an%n%ai " + quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
if (ifs)
getline(ifs, rev_file_cache_);
+ if (ifs)
+ getline(ifs, rev_file_abbrev_cache_);
if (ifs)
getline(ifs, rev_author_cache_);
if (ifs) {
}
doVCCommand("git describe --abbrev --dirty --long > " + quoteName(tmpf.toFilesystemEncoding()),
- FileName(owner_->filePath()));
+ FileName(owner_->filePath()),
+ false); //git describe returns $?=128 when no tag found (but git repo still exists)
if (tmpf.empty())
return false;
+ quoteName(onlyFileName(owner_->absFileName()))
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
FileName(owner_->filePath()));
+ tmpf.refresh();
if (tmpf.isFileEmpty())
return false;
bool GIT::toggleReadOnlyEnabled()
{
- return false;
+ return true;
}