Ken Guest’s online diary

March 11, 2015

Disabling hg clean

Filed under: mercurial — kenguest @ 20:46
Tags:

I use phing a lot in work for kicking off unit tests, phpdocumentor, linting code and other such tasks – this includes using a ‘clean’ target which removes all of the generated files for when I want to ‘trim the fat’.

This is great, and all I have to do is type
$ phing clean
and the files are gone 😉

Occasionally I’ll have other files inside my working clone/repo – documentation that I’m writing up, debug files and such. Phing knows to leave these alone.

Did I mention we use mercurial? Mercurial has a clean subcommand.
$ hg clean
Do this, and all non-version controlled files are gone. Including documentation, debug files and such that I might have decided aren’t ready or shouldn’t be in the repo. I rarely use this.

I’m sure you can see the oncoming train that’s going to collide – if I tap “hg” when I mean to type “phing” all my carefully edited files may as well be exposed to supermagnetic radiation. Vamoosed! Gone. The README.md can no longer be read! (We’ve a nespresso machine in work too – maybe I’m overdoing the caffeine.)

Q: So what to do?
A: Cheat – outrageously.

The start of the [alias] section in my ~/.hgrc file now redefines ‘clean’:
[alias]
clean = version

Job done!

Advertisements

Blog at WordPress.com.