[Aptitude-svn-commit] r4356 - in branches/aptitude-0.3/aptitude: .
doc/en src
Daniel Burrows
dburrows at costa.debian.org
Fri Sep 30 02:51:45 UTC 2005
Author: dburrows
Date: Fri Sep 30 02:51:42 2005
New Revision: 4356
Added:
branches/aptitude-0.3/aptitude/src/changelog_parse.cc
branches/aptitude-0.3/aptitude/src/changelog_parse.h
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
branches/aptitude-0.3/aptitude/src/Makefile.am
branches/aptitude-0.3/aptitude/src/defaults.cc
branches/aptitude-0.3/aptitude/src/view_changelog.cc
Log:
Add formatted changelog support.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Fri Sep 30 02:51:42 2005
@@ -1,5 +1,12 @@
2005-09-29 Daniel Burrows <dburrows at debian.org>
+ * doc/en/aptitude.xml, src/Makefile.am, src/changelog_parse.cc, src/changelog_parse.h, src/defaults.cc, src/generic/util/temp.h, src/view_changelog.cc:
+
+ Add support for parsing changelogs and doing something useful
+ with the information therein. In particular, changelogs are now
+ wrapped like descriptions (and get bullet parsing for free), and
+ newer versions of the package are highlighted. (Closes: #290692)
+
* src/generic/util/temp.h:
Allow clients to extract the parent directory of temporary
Modified: branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
==============================================================================
--- branches/aptitude-0.3/aptitude/doc/en/aptitude.xml (original)
+++ branches/aptitude-0.3/aptitude/doc/en/aptitude.xml Fri Sep 30 02:51:42 2005
@@ -6528,6 +6528,18 @@
</entry>
</row>
+ <row>
+ <entry>ChangelogNewerVersion</entry>
+ <entry><literal>set bold;</literal></entry>
+ <entry>
+ The style of newer versions of the package in the
+ changelog view. Note that &aptitude; will only
+ highlight newer versions of the package if you
+ have the package libparse-debianchangelog-perl
+ installed.
+ </entry>
+ </row>
+
<row id='colorDefaultWidgetBackground'>
<entry><literal>Default</literal></entry>
<entry><literal>fg white; bg black;</literal></entry>
Modified: branches/aptitude-0.3/aptitude/src/Makefile.am
==============================================================================
--- branches/aptitude-0.3/aptitude/src/Makefile.am (original)
+++ branches/aptitude-0.3/aptitude/src/Makefile.am Fri Sep 30 02:51:42 2005
@@ -27,6 +27,8 @@
apt_undo_tree.h \
broken_indicator.cc\
broken_indicator.h\
+ changelog_parse.cc \
+ changelog_parse.h \
defaults.cc \
defaults.h \
dep_item.cc \
Added: branches/aptitude-0.3/aptitude/src/changelog_parse.cc
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/changelog_parse.cc Fri Sep 30 02:51:42 2005
@@ -0,0 +1,107 @@
+// changelog_parse.cc
+//
+// Copyright (C) 2005 Daniel Burrows
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+//
+// At the moment this code uses parsechangelog to convert changelogs
+// into something easier to read.
+
+#include "changelog_parse.h"
+
+#include "desc_parse.h"
+
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/tagfile.h>
+#include <apt-pkg/version.h>
+
+#include <generic/util/temp.h>
+#include <generic/util/util.h>
+
+#include <vscreen/fragment.h>
+#include <vscreen/transcode.h>
+
+static
+fragment *parse_predigested_changelog(const temp::name &digest,
+ const std::string &curver)
+{
+ FileFd digestfd(digest.get_name(), FileFd::ReadOnly);
+
+ if(!digestfd.IsOpen())
+ return NULL;
+ else
+ {
+ pkgTagFile tagfile(&digestfd);
+
+ pkgTagSection sec;
+
+ std::vector<fragment *> fragments;
+
+ bool first = true;
+
+ while(tagfile.Step(sec))
+ {
+ std::string version(sec.FindS("Version"));
+ std::string changes = "\n";
+ changes.append(sec.FindS("Changes"));
+ std::string maintainer(sec.FindS("Maintainer"));
+ std::string date(sec.FindS("Date"));
+
+ fragment *f = fragf(first ? "%F%F" : "%n%F%F",
+ make_desc_fragment(transcode(changes)),
+ hardwrapbox(fragf("%n -- %s %s",
+ maintainer.c_str(),
+ date.c_str())));
+
+ first = false;
+
+ if(!curver.empty() && _system->VS->CmpVersion(version, curver) > 0)
+ {
+ style s = get_style("ChangelogNewerVersion");
+ fragments.push_back(style_fragment(f, s));
+ }
+ else
+ fragments.push_back(f);
+ }
+
+ return sequence_fragment(fragments);
+ }
+}
+
+static
+temp::name digest_changelog(const temp::name &changelog)
+{
+ temp::name rval(changelog.get_parent(), "parsedchangelog");
+
+ if(system(ssprintf("parsechangelog --all --format rfc822 -l %s > %s 2> /dev/null",
+ changelog.get_name().c_str(),
+ rval.get_name().c_str()).c_str()) == 0)
+ return rval;
+ else
+ return temp::name();
+}
+
+fragment *make_changelog_fragment(const temp::name &file,
+ const std::string &curver)
+{
+ temp::name digested = digest_changelog(file);
+
+ if(!digested.valid())
+ return NULL;
+ else
+ return parse_predigested_changelog(digested, curver);
+}
Added: branches/aptitude-0.3/aptitude/src/changelog_parse.h
==============================================================================
--- (empty file)
+++ branches/aptitude-0.3/aptitude/src/changelog_parse.h Fri Sep 30 02:51:42 2005
@@ -0,0 +1,39 @@
+// changelog_parse.h -*-c++-*-
+//
+// Copyright (C) 2005 Daniel Burrows
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#ifndef CHANGELOG_PARSE_H
+#define CHANGELOG_PARSE_H
+
+#include <apt-pkg/pkgcache.h>
+
+class fragment;
+namespace temp {class name;}
+
+/** Parse the contents of the given file as a Debian changelog. If
+ * for some reason the file cannot be parsed, returns \b NULL.
+ *
+ * \param file a temporary file object containing the changelog.
+ * \param verstr the name of the currently installed version of
+ * this package (empty if there is no installed
+ * version)
+ */
+fragment *make_changelog_fragment(const temp::name &file,
+ const std::string &curver);
+
+#endif
Modified: branches/aptitude-0.3/aptitude/src/defaults.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/defaults.cc (original)
+++ branches/aptitude-0.3/aptitude/src/defaults.cc Fri Sep 30 02:51:42 2005
@@ -119,6 +119,7 @@
set_style("DownloadProgress", style_fg(COLOR_BLUE)+style_bg(COLOR_YELLOW));
set_style("DownloadHit", style_fg(COLOR_BLACK)+style_bg(COLOR_GREEN));
+ set_style("ChangelogNewerVersion", style_attrs_on(A_BOLD));
set_style("Bullet", style_fg(COLOR_YELLOW)+style_attrs_on(A_BOLD));
set_style("TrustWarning", style_fg(COLOR_RED)+style_bg(COLOR_BLACK)+style_attrs_on(A_BOLD));
Modified: branches/aptitude-0.3/aptitude/src/view_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/view_changelog.cc (original)
+++ branches/aptitude-0.3/aptitude/src/view_changelog.cc Fri Sep 30 02:51:42 2005
@@ -24,7 +24,9 @@
#include <vscreen/vs_pager.h>
#include <vscreen/vs_scrollbar.h>
#include <vscreen/vs_table.h>
+#include <vscreen/vs_text_layout.h>
+#include "changelog_parse.h"
#include "download_bar.h"
#include "menu_redirect.h"
#include "ui.h"
@@ -145,25 +147,50 @@
string menulabel =
ssprintf(_("ChangeLog of %s"), ver.ParentPkg().Name());
string tablabel = ssprintf(_("%s changes"), ver.ParentPkg().Name());
+ string desclabel = _("View the list of changes made to this Debian package.");
- pkg_changelog_screen_ref cs = pkg_changelog_screen::create(n);
- vs_table_ref t = vs_table::create();
- vs_scrollbar_ref s = vs_scrollbar::create(vs_scrollbar::VERTICAL);
-
- cs->line_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
- s->scrollbar_interaction.connect(sigc::mem_fun(cs.unsafe_get_ref(), &pkg_changelog_screen::scroll_page));
- cs->scroll_top();
-
- t->add_widget_opts(cs, 0, 0, 1, 1,
- vs_table::EXPAND|vs_table::SHRINK, vs_table::EXPAND);
- t->add_widget_opts(s, 0, 1, 1, 1, 0,
- vs_table::EXPAND | vs_table::FILL);
+ pkgCache::VerIterator curver = ver.ParentPkg().CurrentVer();
+ string curverstr;
+ if(curver.VerStr() != NULL)
+ curverstr = curver.VerStr();
+ fragment *f = make_changelog_fragment(n, curverstr);
- t->show_all();
+ vs_table_ref t = vs_table::create();
+ if(f != NULL)
+ {
+ vs_scrollbar_ref s = vs_scrollbar::create(vs_scrollbar::VERTICAL);
+ vs_text_layout_ref l = vs_text_layout::create();
+
+
+ l->location_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
+ s->scrollbar_interaction.connect(sigc::mem_fun(l.unsafe_get_ref(), &vs_text_layout::scroll));
+ l->set_fragment(f);
+
+ t->add_widget_opts(l, 0, 0, 1, 1,
+ vs_table::EXPAND|vs_table::SHRINK, vs_table::EXPAND);
+ t->add_widget_opts(s, 0, 1, 1, 1, 0,
+ vs_table::EXPAND | vs_table::FILL);
+ }
+ else
+ {
+ pkg_changelog_screen_ref cs = pkg_changelog_screen::create(n);
+ vs_scrollbar_ref s = vs_scrollbar::create(vs_scrollbar::VERTICAL);
+
+ cs->line_changed.connect(sigc::mem_fun(s.unsafe_get_ref(), &vs_scrollbar::set_slider));
+ s->scrollbar_interaction.connect(sigc::mem_fun(cs.unsafe_get_ref(), &pkg_changelog_screen::scroll_page));
+ cs->scroll_top();
+
+ t->add_widget_opts(cs, 0, 0, 1, 1,
+ vs_table::EXPAND|vs_table::SHRINK, vs_table::EXPAND);
+ t->add_widget_opts(s, 0, 1, 1, 1, 0,
+ vs_table::EXPAND | vs_table::FILL);
- create_menu_bindings(cs.unsafe_get_ref(), t);
+ create_menu_bindings(cs.unsafe_get_ref(), t);
+ }
+
+ t->show_all();
- insert_main_widget(t, menulabel, _("View the list of changes made to this Debian package."), tablabel);
+ insert_main_widget(t, menulabel, desclabel, tablabel);
}
void view_changelog(pkgCache::VerIterator ver)
More information about the Aptitude-svn-commit
mailing list