You are not logged in.

#1 2012-08-05 01:30:22

electron
Member
Registered: 2010-03-23
Posts: 4

pacdiff3 - Three-way merge for dealing with pacnew files

I've long been irritated by how painful dealing with my .pacnew files can be. Frequently I make small edits to my configuration files. Then any time a package updates its configuration file, I have to manually merge back changes from the resulting .pacnew file. If the new version is significantly different from the old version I sometimes even have trouble remembering which differences between my local copy and the pacnew were my edits and which were not. This afternoon I decided to do something about it.

I've written two fairly small python scripts, pacold-create and pacdiff3. pacdiff3 is intended to be run after every time pacman updates the system. pacold-create is invoked by pacdiff3.

pacold-create looks for each .pacnew file in /etc. If it does not already have a corresponding .pacold file, it figures out which package the file belongs to and then looks in the package cache. It retrieves the original version of the file from the second to most recent package version in the cache (assuming the most recent one is where the .pacnew file is derived from). If pacold-create is not run every time pacman updates the system, there is a risk that the .pacold file will be created from a newer version of the package than it should be, making the merging slightly less nice. Also, this assumes that you keep at least two versions of each package in the cache, if you do not than pacold-create won't be able to create any .pacold files.

pacdiff3 functions similarly to pacdiff except it performs three-way merges. The merge program that it invokes is based on the environment variable PACDIFF3_MERGECMD which should be a complete command to launch the merge program of your choice. This command should use the variables $PACNEW, $PACOLD, $LOCAL, and $MERGE (where to write the results of the merge to) to specify the arguments to the merge program. For example, to set kdiff3 as the merge program you would use.

PACDIFF3_MERGECMD="kdiff3 -m -o $MERGE $PACOLD $LOCAL $PACNEW"

If the PACDIFF3_MERGECMD environment variable is not set, it uses kdiff3 if available, then emacs ediff if available. If neither of those is available, it displays the results of diff3 using EDITOR (or vi if EDITOR is not set).

You can find the scripts at
http://quark.kiewit.dartmouth.edu/~james/pacdiff3 and
http://quark.kiewit.dartmouth.edu/~james/pacold-create

Once I've had a chance to test more (and possibly gotten some feedback), I will create an AUR package for this.

Obviously having pacman itself do the .pacold creation would be preferable. If the pacman maintainers are interested in having .pacold creation functionality in pacman itself, I would be happy to implement that and get rid of my pacold-create script.

I suspect there are bugs and flaws in these scripts. I wrote them this afternoon and have tested them on all of one single .pacnew file. Please let me know any problems you find (and whether or not you find three-way merging for pacnew files useful).

Offline

#2 2012-08-16 07:16:23

leniviy
Member
Registered: 2009-05-23
Posts: 150

Re: pacdiff3 - Three-way merge for dealing with pacnew files

electron wrote:

It retrieves the original version of the file from the second to most recent package version in the cache (assuming the most recent one is where the .pacnew file is derived from).

I don't like this approach. No downgrade, no custom packages.

Anyone knows another merge program that just stores the canonic config files of all the installed packages in some place?


Arch 64, xfce4

Offline

#3 2012-12-26 16:11:01

electron
Member
Registered: 2010-03-23
Posts: 4

Re: pacdiff3 - Three-way merge for dealing with pacnew files

leniviy, can you describe exactly what it is you'd like to see instead? I might be interested in implementing it, but I don't quite understand from your post what you're proposing.

Offline

Board footer

Powered by FluxBB