Creating an 'hg ignore' extension
I often wish Mercurial had an 'hg ignore' command similar to 'bzr ignore'. Turns out it's pretty easy to add one:
#!/usr/bin/env python """Ignore pathnames and patterns""" import os def ignore(ui, repo, *pathnames): """Ignore the given pathnames and patterns.""" outf = open(os.path.join(repo.root, ".hgignore"), "a") for p in pathnames: outf.write(p + "\n") outf.close() return cmdtable = { 'ignore': (ignore, [], "hg ignore pathname [pathname]"), }
To use this, save it to a file such as ${HOME}/platform/independent/lib/hg/ignore.py
. Then add the extension to your ${HOME}/.hgrc
:
[extensions] ~/platform/independent/lib/hg/ignore.py