Patch #2940 2010-03-04 04:32
cryogen
Add updating manifest.xml version to AutoVersion plugin- Download
- 2940-Add_updating_m.patch (18.7 KB)
- Category
- Plugin::FeatureAdd
- Status
- Out of date
- Close date
- 2011-02-22 16:36
- Assigned to
- mortenmacfly
Index: src/plugins/contrib/AutoVersioning/AutoVersioning.cpp
===================================================================
--- src/plugins/contrib/AutoVersioning/AutoVersioning.cpp (revision 6186)
+++ src/plugins/contrib/AutoVersioning/AutoVersioning.cpp (working copy)
@@ -19,6 +19,8 @@
#include <projectmanager.h>
#include <tinyxml/tinyxml.h>
#endif
+#include <tinyxml/tinywxuni.h>
+#include <wx/textfile.h>
#include "projectloader_hooks.h"
@@ -173,6 +175,11 @@
{
Config.Settings.DateDeclarations = Help?true:false;
}
+ // GJH 03/03/10 Added manifest updating.
+ if(pElem->QueryIntAttribute("update_manifest", &Help) == TIXML_SUCCESS)
+ {
+ Config.Settings.UpdateManifest = Help?true:false;
+ }
if(pElem->QueryIntAttribute("do_auto_increment", &Help) == TIXML_SUCCESS)
{
Config.Settings.DoAutoIncrement = Help?true:false;
@@ -255,6 +262,8 @@
TiXmlElement Settings("Settings");
Settings.SetAttribute("autoincrement", NewConfig.Settings.Autoincrement);
Settings.SetAttribute("date_declarations", NewConfig.Settings.DateDeclarations);
+ // GJH 03/03/10 Added manifest updating.
+ Settings.SetAttribute("update_manifest", NewConfig.Settings.UpdateManifest);
Settings.SetAttribute("do_auto_increment", NewConfig.Settings.DoAutoIncrement);
Settings.SetAttribute("ask_to_increment", NewConfig.Settings.AskToIncrement);
Settings.SetAttribute("language", NewConfig.Settings.Language.c_str());
@@ -478,6 +487,8 @@
VersionEditorDialog.SetAuto(GetConfig().Settings.Autoincrement);
VersionEditorDialog.SetDates(GetConfig().Settings.DateDeclarations);
+ // GJH 03/03/10 Added manifest updating.
+ VersionEditorDialog.SetManifest(GetConfig().Settings.UpdateManifest);
VersionEditorDialog.SetSvn(GetConfig().Settings.Svn);
VersionEditorDialog.SetSvnDirectory(cbC2U(GetConfig().Settings.SvnDirectory.c_str()));
@@ -513,6 +524,8 @@
GetConfig().Scheme.BuildTimesToIncrementMinor = VersionEditorDialog.GetBuildTimesToMinorIncrement();
GetConfig().Settings.Autoincrement = VersionEditorDialog.GetAuto();
GetConfig().Settings.DateDeclarations = VersionEditorDialog.GetDates();
+ // GJH 03/03/10 Added manifest updating.
+ GetConfig().Settings.UpdateManifest = VersionEditorDialog.GetManifest();
GetConfig().Settings.AskToIncrement = VersionEditorDialog.GetCommitAsk();
GetConfig().Settings.DoAutoIncrement = VersionEditorDialog.GetCommit();
GetConfig().Settings.Language = cbU2C(VersionEditorDialog.GetLanguage());
@@ -646,7 +659,7 @@
{
wxString revision,date;
if (!QuerySvn(cbC2U(GetConfig().Settings.SvnDirectory.c_str()), revision, date))
- wxMessageBox(_("Svn configuration files not found.\nVerify the Autoversioning svn directory."),_("Error"),wxICON_ERROR);
+ wxMessageBox(_("Possible Causes:\n-You don't have SVN installed.\n-Incompatible version of SVN.\n-SVN configuration files not found.\n\nVerify the Autoversioning SVN directory."),_("SVN Error"),wxICON_ERROR);
headerOutput << _T("\t") << _T("\n");
headerOutput << _T("\t") << _T("//SVN Version") << _T("\n");
headerOutput << _T("\t") << _T("static const char ") << prefix << _T("SVN_REVISION[] = ") << _T("\"") + revision + _T("\"")<< _T(";\n");
@@ -675,6 +688,59 @@
m_timerStatus->Start(1000);
}
+/*! \brief Update manifest.xml with the latest version string.
+ * \author Gary Harris
+ * \date 03/03/10
+ *
+ * \return void
+ *
+ * This function inserts a new version string into the project's manifest.xml.
+ * It searches for the line containing the XML string "<Value version="X.Y.ZZZ" />"
+ * and builds and inserts a new version string based on the current AutoVersion
+ * values.
+ * \note I first used TinyXML to do the XML work but it trashes some text when rewriting the file,
+ * in particular text in the "thanks to" field that is on lines following the value field. This is usually
+ * done to wrap text onto subsequent lines in the plug-in's About dialogue and is probably not strictly
+ * valid XML. TinyXML seems not to like text on following lines.
+ */
+void AutoVersioning::UpdateManifest()
+{
+ wxFileName fnManifest(Manager::Get()->GetProjectManager()->GetActiveProject()->GetCommonTopLevelPath() + wxT("manifest.xml"));
+ wxString sPathManifest(fnManifest.GetFullPath());
+ if (wxFile::Exists(sPathManifest))
+ {
+ wxTextFile fileManifest(sPathManifest);
+ fileManifest.Open();
+ if(fileManifest.IsOpened()){
+ fileManifest.GetFirstLine();
+ wxString sLine;
+ size_t i;
+ while(sLine = fileManifest.GetNextLine())
+ {
+ if(sLine.Find(wxT("<Value version=")) !
download for full patch...
History
cryogen 2010-03-04 04:36
Patched against SVN 6182.
This patch adds to the AutoVersioning plug-in the ability to update the version string in manifest.xml. Autoversioning is great but it's a nuisance to have to update the manifest manually and too easily forgotten. A configuration option is provided to control it, as well.
cryogen 2010-03-04 04:38
This patch includes changes submitted in patch 002922.
cryogen 2010-03-04 04:54
Apologies, the first version was created from the wrong directory.
cryogen 2010-03-05 23:24
Added the missing tooltip description.
cryogen 2010-03-17 17:55
I missed operator !=, too.
cryogen 2011-02-21 17:58
See update to 2922.