mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
SVN info - add author, date, time
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33435 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
773d4a8253
commit
c0f9fb76a8
@ -415,7 +415,8 @@ 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"|"vcs-tree-revision"
|
buffer: "name"|"path"|"class"|"vcs-tree-revision"|
|
||||||
|
"vcs-revision"|"vcs-author"|"vcs-date"|"vcs-time"
|
||||||
* \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
|
||||||
|
@ -146,7 +146,10 @@ public:
|
|||||||
// type of the revision information
|
// type of the revision information
|
||||||
enum RevisionInfo {
|
enum RevisionInfo {
|
||||||
File = 1,
|
File = 1,
|
||||||
Tree = 2
|
Tree = 2,
|
||||||
|
Author = 3,
|
||||||
|
Date = 4,
|
||||||
|
Time = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -860,32 +860,41 @@ bool SVN::undoLastEnabled()
|
|||||||
|
|
||||||
string SVN::revisionInfo(LyXVC::RevisionInfo const info)
|
string SVN::revisionInfo(LyXVC::RevisionInfo const info)
|
||||||
{
|
{
|
||||||
switch (info) {
|
if (info == LyXVC::Tree) {
|
||||||
case LyXVC::File:
|
|
||||||
if (rev_file_cache_.empty())
|
|
||||||
rev_file_cache_ = getFileRevisionInfo();
|
|
||||||
if (rev_file_cache_.empty())
|
|
||||||
rev_file_cache_ = "?";
|
|
||||||
if (rev_file_cache_ == "?")
|
|
||||||
return string();
|
|
||||||
|
|
||||||
return rev_file_cache_;
|
|
||||||
|
|
||||||
case LyXVC::Tree:
|
|
||||||
if (rev_tree_cache_.empty())
|
if (rev_tree_cache_.empty())
|
||||||
rev_tree_cache_ = getTreeRevisionInfo();
|
if (!getTreeRevisionInfo())
|
||||||
if (rev_tree_cache_.empty())
|
rev_tree_cache_ = "?";
|
||||||
rev_tree_cache_ = "?";
|
|
||||||
if (rev_tree_cache_ == "?")
|
if (rev_tree_cache_ == "?")
|
||||||
return string();
|
return string();
|
||||||
|
|
||||||
return rev_tree_cache_;
|
return rev_tree_cache_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill the rest of the attributes for a single file
|
||||||
|
if (rev_file_cache_.empty())
|
||||||
|
if (!getFileRevisionInfo())
|
||||||
|
rev_file_cache_ = "?";
|
||||||
|
|
||||||
|
switch (info) {
|
||||||
|
case LyXVC::File:
|
||||||
|
if (rev_file_cache_ == "?")
|
||||||
|
return string();
|
||||||
|
return rev_file_cache_;
|
||||||
|
case LyXVC::Author:
|
||||||
|
return rev_author_cache_;
|
||||||
|
case LyXVC::Date:
|
||||||
|
return rev_date_cache_;
|
||||||
|
case LyXVC::Time:
|
||||||
|
return rev_time_cache_;
|
||||||
|
default: ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string SVN::getFileRevisionInfo()
|
bool SVN::getFileRevisionInfo()
|
||||||
{
|
{
|
||||||
FileName tmpf = FileName::tempName("lyxvcout");
|
FileName tmpf = FileName::tempName("lyxvcout");
|
||||||
|
|
||||||
@ -894,7 +903,7 @@ std::string SVN::getFileRevisionInfo()
|
|||||||
FileName(owner_->filePath()));
|
FileName(owner_->filePath()));
|
||||||
|
|
||||||
if (tmpf.empty())
|
if (tmpf.empty())
|
||||||
return string();
|
return false;
|
||||||
|
|
||||||
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
|
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
|
||||||
string line;
|
string line;
|
||||||
@ -911,16 +920,30 @@ std::string SVN::getFileRevisionInfo()
|
|||||||
string l1 = subst(line, "revision=\"", "");
|
string l1 = subst(line, "revision=\"", "");
|
||||||
string l2 = trim(subst(l1, "\">", ""));
|
string l2 = trim(subst(l1, "\">", ""));
|
||||||
if (isStrInt(l2))
|
if (isStrInt(l2))
|
||||||
rev = l2;
|
rev_file_cache_ = rev = l2;
|
||||||
|
}
|
||||||
|
if (c && prefixIs(line, "<author>") && suffixIs(line, "</author>")) {
|
||||||
|
string l1 = subst(line, "<author>", "");
|
||||||
|
string l2 = subst(l1, "</author>", "");
|
||||||
|
rev_author_cache_ = l2;
|
||||||
|
}
|
||||||
|
if (c && prefixIs(line, "<date>") && suffixIs(line, "</date>")) {
|
||||||
|
string l1 = subst(line, "<date>", "");
|
||||||
|
string l2 = subst(l1, "</date>", "");
|
||||||
|
l2 = split(l2, l1, 'T');
|
||||||
|
rev_date_cache_ = l1;
|
||||||
|
l2 = split(l2, l1, '.');
|
||||||
|
rev_time_cache_ = l1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ifs.close();
|
ifs.close();
|
||||||
tmpf.erase();
|
tmpf.erase();
|
||||||
return rev;
|
return !rev.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string SVN::getTreeRevisionInfo()
|
bool SVN::getTreeRevisionInfo()
|
||||||
{
|
{
|
||||||
FileName tmpf = FileName::tempName("lyxvcout");
|
FileName tmpf = FileName::tempName("lyxvcout");
|
||||||
|
|
||||||
@ -928,7 +951,7 @@ std::string SVN::getTreeRevisionInfo()
|
|||||||
FileName(owner_->filePath()));
|
FileName(owner_->filePath()));
|
||||||
|
|
||||||
if (tmpf.empty())
|
if (tmpf.empty())
|
||||||
return string();
|
return false;
|
||||||
|
|
||||||
// only first line in case something bad happens.
|
// only first line in case something bad happens.
|
||||||
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
|
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
|
||||||
@ -936,7 +959,9 @@ std::string SVN::getTreeRevisionInfo()
|
|||||||
getline(ifs, line);
|
getline(ifs, line);
|
||||||
ifs.close();
|
ifs.close();
|
||||||
tmpf.erase();
|
tmpf.erase();
|
||||||
return line;
|
|
||||||
|
rev_tree_cache_ = line;
|
||||||
|
return !line.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,12 +279,23 @@ private:
|
|||||||
support::FileName file_;
|
support::FileName file_;
|
||||||
/// is the loaded file under locking policy?
|
/// is the loaded file under locking policy?
|
||||||
bool locked_mode_;
|
bool locked_mode_;
|
||||||
/// real code for obtaining file revision info
|
/**
|
||||||
std::string getFileRevisionInfo();
|
* Real code for obtaining file revision info. Fills all file-related caches
|
||||||
|
* and returns true if successfull.
|
||||||
|
* "?" is stored in rev_file_cache_ as a signal if request for obtaining info
|
||||||
|
* was already unsuccessful.
|
||||||
|
*/
|
||||||
|
bool 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
|
/// cache for author of last commit
|
||||||
std::string getTreeRevisionInfo();
|
std::string rev_author_cache_;
|
||||||
|
/// cache for date of last commit
|
||||||
|
std::string rev_date_cache_;
|
||||||
|
/// cache for time of last commit
|
||||||
|
std::string rev_time_cache_;
|
||||||
|
/// fills rev_tree_cache_, returns true if successfull.
|
||||||
|
bool getTreeRevisionInfo();
|
||||||
/// cache for tree revision number, "?" if already unsuccessful
|
/// cache for tree revision number, "?" if already unsuccessful
|
||||||
std::string rev_tree_cache_;
|
std::string rev_tree_cache_;
|
||||||
};
|
};
|
||||||
|
@ -175,7 +175,8 @@ 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-tree-revision";
|
name == "vcs-revision" || name == "vcs-tree-revision" ||
|
||||||
|
name == "vcs-author" || name == "vcs-date" || name == "vcs-time";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -379,6 +380,15 @@ void InsetInfo::updateInfo()
|
|||||||
else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() &&
|
else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() &&
|
||||||
!buffer().lyxvc().revisionInfo(LyXVC::Tree).empty())
|
!buffer().lyxvc().revisionInfo(LyXVC::Tree).empty())
|
||||||
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Tree)));
|
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Tree)));
|
||||||
|
else if (name_ == "vcs-author" && buffer().lyxvc().inUse() &&
|
||||||
|
!buffer().lyxvc().revisionInfo(LyXVC::Author).empty())
|
||||||
|
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Author)));
|
||||||
|
else if (name_ == "vcs-time" && buffer().lyxvc().inUse() &&
|
||||||
|
!buffer().lyxvc().revisionInfo(LyXVC::Time).empty())
|
||||||
|
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Time)));
|
||||||
|
else if (name_ == "vcs-date" && buffer().lyxvc().inUse() &&
|
||||||
|
!buffer().lyxvc().revisionInfo(LyXVC::Date).empty())
|
||||||
|
setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Date)));
|
||||||
else
|
else
|
||||||
setText(_("Unknown buffer info"));
|
setText(_("Unknown buffer info"));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user