]> git.lyx.org Git - features.git/blobdiff - src/VCBackend.cpp
Tree revision info into InsetInfo. Muhehe.
[features.git] / src / VCBackend.cpp
index 908593b967edffedb8722d790972e47c8c8f84d4..f54e54e96e19ff4840649dcf71356e18f64ef01e 100644 (file)
@@ -869,6 +869,16 @@ string SVN::revisionInfo(LyXVC::RevisionInfo const info)
                                return string();
 
                        return rev_file_cache_;
+
+               case LyXVC::Tree:
+                       if (rev_tree_cache_.empty())
+                               rev_tree_cache_ = getTreeRevisionInfo();
+                       if (rev_tree_cache_.empty())
+                               rev_tree_cache_ = "?";
+                       if (rev_tree_cache_ == "?")
+                               return string();
+
+                       return rev_tree_cache_;
        }
        return string();
 }
@@ -909,6 +919,26 @@ std::string SVN::getFileRevisionInfo()
 }
 
 
+std::string SVN::getTreeRevisionInfo()
+{
+       FileName tmpf = FileName::tempName("lyxvcout");
+
+       doVCCommand("svnversion -n . > " + quoteName(tmpf.toFilesystemEncoding()),
+                   FileName(owner_->filePath()));
+
+       if (tmpf.empty())
+               return string();
+
+       // only first line in case something bad happens.
+       ifstream ifs(tmpf.toFilesystemEncoding().c_str());
+       string line;
+       getline(ifs, line);
+       ifs.close();
+       tmpf.erase();
+       return line;
+}
+
+
 void SVN::getLog(FileName const & tmpf)
 {
        doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName()))