Fixes bug #11620.
Patch from Joel Kulesza.
-----------------------
+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.
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. "
[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!
Tree = 2,
Author = 3,
Date = 4,
- Time = 5
+ Time = 5,
+ FileAbbrev = 6
};
/**
// 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:
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()));
if (ifs)
getline(ifs, rev_file_cache_);
+ if (ifs)
+ getline(ifs, rev_file_abbrev_cache_);
if (ifs)
getline(ifs, rev_author_cache_);
if (ifs) {
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
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")));
|| 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;
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")
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")
// 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