Adding HG_DEST for post-clone hook

Sietse Brouwer sbbrouwer at gmail.com
Fri Jan 11 13:47:07 UTC 2019


Hi Anatoly,

On 08/01/2019 16:33, anatoly techtonik wrote:

 > Over the years I had to type my email and name at least 260 times
 > judging from amount of repository clones in my public accounts.

I, too, have some repos for work, and some personal repositories. The 
solution I settled on is to make it as easy as possible to configure a 
repository as work or personal.

- I don't set my name or e-mail in the hgrc in my home directory
- I have aliases `hg work` and `hg personal` to set my name and e-mail 
in the repo hgrc
- I have a post-clone hook that reminds me to run `hg work` or `hg 
personal`.


     # /home/sietse/.hgrc
     [ui]
     askusername = True  # get a reminder if repo has no username set

     [hooks]
     post-init.username_reminder = echo '[run hg personal / hg work]'
     post-clone.username_reminder = echo '[run hg personal / hg work]'

     [alias]
     personal = !
         echo '[ui]' >> $(hg root)/.hg/hgrc;
         echo 'username = Sietse Brouwer <sbbrouwer at gmail.com>' >> $(hg 
root)/.hg/hgrc

     work = !
         echo '[ui]' >> $(hg root)/.hg/hgrc;
         echo 'username = Sietse Brouwer <s.brouwer at anchormen.nl>' >> 
$(hg root)/.hg/hgrc


Example of usage:

     $ hg clone git+https://github.com/pomp/circumstance
     $ cd circumstance
     $ hg personal

I realise you were asking about adding a parameter to the original 
init/clone command, but perhaps a dedicated username-setting alias could 
also work.

Cheers,

Sietse







More information about the Mercurial mailing list