Mercurial 的hook使用
1、
Handling repository events with hooks
可以通过Mercurial版本管理工具提供的hooks机制来处理repo的各种事件,从而实现对Mercurial的扩展,实现我们的特定需求。
2、
常用的hooks event事件:
摘自:http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html#sec:hook:precommit
changegroup: This is run after a group of changesets has been brought into the repository from elsewhere. 5 comments commit: This is run after a new changeset has been created in the local repository. No comments incoming: This is run once for each new changeset that is brought into the repository from elsewhere. Notice the difference from changegroup, which is run once per group of changesets brought in. No comments outgoing: This is run after a group of changesets has been transmitted from this repository. No comments prechangegroup: This is run before starting to bring a group of changesets into the repository. 2 comments precommit: Controlling. This is run before starting a commit. 2 comments preoutgoing: Controlling. This is run before starting to transmit a group of changesets from this repository. No comments pretag: Controlling. This is run before creating a tag. No comments pretxnchangegroup: Controlling. This is run after a group of changesets has been brought into the local repository from another, but before the transaction completes that will make the changes permanent in the repository. No comments pretxncommit: Controlling. This is run after a new changeset has been created in the local repository, but before the transaction completes that will make it permanent. One comment preupdate: Controlling. This is run before starting an update or merge of the working directory. One comment tag: This is run after a tag is created. No comments update: This is run after an update or merge of the working directory has finished. No comments
3、
hook配置:
可以修改本地仓库下面.hg/hgrc配置文件,语法规则:
The syntax for Python hooks is as follows:
hookname = python:modulename.submodule.callable
hookname = python:/path/to/python/module.py:callable
例:
  [hooks]
        precommit = python:.hg/signoff.py:sign_commit_message
4、函数参数:
all hooks will take ui, repo,hooktype  -- that's a very common pattern in Mercurial code (core, extensions, hooks, whatever)
例:我们一般可以这样定义函数:
import re def precommit_badbranch(ui, repo, **kwargs):
branch = repo[None].branch()
branch_re = re.compile(r'\d+\.\d+-branch$')
if not branch_re.match(branch):
ui.warn('invalid branch name %r (use <major>.<minor>-branch)\n')
return True
return False
5、返回值:
Hooks can be implemented as either external programs, or internal python calls. The meaning of the return value in both cases is based on the convention for external executables; in other words, a value of 0 means "success". For hooks implemented in python this can be a bit misleading, since it means you return "False" to indicate success and "True" (or throw an exception) to indicate failure.
return True 表明失败, 则此命令执行会失败
return False表明成功,此命令可以执行
6、
The Mercurial API
在写hook的时候,我们可以使用很多Mercurial提供的api,具体参见:
https://www.mercurial-scm.org/wiki/MercurialApi
参考:
http://hgbook.red-bean.com/ --重要
https://www.mercurial-scm.org/wiki/HookExamples
https://www.mercurial-scm.org/wiki/MercurialApi
https://www.mercurial-scm.org/wiki/Hook
https://selenic.com/hg/help/hgrc
Mercurial 的hook使用的更多相关文章
- Mercurial (hg) Hook : PHP Syntax Check , hg 代码检测 钩子
		用百度搜了一遍hg的hook教程,发现真的是太少了.公司目前正要用到这个,正好本人负责,So. 百度是个坑,少有的几篇文章,再加上善于发现的眼睛,发现TortoiseHg的UI操作都会在控制台显示动作 ... 
- svnserver hook python
		在使用中可能会遇到的错误排除 :1.Error: svn: 解析"D:\www\test"出错,或svn: E020024: Error resolving case of 'D: ... 
- Android Hook技术
		原文:http://blog.csdn.net/u011068702/article/details/53208825 附:Android Hook 全面入侵监听器 第一步.先爆项目demo照片,代码 ... 
- Frida HOOK微信实现骰子作弊
		由于微信摇骰子的功能在本地进行随机后在发送,所以存在可以hook掉判断骰子数的方法进行修改作弊. 1.frida实现hook java层函数1)写个用来测试的demo,当我们点击按钮的时候会弹出窗口显 ... 
- java的关闭钩子(Shutdown Hook)
		Runtime.getRuntime().addShutdownHook(shutdownHook); 这个方法的含义说明: 这个方法的意思就是在jvm中增加一个关闭的钩子,当jv ... 
- IDT HOOK思路整理
		IDT(中断描述符表)分为IRQ(真正的硬件中断)和软件中断(又叫异常). HOOK的思路为,替换键盘中断处理的函数地址为自己的函数地址.这样在键盘驱动和过滤驱动之前就可以截获键盘输入. 思路确定之后 ... 
- [解决]Mercurial HTTP Error 500: Access is denied on 00changelog.i
		总之,用户对仓库目录要有写权限 00changelog, access is denied, hg, http error 500, mercurial, permissions, push Merc ... 
- Android Hook 借助Xposed
		主要就是使用到了Xposed中的两个比较重要的方法,handleLoadPackage获取包加载时候的回调并拿到其对应的classLoader:findAndHookMethod对指定类的方法进行Ho ... 
- iOS App 无代码入侵的方法hook
		继续Objective-C runtime的研究 最近公司项目在做用户行为分析 于是App端在某些页面切换,交互操作的时候需要给统计系统发送一条消息 在几十个Controller 的项目里,一个一个地 ... 
随机推荐
- linux基础命令汇总
			目录 linux系统结构 常用命令 切换目录命令cd 文件操作 vi和vim编辑器 重定向输出>和>> 管道 | &&命令执行控制 网络通讯命令 系统管理命令 用户和 ... 
- python基础03day
			# 1. # 创建字符串变量的三种写法及其区别 # 代码: #‘’.“”.“““””” # 区别: # 2. # 简述,计算机编程语言的分类及特点 # 1.机器 # 2.汇编 # 3.高级 # 3.1 ... 
- .Net Core 遇到 “'windows-1252' is not a supported encoding name.”
			最近用 iTextSharp 拆分 Pdf 文档 加水印的时候遇到错误: 'windows-1252' is not a supported encoding name. For informatio ... 
- 1 Dalvik和Java虚拟机
			Dalvik虚拟机特点: 1. 体积小 2. DEX格式可执行文件,相比java运行速度快 3. 常量池采用32位索引值 4. 提供对象生命周期,堆栈,线程,权限,异常等管理 5. Andr ... 
- Java集合学习(6):LinkedHashSet
			一.概述 首先我们需要知道的是它是一个Set的实现,所以它其中存的肯定不是键值对,而是值.此实现与HashSet的不同之处在于,LinkedHashSet维护着一个运行于所有条目的双重链接列表.此链接 ... 
- 上传文本到hdfs上的一些命令
			在hadoop下创建文件夹 bin/hdfs dfs -mkdir -p /usr/hadoop/spark/ touch wc.input 写一些文本进去. 上传到hdfs上 bin/hdfs ... 
- 关于SQL中的 where 1 = 1 的用法
			在项目中的常见的一个操作:在有关SQL的代码中加入where 1 = 1,关于它的用法,可以总结如下: 首先,where 1 = 1的用法往往是为了方便后续的给SQL增加where限制条件.如果实现加 ... 
- Echarts实现Excel趋势线和R平方计算思路
			测试数据 [19550, 7.1 ],[22498, 8.44 ],[25675, 9.56 ],[27701, 10.77],[29747, 11.5 ],[32800, 12.27],[34822 ... 
- docker-ce添加国内源-阿里docker-hub镜像
			问题现象: WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled 问题解 ... 
- mac python3 安装mysqlclient
			brew install openssl export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ pip install mysql ... 
