HTTPS SSH

hgskipcommit

Author: Alan Franzoni

Project Homepage: http://hgskipcommit.franzoni.eu

intro

Mercurial extension that allows to skip some files when committing, even if
they're marked as modified, something like "ignore on commit".

Use case

Even though it would be better to commit a template on a vcs - that
every user or developer can then copy and customize, there are some situations
where that's not possible, mostly because some externally managed software
(e.g. a library, framework, or IDE) insists on using or modifying certain
well-known filenames.

If developers, then, inadvertently modify and commit such files, many problem
could arise.

This extension provides a simple way to prevent it; if a "wild commit" (i.e. a
commit without file selection) occurs, any file matching the hgskipcommit
pattern won't get committed, and will just stay modified on the repo.

how it works

Ehenever a commit without file selection is issued, the hgskipcommit pattern is
taken into account and just added to the 'exclude' options for commit; the very
same functionality can be achieved via command line -X option.

If at least one target file to be committed is passed on the command line this
extension performs no action. Also, the extension is automatically disabled when
committing a merge, since it would make little sense and you can't do partial
commits of a merge anyway.

install

after cloning the repo or getting the tarball, edit your $HOME/.hgrc, and enable the extension:

[extensions]
hgskipcommit=PATH/TO/hgskipcommit.py

configure

Configuration, just like any mercurial config value, can be done system-wide,
per user, or per repo. In the hgrc you choose, just add the section and
configure the pattern value.

Small notice: at the time of this writing, patterns are not additive; anything
specified in an higher priority config file just overrides the lower priority
setting. Priority in descending order is repo -> user -> system.

example

Skip committing config files from the most well-known IDEs, since
they often pollute commits

[hgskipcommit]
pattern = path:.idea path:nbproject path:.project path:.settings glob:*.iml

options

You can pass the --everything flag to prevent the extension from applying its
exclusion patterns.

pattern syntax

pattern syntax just follows mercurial patterns - see `hg help patterns'
more information.

Be aware that setting an absolute exclude (relative to repository root) will
probably require a path: or re: file pattern, otherwise it'll be interpreted as
an exclude relative to the current directory.

current status and known issues

Configuration is currently handled as extensions configuration, so it's not
shared between repositories. If there're requests I may make a change and adopt
an .hgignore like approach that could be shared between repositories.

There may be use cases - especially when doing backouts, patch queue and
similar operations, that I've not considered yet. Feel free to open a ticket
with your problems and I'll try fixing the issue ASAP.

credits

Thanks to Erik Zielke from Aragost Trifork for his exclude extension
which shares a common usage pattern with mine, and from which I've taken some
parts of code.