From 7875d1a9ad33c047acaf1e4e5da7aa4ad3bf3d3d Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Fri, 12 Feb 2010 02:31:58 +0000 Subject: [PATCH] Tree revision info into InsetInfo. Muhehe. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33431 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXAction.cpp | 2 +- src/LyXVC.h | 3 ++- src/VCBackend.cpp | 30 ++++++++++++++++++++++++++++++ src/VCBackend.h | 4 ++++ src/insets/InsetInfo.cpp | 5 ++++- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 8cdc26803f..54d6fc3a0b 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -415,7 +415,7 @@ void LyXAction::init() textclass: name of textclass (e.g. article) \n menu: name of lfun used in menu \n icon: name of lfun used in toolbar \n - buffer: "name"|"path"|"class"|"vcs-revision" + buffer: "name"|"path"|"class"|"vcs-revision"|"vcs-tree-revision" * \li Sample: command-sequence info-insert buffer path; info-insert buffer name * \li Origin: bpeng, 7 Oct 2007 * \endvar diff --git a/src/LyXVC.h b/src/LyXVC.h index 6a4b3bd0a6..56f8be94b9 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -145,7 +145,8 @@ public: // type of the revision information enum RevisionInfo { - File = 1 + File = 1, + Tree = 2 }; /** diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 908593b967..f54e54e96e 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -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())) diff --git a/src/VCBackend.h b/src/VCBackend.h index 43b2e1d2ea..864dc199c8 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -283,6 +283,10 @@ private: std::string getFileRevisionInfo(); /// cache for file revision number, "?" if already unsuccessful std::string rev_file_cache_; + /// real code for obtaining file revision info + std::string getTreeRevisionInfo(); + /// cache for tree revision number, "?" if already unsuccessful + std::string rev_tree_cache_; }; } // namespace lyx diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 871a361d49..4685a9f5ec 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -175,7 +175,7 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const return true; case BUFFER_INFO: return name == "name" || name == "path" || name == "class" || - name == "vcs-revision"; + name == "vcs-revision" || name == "vcs-tree-revision"; } return false; } @@ -376,6 +376,9 @@ void InsetInfo::updateInfo() else if (name_ == "vcs-revision" && buffer().lyxvc().inUse() && !buffer().lyxvc().revisionInfo(LyXVC::File).empty()) setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::File))); + else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() && + !buffer().lyxvc().revisionInfo(LyXVC::Tree).empty()) + setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Tree))); else setText(_("Unknown buffer info")); break; -- 2.39.2