hghooks-and-scripts / force-one-head.sh

#!/bin/bash
# -*- coding:sjis-unix -*-
#
# <repository>/.hg/hgrc に追記してください
# ----------------------
# Linux の場合
# ----------------------
# [hooks]
# pretxnchangegroup.forceonehead = .hg/force-one-head.sh
# -----------------------------------------------------------
# ----------------------
# Windows(Cygwin) の場合
# ----------------------
# [hooks]
# pretxnchangegroup.forceonehead = call .hg\force-one-head.bat
# -----------------------------------------------------------
# Cygwin の環境の場合、PATH環境変数に /usr/bin を通すと hg が 
# Cygwin 提供のhg になり、うまく hooks 処理が動作しません
#
export LANG=C 


if [ $(hg heads --template "{branch}\n"|/usr/bin/sort|/usr/bin/uniq|/usr/bin/wc -l) != $(hg heads --template "{branch}\n"|/usr/bin/sort|/usr/bin/wc -l) ]; then
    echo '============================================================'
    echo '[警告] マルチプルヘッドになっています'
    echo '       hg pull して hg rebase を実行し、マージしてください'
    echo '       # hg push -f はつかってはダメ'
    echo '============================================================'

    exit 1
fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.