]> git.lyx.org Git - lyx.git/blobdiff - src/VCBackend.cpp
Remove exclamation mark from "String not found!"
[lyx.git] / src / VCBackend.cpp
index 599e33136439dbe1255e8315aa22602b6004ee33..753bd63890cb119e7545f1c66f5fc922b82221b3 100644 (file)
@@ -276,7 +276,7 @@ LyXVC::CommandResult RCS::checkIn(string const & msg, string & log)
        if (ret)
                return LyXVC::ErrorCommand;
        log = "RCS: Proceeded";
-       return LyXVC::Success;
+       return LyXVC::VCSuccess;
 }
 
 
@@ -846,7 +846,7 @@ LyXVC::CommandResult CVS::checkIn(string const & msg, string & log)
                        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 + "\" "
@@ -855,7 +855,7 @@ LyXVC::CommandResult CVS::checkIn(string const & msg, string & log)
                if (rc)
                        return LyXVC::ErrorCommand;
                log = "CVS: Proceeded";
-               return LyXVC::Success;
+               return LyXVC::VCSuccess;
        }
        case NeedsMerge:
        case NeedsCheckout:
@@ -1274,7 +1274,7 @@ string SVN::rename(support::FileName const & newFile, string const & msg)
        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);
@@ -1306,7 +1306,7 @@ string SVN::copy(support::FileName const & newFile, string const & msg)
                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();
 }
@@ -1336,7 +1336,7 @@ SVN::checkIn(vector<support::FileName> const & f, string const & msg, string & l
        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()) {
@@ -1353,7 +1353,7 @@ SVN::checkIn(vector<support::FileName> const & f, string const & msg, string & l
        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;
 }
@@ -1916,7 +1916,7 @@ string GIT::rename(support::FileName const & newFile, string const & msg)
        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);
@@ -1966,7 +1966,7 @@ GIT::checkIn(vector<support::FileName> const & f, string const & msg, string & l
        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()) {
@@ -1980,7 +1980,7 @@ GIT::checkIn(vector<support::FileName> const & f, string const & msg, string & l
        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;
 }
@@ -2189,7 +2189,7 @@ bool GIT::getTreeRevisionInfo()
                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())
@@ -2213,15 +2213,50 @@ void GIT::getLog(FileName const & tmpf)
 }
 
 
-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;
 }