Search code examples
mercurialhgrc

Common HgNotify template configuration


Is there a way to point to a common HgNotify configuration in each repositories' hgrc file on windows? I have the below notify section in each hgrc for every repo that I have on the server, and when I want to create a new repo, I have to copy this section into the hgrc.

[notify]
sources = serve push pull bundle
#For template, see: http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html
strip=3
template = 
  files:     
  {files}
  details:   {baseurl}/rev/{node|short}
  branches:  {branches}
  changeset: {rev}:{node|short}
  user:      {author}
  date:      {date|date}
  description:
  {desc}
  =================\n

test=false
maxdiff = 0
config=D:\hg\Repositories\HgNotify\NotificationList.txt

I am experimenting with changing the template and would like all repos to get the new template automatically.

Update: The Hg server is on windows and served thru IIS.


Solution

  • I ended up using the %include syntax for an hgrc file, in part because the server is a Windows box and I was not sure where to put a global hgrc file that could be accessed by the IIS server/IIS user.

    I put the following at the end of my hgrc files:

    %include D:\Hg\HgNotify\hgrc.notify.txt

    The %include actually works out great because it allowed me to put the file in an hg repo of its own so that I can have a history of changes made.

    Here's what a complete hgrc file looks like in one of my repos:

    [web]
    name=MyRepo
    [email protected]
    push_ssl=False
    description=MyRepo
    allow_archive = zip
    allow_push = *
    baseurl = http://hg.mydomain.net/MyRepo
    logourl = http://hg.mydomain.net/
    
    [extensions]
    hgext.notify = 
    progress = 
    rebase =
    
    [hooks]
    changegroup.notify = python:hgext.notify.hook
    
    #Include file for common notification template
    %include D:\Hg\HgNotify\hgrc.notify.txt