-
-
Save oyakata/1113427 to your computer and use it in GitHub Desktop.
hg branchで数値のブランチを作るとリビジョン番号と混同して紛らわしいので生成不可能にするエクステンション。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[extensions] | |
sb=~/work/hgsmpl/myhgext/safe_branch.py | |
# pyファイルを置いた場所を指定して下さい。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import re | |
from mercurial import ui, hg, commands | |
MSG = """ | |
指定したブランチの名前"%s"は数値です。 | |
このブランチを作ると"%s"のリビジョン番号が使えなくなるのでやめて下さい。 | |
とfeiz(https://twitter.com/#!/feiz)が申しております。 | |
""" | |
def sb(ui_, repo, label=None): | |
if label and re.match(r"^[0-9]+$", label): | |
ui_.write(MSG % (label, label)) | |
return | |
commands.branch(ui_, repo, label) | |
cmdtable = { | |
# "コマンド名": (関数, オプション, ヘルプ) | |
"sb": (sb, [], "safe branch") | |
} | |
if __name__ == "__main__": | |
import sys | |
ui_ = ui.ui() | |
args = sys.argv[1:] | |
label = args[0] if args else None | |
repo = hg.repository(ui_, ".", label) | |
sb(ui_, repo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment