Code duplication in Mercurial

Alexander Plavin me at aplavin.ru
Sat Jul 13 17:30:31 CDT 2013


For the sake of interest today I ran CloneDigger
(http://clonedigger.sourceforge.net/) on the hg codebase, and it found
a lot of places with duplicate code there (it counted about 200
duplicates). Some places have exact the same code, while some differ
in variable names, or something like this. For example, there are same
pieces of code in mercurial/hgweb/webcommand.py which are related to
dealing with number of shown revisions (of course, it's just one
example). Probably, some of the duplicates are worth moving into
separate functions (also, there are almost equal different functions,
which can me merged into one with extra argument). Now I'm writing it
here just to point at this, as the code duplication can make it more
difficult to change something in code correctly.

P.S.: CloneDigger took more than 10 minutes and 1.5 Gb of memory to run.


More information about the Mercurial-devel mailing list