diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 54d6fc3a0b..acadc934a6 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -415,7 +415,8 @@ 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"|"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 Origin: bpeng, 7 Oct 2007
* \endvar
diff --git a/src/LyXVC.h b/src/LyXVC.h
index 56f8be94b9..00b889f982 100644
--- a/src/LyXVC.h
+++ b/src/LyXVC.h
@@ -146,7 +146,10 @@ public:
// type of the revision information
enum RevisionInfo {
File = 1,
- Tree = 2
+ Tree = 2,
+ Author = 3,
+ Date = 4,
+ Time = 5
};
/**
diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp
index d2c3c1a6f2..9e0156b04e 100644
--- a/src/VCBackend.cpp
+++ b/src/VCBackend.cpp
@@ -860,32 +860,41 @@ bool SVN::undoLastEnabled()
string SVN::revisionInfo(LyXVC::RevisionInfo const info)
{
- switch (info) {
- 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 (info == LyXVC::Tree) {
if (rev_tree_cache_.empty())
- rev_tree_cache_ = getTreeRevisionInfo();
- if (rev_tree_cache_.empty())
- rev_tree_cache_ = "?";
+ if (!getTreeRevisionInfo())
+ rev_tree_cache_ = "?";
if (rev_tree_cache_ == "?")
return string();
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();
}
-std::string SVN::getFileRevisionInfo()
+bool SVN::getFileRevisionInfo()
{
FileName tmpf = FileName::tempName("lyxvcout");
@@ -894,7 +903,7 @@ std::string SVN::getFileRevisionInfo()
FileName(owner_->filePath()));
if (tmpf.empty())
- return string();
+ return false;
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
string line;
@@ -911,16 +920,30 @@ std::string SVN::getFileRevisionInfo()
string l1 = subst(line, "revision=\"", "");
string l2 = trim(subst(l1, "\">", ""));
if (isStrInt(l2))
- rev = l2;
+ rev_file_cache_ = rev = l2;
+ }
+ if (c && prefixIs(line, "") && suffixIs(line, "")) {
+ string l1 = subst(line, "", "");
+ string l2 = subst(l1, "", "");
+ rev_author_cache_ = l2;
+ }
+ if (c && prefixIs(line, "") && suffixIs(line, "")) {
+ string l1 = subst(line, "", "");
+ string l2 = subst(l1, "", "");
+ l2 = split(l2, l1, 'T');
+ rev_date_cache_ = l1;
+ l2 = split(l2, l1, '.');
+ rev_time_cache_ = l1;
}
}
+
ifs.close();
tmpf.erase();
- return rev;
+ return !rev.empty();
}
-std::string SVN::getTreeRevisionInfo()
+bool SVN::getTreeRevisionInfo()
{
FileName tmpf = FileName::tempName("lyxvcout");
@@ -928,7 +951,7 @@ std::string SVN::getTreeRevisionInfo()
FileName(owner_->filePath()));
if (tmpf.empty())
- return string();
+ return false;
// only first line in case something bad happens.
ifstream ifs(tmpf.toFilesystemEncoding().c_str());
@@ -936,7 +959,9 @@ std::string SVN::getTreeRevisionInfo()
getline(ifs, line);
ifs.close();
tmpf.erase();
- return line;
+
+ rev_tree_cache_ = line;
+ return !line.empty();
}
diff --git a/src/VCBackend.h b/src/VCBackend.h
index 864dc199c8..50cec8c770 100644
--- a/src/VCBackend.h
+++ b/src/VCBackend.h
@@ -279,12 +279,23 @@ private:
support::FileName file_;
/// is the loaded file under locking policy?
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
std::string rev_file_cache_;
- /// real code for obtaining file revision info
- std::string getTreeRevisionInfo();
+ /// cache for author of last commit
+ 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
std::string rev_tree_cache_;
};
diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp
index 4685a9f5ec..cfd197aeae 100644
--- a/src/insets/InsetInfo.cpp
+++ b/src/insets/InsetInfo.cpp
@@ -175,7 +175,8 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const
return true;
case BUFFER_INFO:
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;
}
@@ -379,6 +380,15 @@ void InsetInfo::updateInfo()
else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() &&
!buffer().lyxvc().revisionInfo(LyXVC::Tree).empty())
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
setText(_("Unknown buffer info"));
break;