Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 73129 - dispatch-conf should support vimdiff
Summary: dispatch-conf should support vimdiff
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High enhancement
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-02 06:09 UTC by Chris Lear
Modified: 2014-08-01 20:00 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lear 2004-12-02 06:09:04 UTC
There's a general feeling that dispatch-conf is better than etc-update. It is now included in portage, and has a man page, which makes it look better than it did a while ago.
But etc-update allows the use of vimdiff.

eg in etc-update.conf:

pager=""
diff_command="vim -d %file1 %file2"
using_editor=1

There is no equivalent in dispatch-conf.conf - this doesn't work:

diff="vim -d %s %s"
pager=""


Reproducible: Always
Steps to Reproduce:
Comment 1 Chris Lear 2004-12-03 06:53:45 UTC
Here's a patch that works (with diff="vim -d %s %s", pager=""). It's kind of crude:

diff="vim -d %s %s"
pager=""

$ diff dispatch-conf dispatch-conf.edited
162c162,166
<                     os.system((self.options['diff'] + '| %s') % (conf['new'], mrgconf, self.options['pager']))
---
>                     if self.options['pager']:
>                         command_to_run = ((self.options['diff'] + '| %s') % (conf['new'], mrgconf, self.options['pager']))
>                     else:
>                         command_to_run = ((self.options['diff']) % (conf['new'], mrgconf))
>                     os.system(command_to_run)
163a168
>
165c170,174
<                     os.system((self.options['diff'] + '| %s') % (conf['current'], newconf, self.options['pager']))
---
>                     if self.options['pager']:
>                         command_to_run=(self.options['diff'] + '| %s') % (conf['current'], newconf, self.options['pager'])
>                     else:
>                         command_to_run=(self.options['diff']) % (conf['current'], newconf)
>                     os.system(command_to_run)
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2005-01-10 18:43:38 UTC
Please use context diffs. diff -u
Comment 3 Chris Lear 2005-01-19 01:45:42 UTC
Thanks for the advice, but I'm not going to take it.

diff -u is miles less use to me than vimdiff. With vimdiff I can actually work with the config files, merge the changes, see everything in nice highlighing if I like, etc etc. I'll stick to using either a patched dispatch-conf or etc-update (which supports vimdiff) unless someone feels like enhancing the gentoo dispatch-conf. And what if I wanted to use a graphical diff tool (lots of people do, according to the forums)? This request would support that too.

Effectively, the request is to be allowed to use a diff tool without piping the output to a pager. I think it would be worth the effort, and perhaps the fact that it's been implemented in etc-update backs up this idea.

On the other hand, if this doesn't ever get done, it's no big deal.
Comment 4 david.antliff 2005-02-07 11:31:42 UTC
I think the reference to 'diff -u' was for your PATCH.
http://bugs.gentoo.org/show_bug.cgi?id=73129#c1
Comment 5 david.antliff 2005-02-07 11:36:11 UTC
i.e. use 'diff -u dispatch-conf dispatch-conf.edited'
Comment 6 Chris Lear 2005-02-08 01:05:27 UTC
How embarrassing. Sorry for the misunderstanding. Here it is again.


$ diff -u /usr/sbin/dispatch-conf dispatch-conf.edited
--- /usr/sbin/dispatch-conf     2004-12-03 12:53:22.000000000 +0000
+++ dispatch-conf.edited        2004-12-03 14:48:50.000000000 +0000
@@ -159,10 +159,19 @@

             while 1:
                 if show_new_diff:
-                    os.system((self.options['diff'] + '| %s') % (conf['new'], mrgconf, self.options['pager']))
+                    if self.options['pager']:
+                        command_to_run = ((self.options['diff'] + '| %s') % (conf['new'], mrgconf, self.options['pager']))
+                    else:
+                        command_to_run = ((self.options['diff']) % (conf['new'], mrgconf))
+                    os.system(command_to_run)
                     show_new_diff = 0
+
                 else:
-                    os.system((self.options['diff'] + '| %s') % (conf['current'], newconf, self.options['pager']))
+                    if self.options['pager']:
+                        command_to_run=(self.options['diff'] + '| %s') % (conf['current'], newconf, self.options['pager'])
+                    else:
+                        command_to_run=(self.options['diff']) % (conf['current'], newconf)
+                    os.system(command_to_run)

                 print
                 print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])
Comment 7 Walther 2005-05-09 17:06:18 UTC
No activity since February? Heck, I am going back to etc-update + vimdiff then until this gets resolved. Consider this an "annoying bump" to this issue, but I think it is well deserved, for vimdiff is an excellent merging tool.
Comment 8 Amit Kotlovski 2005-05-10 14:49:28 UTC
a silly question - how do i incorporate the patch supplied here into my dispatch-conf?

Also if there is no problem with the patch offered, can it be a part of the standard dispatch-conf on portage?
Comment 9 Jason Stubbs (RETIRED) gentoo-dev 2005-05-11 05:40:17 UTC
It is not a good idea to use vim to edit config files when using it as the diff command. 2.0.51.20 brings in a "merge" config option which may be usable however.
Comment 10 Chris Lear 2005-05-11 06:29:26 UTC
>It is not a good idea to use vim to edit config files when using 
>it as the diff command.

This might be a matter of opinion. My opinion is that it's an excellent idea. I've been doing it ever since I started using Gentoo and realised that etc-update was unusable (for me) without using vimdiff.

I still don't use dispatch-conf because of the lack of support for a diff command that can be used without being piped to a pager. Note that the original problem is the insistence on paging (all the patch does is check the pager variable, and not try to pipe to it if it's empty), not any design decision that prevents the diff command from editing the file.
Comment 11 Jason Stubbs (RETIRED) gentoo-dev 2005-05-11 07:01:35 UTC
It is a design decision - regardless of the pager enforcement. Merging of files happens at another stage, which I've recently made into a configuration option. Put it this way, if dispatch-conf's three-way diffing/automatic updating ever eats all your config files because you're editing when it expects you to be viewing then don't post any bugs.
Comment 12 Chris Lear 2005-05-11 07:28:56 UTC
> It is a design decision - regardless of the pager enforcement.

OK, I accept that it's a design decision - but it isn't enforced at all except (it seems) by accident.

> Merging of files happens at another stage, which I've recently
> made into a configuration option.

Fair enough. I'll give it a go when I get hold of it.

> Put it this way, if dispatch-conf's three-way diffing/automatic 
> updating ever eats all your config files because you're editing 
> when it expects you to be viewing then don't post any bugs.

I won't. I only post bugs when I think there's something I reckon I should be able to do but can't.
Comment 13 Amit Kotlovski 2005-05-20 10:53:24 UTC
(In reply to comment #9)
> It is not a good idea to use vim to edit config files when using it as the
diff command. 2.0.51.20 brings in a "merge" config option which may be usable
however.

I emerged gentoolkit-0.2.1_pre2 which should contain the most recent version of
dispatch-conf.

How can i set vim to control the merge function?
Comment 14 Jason Stubbs (RETIRED) gentoo-dev 2005-05-20 17:20:28 UTC
dispatch-conf is part of portage rather than gentoolkit. 
Comment 15 Amit Kotlovski 2005-05-21 04:45:01 UTC
(In reply to comment #14)
> dispatch-conf is part of portage rather than gentoolkit. 

Oops. Thanks for correcting this out.

I was looking for a way to use vimdiff as the merging agent, when i came across
a remark on the env-update.conf file:
# NOTE_1: Editors such as vim/vimdiff are not usable for the merge_command
# because it is not known what filenames the produced files have (the user can
# choose while using those programs)

And indeed, i cannot give vim the name of the output file as an option.
If only dispatch-conf would have been able to give the merging agent a
duplicated version of the new file, it would have been very easy to merge on
that file. 

Do you find such an idea reasonable, or can you suggest some other method?
Comment 16 Amit Kotlovski 2005-06-08 14:57:18 UTC
Another suggestion:
Currently the parameters for both the old file, the new one and the output file
are %s.
If it was possible to change them into three different indicative parameters,
say %out for out, %new for new and %old for old, then it would have been
possible to use something other than 'sdiff' to do the merging.

Please respond to this suggestion, as this issue has been waiting for a long time.
Comment 17 Jason Stubbs (RETIRED) gentoo-dev 2005-06-18 01:02:16 UTC
The form is not so easy to change. People will likely be using dispatch-conf 
to update dispatch-conf.conf so a change in syntax has the ability to break 
itself. 
Comment 18 Jason Stubbs (RETIRED) gentoo-dev 2005-07-14 05:47:53 UTC
Fixed on or before 2.0.51.22-r1 
Comment 19 Jason Stubbs (RETIRED) gentoo-dev 2005-07-14 06:58:38 UTC
Looking through the batch of bugs, I'm not sure that some of these are 
actually fixed in stable. Others, the requirements have possibly changed after 
the initial fix was committed. 
 
If you think this bug has been closed incorrectly, please reopen or ask that 
it be reopened. 
Comment 20 Chris Lear 2005-07-14 08:23:32 UTC
Looks like it's possible to use
diff="vim -d %s %s"
And it doesn't break. I can't see how to make the merge work with vimdiff, but 
I think that the functionality of etc-update is replicated OK, so I'm happy 
with this.
Comment 21 Amit Kotlovski 2005-07-25 11:50:02 UTC
(In reply to comment #20)
> Looks like it's possible to use
> diff="vim -d %s %s"
> And it doesn't break. I can't see how to make the merge work with vimdiff, but 
> I think that the functionality of etc-update is replicated OK, so I'm happy 
> with this.

I find using vim as the diff tool disturbing, in view of Jason's comment #11.
I would still like to use vim as the merging tool, as it offers a much better
environment for comparison and fine editing.
Other solutions are to use dispatch-conf only for the auto-updating of config
files, and to manually vimdiff all the rest.

The issue that Jason raised in response to my suggestion can be solved in many
different manners - one of them is to add a flag in the config file indicating
usage og the "new merger command line parameters".

I would like to ask that this bug be reopened, so that this tool will be changed
in a manner that properly allows using vimdiff as the merger tool. I think it
will be better than opening a new bug for the same issue.
Comment 22 Jason Stubbs (RETIRED) gentoo-dev 2005-07-25 17:54:00 UTC
Okay. 
Comment 23 Jason Stubbs (RETIRED) gentoo-dev 2005-07-28 07:25:00 UTC
Putting a hold on feature requests for portage as they are drowning out the 
bugs. Most of these features should be available in the next major version of 
portage. But for the time being, they are just drowning out the major bugs and 
delaying the next version's progress. 
 
Any bugs that contain patches and any bugs for etc-update or dispatch-conf can 
be reopened. Sorry, I'm just not good enough with bugzilla. ;) 
Comment 24 Amit Kotlovski 2005-07-28 10:56:31 UTC
Are you saying that having many open bugs in the bugzilla is a problem for the
portage project?
How will this feature request be noticed unless this entry stays open?
If you will review my idea for solving this issue, i guess i could try and write
a patch for it myself and offer it here. Will this help to advance this issue?
Comment 25 Brian Harring (RETIRED) gentoo-dev 2005-07-28 11:28:25 UTC
patches always help.
Re: how will features get implemented without feature bugs, well, frankly was
this being implemented now?  It's been open for 7 months...
The later change on bugs comes down to trying to focus on addressing core
portage problems, and address stable bugs; stuff isn't blown off, but it is
being marked as what it is, later (core lib rewrite needs to be finished before
more stuff is jammed into portage).
Comment 26 Alun Jones 2006-03-17 06:09:46 UTC
(In reply to comment #25)
> patches always help.
> Re: how will features get implemented without feature bugs, well, frankly was
> this being implemented now?  It's been open for 7 months...

Just came across this thread whilst looking at how to configure dispatch-conf here. After reading all the comments, it seems to me this can be addressed fairly easily in the dispatch-conf.conf file. Here's what I've hacked together:

merge="out='%s'; old='%s'; new='%s'; cp \$old \$out ; vimdiff \$out \$new"

Comment 27 Marius Mauch (RETIRED) gentoo-dev 2007-01-11 14:17:41 UTC
Reopening for consideration (per comment #21)
Comment 28 dan zwell 2007-09-24 04:06:38 UTC
This is how to use emacs' ediff: (first, the complex way, which doesn't make permanent changes until you save)

merge='emacs "%s" --eval "(progn
                          (rename-buffer \\"merge\\")
                          (insert-file \\"%s\\")
                          (find-file \\"%s\\")
                          (rename-buffer \\"clean-new\\")
                          (toggle-read-only 1)
                          (ediff-buffers \\"merge\\" \\"clean-new\\") )"'

Here's a simpler alternative: (that I have not tested)
merge='out="%s"; old="%s"; new="%s"; cp "$old" "$out";
       emacs --eval "(ediff \"$out\" \"$new\")" '
Comment 29 Zac Medico gentoo-dev 2007-09-26 22:52:49 UTC
Comment #28 appears to present some solutions that use the 'merge' config option as it was designed to be used. Should we include one of those as an example in the config file?

If that approach isn't sufficient then please explain why. Please do not post any more suggestions that involve abuse of the 'diff' config option to modify files.
Comment 30 Tianon 2014-08-01 20:00:49 UTC
I love the solution provided, but I find that it makes for a more "logical" flow if I swap old and new like so:

merge="out='%s'; old='%s'; new='%s'; cp $new $out; vimdiff $out $old"

The biggest benefit here is that if you enter the merge and then immediately quit vim with ":qa", the diff you see in dispatch-conf remains unchanged.  Also, the flow feels cleaner, since instead of taking your old config and adapting bits of the updated config into that, you adapt the bits of your old config into the new one, which helps promote smaller future merges, since you then tend towards smaller and more discrete changes wherever possible.

This also makes sense logically since in "merge" you're not updating the current config, you're actually updating the "new" config which is then provided as a diff against the current config and offered for "use-new".

I also think it's worth noting that the line in the wiki (http://wiki.gentoo.org/wiki/Dispatch-conf#Use_.28g.29vimdiff_to_merge_changes) really leads to a somewhat unpleasant experience (especially since when I was playing with it, it broke the automatic vimdiff folding).

So I'm +1 on some variation of this simpler form being added as an example somewhere prominent, such as a comment in the conf file. :)