mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
git VCS: add support for short hashes in inset info ("Abbreviated revision").
Fixes bug #11620. Patch from Joel Kulesza.
This commit is contained in:
parent
eceed02a90
commit
a6634f5bb3
@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be
|
||||
|
||||
-----------------------
|
||||
|
||||
2019-07-26 Joel Kulesza <jkulesza@gmail.com>
|
||||
* Format incremented to 584: support for revision InsetInfo addition of
|
||||
revision-abbrev. This entry is added to accommodate git abbreviated
|
||||
hashes.
|
||||
|
||||
2019-07-17 Kornel Benko <kornel@lyx.org>
|
||||
Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* format incremented to 583: Support for the Chivo and CrimsonPro font families.
|
||||
|
@ -1056,6 +1056,26 @@ def revert_vcsinfo(document):
|
||||
document.body[tp] = "type \"buffer\""
|
||||
document.body[arg] = "arg \"vcs-" + argv + "\""
|
||||
|
||||
def revert_vcsinfo_rev_abbrev(document):
|
||||
" Convert abbreviated revisions to regular revisions. "
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Info", i+1)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(document.body, i+1)
|
||||
if j == -1:
|
||||
document.warning("Malformed LyX document: Could not find end of Info inset.")
|
||||
continue
|
||||
tp = find_token(document.body, 'type', i, j)
|
||||
tpv = get_quoted_value(document.body, "type", tp)
|
||||
if tpv != "vcs":
|
||||
continue
|
||||
arg = find_token(document.body, 'arg', i, j)
|
||||
argv = get_quoted_value(document.body, "arg", arg)
|
||||
if( argv == "revision-abbrev" ):
|
||||
document.body[arg] = "arg \"revision\""
|
||||
|
||||
def revert_dateinfo(document):
|
||||
" Revert date info insets to static text. "
|
||||
@ -3147,9 +3167,11 @@ convert = [
|
||||
[581, [convert_osf]],
|
||||
[582, [convert_AdobeFonts,convert_latexFonts,convert_notoFonts,convert_CantarellFont,convert_FiraFont]],# old font re-converterted due to extra options
|
||||
[583, [convert_ChivoFont,convert_Semibolds,convert_NotoRegulars,convert_CrimsonProFont]],
|
||||
[584, []],
|
||||
]
|
||||
|
||||
revert = [[582, [revert_ChivoFont,revert_CrimsonProFont]],
|
||||
revert = [[583, [revert_vcsinfo_rev_abbrev]],
|
||||
[582, [revert_ChivoFont,revert_CrimsonProFont]],
|
||||
[581, [revert_CantarellFont,revert_FiraFont]],
|
||||
[580, [revert_texfontopts,revert_osf]],
|
||||
[579, [revert_minionpro, revert_plainNotoFonts_xopts, revert_notoFonts_xopts, revert_IBMFonts_xopts, revert_AdobeFonts_xopts, revert_font_opts]], # keep revert_font_opts last!
|
||||
|
@ -176,7 +176,8 @@ public:
|
||||
Tree = 2,
|
||||
Author = 3,
|
||||
Date = 4,
|
||||
Time = 5
|
||||
Time = 5,
|
||||
FileAbbrev = 6
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2125,14 +2125,20 @@ string GIT::revisionInfo(LyXVC::RevisionInfo const info)
|
||||
|
||||
// fill the rest of the attributes for a single file
|
||||
if (rev_file_cache_.empty())
|
||||
if (!getFileRevisionInfo())
|
||||
if (!getFileRevisionInfo()) {
|
||||
rev_file_cache_ = "?";
|
||||
rev_file_abbrev_cache_ = "?";
|
||||
}
|
||||
|
||||
switch (info) {
|
||||
case LyXVC::File:
|
||||
if (rev_file_cache_ == "?")
|
||||
return string();
|
||||
return rev_file_cache_;
|
||||
case LyXVC::FileAbbrev:
|
||||
if (rev_file_abbrev_cache_ == "?")
|
||||
return string();
|
||||
return rev_file_abbrev_cache_;
|
||||
case LyXVC::Author:
|
||||
return rev_author_cache_;
|
||||
case LyXVC::Date:
|
||||
@ -2156,7 +2162,7 @@ bool GIT::getFileRevisionInfo()
|
||||
return false;
|
||||
}
|
||||
|
||||
doVCCommand("git log -n 1 --pretty=format:%H%n%an%n%ai " + quoteName(onlyFileName(owner_->absFileName()))
|
||||
doVCCommand("git log -n 1 --pretty=format:%H%n%h%n%an%n%ai " + quoteName(onlyFileName(owner_->absFileName()))
|
||||
+ " > " + quoteName(tmpf.toFilesystemEncoding()),
|
||||
FileName(owner_->filePath()));
|
||||
|
||||
@ -2167,6 +2173,8 @@ bool GIT::getFileRevisionInfo()
|
||||
|
||||
if (ifs)
|
||||
getline(ifs, rev_file_cache_);
|
||||
if (ifs)
|
||||
getline(ifs, rev_file_abbrev_cache_);
|
||||
if (ifs)
|
||||
getline(ifs, rev_author_cache_);
|
||||
if (ifs) {
|
||||
|
@ -560,6 +560,8 @@ private:
|
||||
bool getFileRevisionInfo();
|
||||
/// cache for file revision number, "?" if already unsuccessful, isNumber==true
|
||||
std::string rev_file_cache_;
|
||||
/// cache for abbreviated file revision number, "?" if already unsuccessful, isNumber==true
|
||||
std::string rev_file_abbrev_cache_;
|
||||
/// cache for author of last commit
|
||||
std::string rev_author_cache_;
|
||||
/// cache for date of last commit
|
||||
|
@ -278,6 +278,7 @@ vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
|
||||
break;
|
||||
}
|
||||
result.push_back(make_pair("revision", _("Revision[[Version Control]]")));
|
||||
result.push_back(make_pair("revision-abbrev", _("Abbreviated revision[[Version Control]]")));
|
||||
result.push_back(make_pair("tree-revision", _("Tree revision")));
|
||||
result.push_back(make_pair("author", _("Author")));
|
||||
result.push_back(make_pair("date", _("Date")));
|
||||
@ -385,7 +386,7 @@ bool InsetInfoParams::validateArgument(Buffer const * buf, docstring const & arg
|
||||
|| name == "path" || name == "class");
|
||||
|
||||
case VCS_INFO:
|
||||
if (name == "revision" || name == "tree-revision"
|
||||
if (name == "revision" || name == "revision-abbrev" || name == "tree-revision"
|
||||
|| name == "author" || name == "date" || name == "time")
|
||||
return buf->lyxvc().inUse();
|
||||
return false;
|
||||
@ -529,6 +530,8 @@ docstring InsetInfo::toolTip(BufferView const &, int, int) const
|
||||
case InsetInfoParams::VCS_INFO:
|
||||
if (params_.name == "revision")
|
||||
result = _("Version control revision");
|
||||
else if (params_.name == "revision-abbrev")
|
||||
result = _("Version control abbreviated revision");
|
||||
else if (params_.name == "tree-revision")
|
||||
result = _("Version control tree revision");
|
||||
else if (params_.name == "author")
|
||||
@ -1099,6 +1102,8 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
|
||||
LyXVC::RevisionInfo itype = LyXVC::Unknown;
|
||||
if (params_.name == "revision")
|
||||
itype = LyXVC::File;
|
||||
else if (params_.name == "revision-abbrev")
|
||||
itype = LyXVC::FileAbbrev;
|
||||
else if (params_.name == "tree-revision")
|
||||
itype = LyXVC::Tree;
|
||||
else if (params_.name == "author")
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 583 // Kornel: Add Chivo sans serif font
|
||||
#define LYX_FORMAT_TEX2LYX 583
|
||||
#define LYX_FORMAT_LYX 584 // Kornel: Add Chivo sans serif font
|
||||
#define LYX_FORMAT_TEX2LYX 584
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user