1

I guess this is really 2 questions:

  1. How do I get an update hook to execute the following:

hg heads --template 'version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}'

Simply putting: update = <above command> in the [hooks] section of the hgrc file, doesn't seem to work.

  1. How do I redirect output from the above to a text file? Appending > log.txt or | log.txt doesn't work at all

I'm sure this is really basic and my command line knowledge is really basic - I just learned all of the above command this morning!

BTW, if it helps, I am running TortoiseHg 2.6.1 with Mercurial 2.4.1

RdeG
  • 83
  • 5

1 Answers1

1
  1. According to Hooks wiki-page

Hooks can be implemented as either external programs, or internal python calls.

i,e you can't write hg COMMAND directly in [hooks] section, but can write yjis command in shell-script, which in called in hook. Something like

[hooks]
update = updatehook

with updatehook.sh | updatehook.bat in PATH (or with full path to script), in which you have as main part

hg heads --template "version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}\n" > SOMEPATH/log.txt

(note added \n at the end of template - for multi-head repository it's needed)

>hg heads --template "version {tags}\tbuild {rev}.{node|short}\tcommitted on {date|shortdate}\n"
version default/2.0 tip build 4638.4a48cef94e2e committed on 2014-12-24
version default/master  build 4620.de0053588acf committed on 2014-12-23
version default/1.6     build 2344.fc32e948fcba committed on 2013-01-06
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • Brilliant, thank you so much! I did read about implementing hooks as external programs, but clearly didn't comprehend what it meant. I know, I'm slow. But your explanation was clear and concise and I now understand what's going on. Thanks again. – RdeG Dec 26 '14 at 15:35