mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
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:
parent
5942071ccb
commit
7875d1a9ad
@ -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
|
||||
|
@ -145,7 +145,8 @@ public:
|
||||
|
||||
// type of the revision information
|
||||
enum RevisionInfo {
|
||||
File = 1
|
||||
File = 1,
|
||||
Tree = 2
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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()))
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user