Tree revision info into InsetInfo. Muhehe.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33431 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2010-02-12 02:31:58 +00:00
parent 5942071ccb
commit 7875d1a9ad
5 changed files with 41 additions and 3 deletions

View File

@ -415,7 +415,7 @@ void LyXAction::init()
textclass: name of textclass (e.g. article) \n textclass: name of textclass (e.g. article) \n
menu: name of lfun used in menu \n menu: name of lfun used in menu \n
icon: name of lfun used in toolbar \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 Sample: command-sequence info-insert buffer path; info-insert buffer name
* \li Origin: bpeng, 7 Oct 2007 * \li Origin: bpeng, 7 Oct 2007
* \endvar * \endvar

View File

@ -145,7 +145,8 @@ public:
// type of the revision information // type of the revision information
enum RevisionInfo { enum RevisionInfo {
File = 1 File = 1,
Tree = 2
}; };
/** /**

View File

@ -869,6 +869,16 @@ string SVN::revisionInfo(LyXVC::RevisionInfo const info)
return string(); return string();
return rev_file_cache_; 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(); 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) void SVN::getLog(FileName const & tmpf)
{ {
doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName())) doVCCommand("svn log " + quoteName(onlyFilename(owner_->absFileName()))

View File

@ -283,6 +283,10 @@ private:
std::string getFileRevisionInfo(); std::string getFileRevisionInfo();
/// cache for file revision number, "?" if already unsuccessful /// cache for file revision number, "?" if already unsuccessful
std::string rev_file_cache_; 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 } // namespace lyx

View File

@ -175,7 +175,7 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const
return true; return true;
case BUFFER_INFO: case BUFFER_INFO:
return name == "name" || name == "path" || name == "class" || return name == "name" || name == "path" || name == "class" ||
name == "vcs-revision"; name == "vcs-revision" || name == "vcs-tree-revision";
} }
return false; return false;
} }
@ -376,6 +376,9 @@ void InsetInfo::updateInfo()
else if (name_ == "vcs-revision" && buffer().lyxvc().inUse() && else if (name_ == "vcs-revision" && buffer().lyxvc().inUse() &&
!buffer().lyxvc().revisionInfo(LyXVC::File).empty()) !buffer().lyxvc().revisionInfo(LyXVC::File).empty())
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::File))); 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 else
setText(_("Unknown buffer info")); setText(_("Unknown buffer info"));
break; break;