标签: mercurial-hook

轻松,无痛的方式测试新的mercurial钩子(正在进行的工作)

我正在编写一个mercurial changegroup hook.我还没有想到所有的东西,但是由于我必须继续承诺并且只是为了测试我正在进行的工作,因此试错的过程变得更加痛苦.

是否有任何方法可以"伪造"触发器来执行我的changegroup钩子,并使用存储库的当前状态来使用它的参数?

任何帮助简化这一过程的人都将非常感激.谢谢尼克

python mercurial mercurial-hook

16
推荐指数
2
解决办法
1636
查看次数

Mercurial钩子禁止提交大型二进制文件

我希望有一个Mercurial钩子,它将在提交事务之前运行,如果提交的二进制文件大于1兆字节,该事务将中止事务.我找到了以下代码,除了一个问题,它工作正常.如果我的更改集涉及删除文件,则此挂钩将引发异常.

钩子(我正在使用pretxncommit = python:checksize.newbinsize):

from mercurial import context, util
from mercurial.i18n import _
import mercurial.node as dpynode

'''hooks to forbid adding binary file over a given size

Ensure the PYTHONPATH is pointing where hg_checksize.py is and setup your
repo .hg/hgrc like this:

[hooks]
pretxncommit = python:checksize.newbinsize
pretxnchangegroup = python:checksize.newbinsize
preoutgoing = python:checksize.nopull

[limits]
maxnewbinsize = 10240
'''

def newbinsize(ui, repo, node=None, **kwargs):
    '''forbid to add binary files over a given size'''
    forbid = False
    # default limit is …
Run Code Online (Sandbox Code Playgroud)

mercurial hook pre-commit-hook mercurial-hook

10
推荐指数
2
解决办法
2976
查看次数

如何与所有开发人员共享mercurial中的commit-hook?

我们正在使用mercurial,现在我们想引入precommit钩子来保持代码清洁.我们希望每个人以某种方式得到钩子,但我们也希望能够以某种集中的方式更新它.Mercurial没有版本控制钩子,那么我们的替代选择是什么呢?你们有没有找到解决方案?提前致谢!

Nemmi

mercurial pre-commit pre-commit-hook mercurial-hook

9
推荐指数
1
解决办法
727
查看次数

Mercurial pretxncommit hook - 仅在提交时执行,忽略rebase和patch

我们使用pretxncommithook for HG对提交的代码运行快速静态分析检查.但是,在对提交树应用任何更改时触发挂钩 - 包括重新绑定和使用MQ编辑和压缩提交.

是否有可能以某种方式检查钩子本身发生了什么类型的变化?喜欢

def analyze_hook(ui, repo, node=None, **kwargs):
    if repo.state.is_commit_added and not (repo.state.is_rebase or repo.state.is_patch):
        return 0
Run Code Online (Sandbox Code Playgroud)

mercurial mercurial-hook

9
推荐指数
1
解决办法
62
查看次数

tortoisehg一步提交推送 - 如何以及在哪里是日志文件

我使用win xp与Tortoisehg 2.3.我使用位桶来备份我的个人源代码.(很少用于真正的版本控制,更多用作源备份存储).现在我必须右键单击我的仓库,选择提交,然后输入提交消息(我选择只复制我上次使用的相同消息,有一个下拉列表来执行此操作),然后单击提交.然后我再次右键单击并选择同步并通过此选项最终推送.我可以使用工作台并做类似的事情.我想优化这个过程,所以我决定只写一个dos bat脚本来提交和推送.当我推动Tortoisehg吐出hg命令到窗口时你可以看到它并从这里剪切和粘贴.对于提交,它没有显示它在幕后真正做的事情.当我长期使用TortoiseSVN时,我记得有一个日志文件,其中存储了所有执行的svn命令以进行调试.所以我开始搜索TortoiseHg日志文件.

有人知道吗:

1)Tortoisehg是否有一个日志文件,它存储所有执行完所有的mercurial命令以及所有命令行选项?

2)有没有更好的方法进行一步提交推送(通过Tortoisehg gui或bat或某些插件/扩展等)?

问候

mercurial tortoisehg mercurial-hook mercurial-extension tortoisehg-2.0

8
推荐指数
2
解决办法
5069
查看次数

Mercurial Hook - 在提交前更改提交消息

编辑制作此基本挂钩以防止分支名称和提交消息bugID不匹配.https://gist.github.com/2583189

所以基本上这个想法是,如果分支名称类似于bug_123或feature_123,那么钩子应该在提交消息的末尾附加"BugID:xyz".然而,我在找到如何做到这一点时遇到了问题,因为大多数的pretxncommit人员都不想改变变更集描述.

这就是我到目前为止所拥有的.它使用正确的消息更新.hg/commit.save,但此消息永远不会传递给提交.然而,它显示在下一次提交的默认消息框(tortoisehg)中.也许pretxncommit不是正确的钩子?

我可以使用precommit钩子,读取commit.save和repo ['tip'].branch()文件并更改它,如果是这样我将从哪里获取分支名称?

#
# Fogbugz automaticically add BugID:123 to commit messages based on branch names.
# Your branch name must be in the format feature_123_description or bug_123_description
#

import re
import mercurial, sys, os

_branch_regex = re.compile('(feature|bug|case|bugid|fogbugz)_(\d+)')
_commit_regex = re.compile(r'\b(?P<case>(review|case|bug[zs]?(\s| )*(id)?:?)s?(\s| )*([#:; ]| )+)((([ ,:;#]|and)*)(?P<bugid>\d+))+',re.I)

def pretxncommithook(ui, repo, **kwargs):
    ui.write('hook pretxncommithook running from fogbugz.py\n')
    """
    Checks a single commit message for adherence to commit message rules.

    To use add the following to your project .hg/hgrc …
Run Code Online (Sandbox Code Playgroud)

python mercurial mercurial-hook

8
推荐指数
2
解决办法
2293
查看次数

Mercurial钩子没有正确执行

这应该是一个非常简单的运行,但由于某种原因它不适用于我的Mercurial存储库.我想要的只是远程仓库hg update在有人推送时自动运行.所以我在.hg/hgrc文件中有这个:

[hook]
changegroup = hg update
Run Code Online (Sandbox Code Playgroud)

简单吧?但由于某种原因,这永远不会执行.我也尝试编写一个执行此操作的shell脚本..hg/hgrc看起来像这样:

[hooks]
changegroup = /home/marc/bin/hg-update
Run Code Online (Sandbox Code Playgroud)

和hg-update看起来像这样:

#!/bin/sh
hg help >> /home/marc/works.txt;
hg update >> /home/marc/works.txt;
exit 0;
Run Code Online (Sandbox Code Playgroud)

但同样,这不会更新.hg help写出来的内容works.txt,但没有写出来hg update.有什么明显的东西我在这里不见了吗?这一直困扰着我好几天,我似乎无法让它发挥作用.

更新

好的,再次,使用-v我的工作站命令行上的开关推送到远程仓库,即使我有这些echo行,也不打印任何详细消息.hg/hgrc.但是,当我从同一文件系统上的repo克隆推送(我通过SSH登录)时,这就是我得到的:

bash-3.00$ hg -v push ../test-repo/
pushing to ../test-repo/
searching for changes
1 changesets found
running hook prechangegroup: echo "Remote repo is at `hg tip -q`"
echo "Remote repo wdir is at `hg parents -q`"
Remote repo is …

version-control mercurial mercurial-hook

7
推荐指数
2
解决办法
7555
查看次数

Mercurial:在"hg commit"之前强制执行"hg pull -u"

在某些情况下,我需要强制Mercurial用户hg pull -u在任何hg commit可以被允许之前运行,即,hg pull意味着传入队列是空的 - 此外我还希望该人正在使用分支的头版本.

我该如何设置这样的限制?

(我完全清楚这与DVCS设计核心部分有关)

mercurial dvcs mercurial-hook

7
推荐指数
1
解决办法
2001
查看次数

我可以配置mercurial钩子,就像在hgrc文件中配置一些扩展一样?

我知道如何指定何时运行哪些挂钩.我想知道的是,是否可以通过hgrc文件将配置传递到钩子中.扩展可以做到这一点,例如

[extensions]
someextension = something

[someextension]
some.config = 1
some.other.config = True
Run Code Online (Sandbox Code Playgroud)

我希望能够为钩子做类似的事情,例如

[hooks]
changegroup.mail_someone = python:something

[changegroup.mail_someone]
to_address = some.email.address@somewhere.com
Run Code Online (Sandbox Code Playgroud)

这样的事情可能吗?寻找一种方法来做到这一点并没有发现任何有用的东西...如果可能的话,我如何在我的(Python进程中)钩子处理程序中读取配置?

python mercurial dvcs mercurial-hook

6
推荐指数
1
解决办法
342
查看次数

让Jenkins从Mercurial提交中构建项目

有没有办法在单个存储库中指定一个钩子?

现在我们已经在"/ etc/mercurial/hgrc"文件中指定了钩子,但每次构建两次时,它都会为每个存储库中的每个提交构建.

所以我们想要为每个存储库指定一个构建.

这就是我们实现钩子的方式:

[hooks]
changegroup = curl --silent http://jenkins:8080/job/ourProject/build
Run Code Online (Sandbox Code Playgroud)

它在Ubuntu服务器上.

mercurial-hook jenkins mercurial-commit

6
推荐指数
2
解决办法
5462
查看次数