Mercurial hooks

Useful Mercurial Hooks

Add/document commit-hook

To close the branch retroactively, just update to it and close it. You can also do so in bulk if you need to:

for b in `hg heads --template '{branches}\n'`; do \
    tip=`hg log -r $b --template '{node}'`; \
    anc=`hg debuganc $b default | cut -d: -f2`; \
    if [ $tip = $anc ]; then \
      echo $b merged; \
      hg up $b; \
      hg ci --close-branch -m 'Closing merged branch.'; \
    else \
      echo $b unmerged; \
    fi; \
  done

via Using a named branch

hg log -r 'head()-parents(merge())-closed()' --template '{branch}\n'

via hg hook to detect unmerged changesets

Leave a Reply