Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Hotfiles extensions

Author: Benoît Allard <benoit.allard@gmx.de>
website:https://bitbucket.org/benallard/hotfiles

Introduction

It all began from a blog post about bug prediction, that describes how some files can be considered as hot spots inside a codebase. Those files, for instance have to be reviewed more carrefully than others, or even, development on them should be done with a higher level of alert. The trouble is only, how to detect those files when you are new to the codebase. The Google blog post quotes a few papers that shows that history can helps.

I decided to implement their method as a Mercurial extension.

Installation

Like any other extension, this one has to be enables in one of the mercurial configuration file like this:

[extensions]
hotfiles = path/to/hotfiles.py

Usage

This extension adds a new command hotfiles that displays the ten files the most succeptible to have issues. Or at least, the one that contained issues in the late time.

This command can takes up to four parameters:

-r REV, --revision REV
 This stop the computation at a particular revision and displays the hot files at that moment in time. By default, the current parent revision will be used.
-p REGEX, --pattern REGEX
 This is a regular expression used on the commit message to filter only the changesets that are related to issues.
-I PATTERN, --include PATTERN
 The specified files will be explicitely included in the computation (the rest will be excluded).
-X PATTERN, --exclude PATTERN
 The specified files will be excluded from the included files.

Example:

hg hotfiles -p 'issue\d+'

Will display the ten files the most succeptible to contains bug if run in the Mercurial repository.

Configuration

Filtering of changesets

The value of the regex to filter issue changesets can be configured in the mercurial configuration file. In this case, if not provided on the command line, this one will be taken. The value is configured as follow:

[hotfiles]
pattern = issue\d+

If neither the configuration file, nor the command line parameter is provided, all non-merge changesets will be considered in the computation.

Filtering of files

To filter some parts of the files out of the computation, like the docs or the test directory for instance, a set of exclude and include rules can be used like in the following example:

[hotfiles]
exclude.glob =
  mercurial/util.py
include.glob =
  mercurial/

If the include.glob key is not set, all files will be included, if the exclude.glob key is not set, all included files will be considered.

Contributing

For bug reports, pull requests, comments, ... simply use the Bitbucket interface or send me a mail.

Recent activity

sim...@besonet.ch

Commits by sim...@besonet.ch were pushed to benallard/hotfiles

89b6400 - Add argument for number of hot files to show only number of files, no range and no % of total files
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.