From abe at deuxchevaux.org Wed Nov 16 02:07:01 2011 From: abe at deuxchevaux.org (Axel Beckert) Date: Wed, 16 Nov 2011 02:07:01 +0100 Subject: [xen-tools-dev] Code (De)Duplication in xen-tools/bin/* Message-ID: <20111116010701.GZ2034@sym.noone.org> Hi, due to a bug report in Debian against xen-create-nfs[0] which handles configuration values differently than xen-create-image, I noticed that there are quite some similar to identical functions in all Perl scripts in bin/ which means tons of code duplication. [0] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=648814 While there are functions which have the same name but are script specific, I found at least four functions which were either identical, very similar or clearly at different states of evolution. I merged them all[1] into a new Perl Module Xen::Tools::Common[2] which is now used by all these scripts. [1] https://github.com/xtaran/xen-tools/commits/code-deduplication [2] https://github.com/xtaran/xen-tools/blob/code-deduplication/lib/Xen/Tools/Common.pm The diffstat shows the amount of deduplication (plus some other fixes and documentation): $ git diff --stat 9a966869536a9d1efd984382c99cf8ab8f3ce000..HEAD KNOWN_BUGS | 4 + TODO | 13 ++ bin/xen-create-image | 196 ++++--------------------------- bin/xen-create-nfs | 164 +------------------------- bin/xen-delete-image | 180 ++--------------------------- bin/xen-list-images | 80 +------------ bin/xen-resize-guest | 109 +----------------- bin/xen-update-image | 107 +----------------- bin/xt-create-xen-config | 79 +------------ bin/xt-install-image | 145 ++--------------------- lib/Xen/Tools/Common.pm | 291 ++++++++++++++++++++++++++++++++++++++++++++++ t/perl-syntax.t | 2 +- 12 files changed, 360 insertions(+), 1010 deletions(-) I plan to merge this in the master branch. Any comments? With regards to the roadmap: The 4.2 branch got some more bugfixes and I'll try to release a 4.2.2 somewhen soonish. The above mentioned code-deduplication and the remaining changes in the master branch will probably make up some 4.3 release after the 4.2.2 bugfix release. Kind regards, Axel -- /~\ Plain Text Ribbon Campaign | Axel Beckert \ / Say No to HTML in E-Mail and News | abe at deuxchevaux.org (Mail) X See http://www.asciiribbon.org/ | abe at noone.org (Mail+Jabber) / \ I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)