[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 5/7] Implement 'p' option for diffing dist conffiles during conflict resolution



From: Sean Finney <seanius@debian.org>
Date: Mon, 14 Dec 2009 08:27:35 +0100

A new option is presented to the user in the conffile resolution prompt,
offering to show the diff between the previous dist version of the conffile
and the new dist version of the conffile. This can be useful for the local
admin to know what has changed in the latest version of the package in the
case that manual conflict resolution is necessary.

To remove ambiguity the string prompt for the old diff option has been
updated as well.  The new prompt contains the following:

      D     : show the differences from your current version
      P     : show the differences from the previous debian version

Suggestions are welcome for improvement to this.

[jn: rebased

Conflicts:

	src/configure.c
]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
It might make sense to consider the patches up to here as something
to polish and make mergeable to start out.  It would already be useful.

What happens if the previously configured version was installed before
conffiledb-enabled dpkg?  Should this be presented differently from
the case where the previously configured version didn't have the
conffile in question?

When presented with D and P, the obvious thing to do is to send their
output somewhere, run combinediff, and get an automatic merge (or
perform other operations to the same effect).  In other words, one
wants to run a 3-way merge:

 - the previous pristine version is the common ancestor
 - the file on disk is "our" version
 - the new pristine version is "their" version

... which leads to the next patch.

In cases with renamed conffiles, one might want something more
complicated, but that can wait for later.

 src/configure.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/configure.c b/src/configure.c
index 68decc4..74ef148 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -588,6 +588,7 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
                  int useredited, int distedited, enum conffopt what)
 {
 	const char *s;
+	char *prev_conffile;
 	int c, cc;
 
 	if (!(what & cfof_prompt))
@@ -654,7 +655,8 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
 		        _("   What would you like to do about it ?  Your options are:\n"
 		          "    Y or I  : install the package maintainer's version\n"
 		          "    N or O  : keep your currently-installed version\n"
-		          "      D     : show the differences between the versions\n"
+		          "      D     : show the differences from your current version\n"
+		          "      P     : show the differences from the previous debian version\n"
 		          "      Z     : start a shell to examine the situation\n"));
 
 		if (what & cfof_keep)
@@ -665,7 +667,7 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
 		s = strrchr(cfgfile, '/');
 		if (!s || !*++s)
 			s = cfgfile;
-		fprintf(stderr, "*** %s (Y/I/N/O/D/Z) %s ? ",
+		fprintf(stderr, "*** %s (Y/I/N/O/D/P/Z) %s ? ",
 		        s,
 		        (what & cfof_keep) ? _("[default=N]") :
 		        (what & cfof_install) ? _("[default=Y]") :
@@ -699,6 +701,14 @@ promptconfaction(struct pkginfo *pkg, const char *cfgfile,
 		if (cc == 'd')
 			showdiff(realold, realnew);
 
+		if (cc == 'p') {
+			prev_conffile = conffiledb_path(pkg,
+			                                &pkg->configversion,
+			                                cfgfile);
+			showdiff(prev_conffile, realnew);
+			free(prev_conffile);
+		}
+
 		if (cc == 'z')
 			spawn_shell(realold, realnew);
 	} while (!strchr("yino", cc));
-- 
1.7.5.1


Reply to: