if (ret)
return LyXVC::ErrorCommand;
log = "RCS: Proceeded";
- return LyXVC::Success;
+ return LyXVC::VCSuccess;
}
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:
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;
}
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())
}
-bool GIT::prepareFileRevision(string const & /*revis*/, string & /*f*/)
+//at this moment we don't accept revision SHA, but just number of revision steps back
+//GUI and infrastucture needs to be changed first
+bool GIT::prepareFileRevision(string const & revis, string & f)
{
- return false;
+ // anything positive means we got hash, not "0" or minus revision
+ int rev = 1;
+
+ // hash is rarely number and should be long
+ if (isStrInt(revis) && revis.length()<20)
+ rev = convert<int>(revis);
+
+ // revision and filename
+ string pointer;
+
+ // go back for "minus" revisions
+ if (rev <= 0)
+ pointer = "HEAD~" + convert<string>(-rev);
+ // normal hash
+ else
+ pointer = revis;
+
+ pointer += ":";
+
+ FileName tmpf = FileName::tempName("lyxvcrev_" + revis + "_");
+ if (tmpf.empty()) {
+ LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
+ return false;
+ }
+
+ doVCCommand("git show " + pointer + "./"
+ + quoteName(onlyFileName(owner_->absFileName()))
+ + " > " + quoteName(tmpf.toFilesystemEncoding()),
+ FileName(owner_->filePath()));
+ if (tmpf.isFileEmpty())
+ return false;
+
+ f = tmpf.absFileName();
+ return true;
}
bool GIT::prepareFileRevisionEnabled()
{
- return false;
+ return true;
}