Version control 如何监控Mercurial中特定文件的更改?
我已经建立了一个远程Mercurial(Hg)存储库,其中包含一个大型Java项目。我想监控对项目pom文件所做的任何更改,并在pom更改时接收电子邮件 我想从通知中排除所有其他文件更改,因为我只对监视依赖项(因此POM)中的任何可能更改感兴趣。是否有使用Jenkins订阅Mercurial repo中单个文件的更改历史记录的Mercurial扩展或解决方法?会发送关于repo更改的电子邮件 (参见第6节)提供了一种迭代变更集中文件的方法 将这两件事放在一个定制挂钩中应该相当简单。查看上下文,只有在提到您的特殊文件时才发送电子邮件。@Ed.ward 我最近不得不这样做(将notify扩展名与change上下文结合起来),以便仅在某些文件发生更改时通知。 为了从您自己的钩子调用notify钩子,您需要导入hgext,然后调用hgext.notify.hook。我的python工作示例:Version control 如何监控Mercurial中特定文件的更改?,version-control,mercurial,notify,Version Control,Mercurial,Notify,我已经建立了一个远程Mercurial(Hg)存储库,其中包含一个大型Java项目。我想监控对项目pom文件所做的任何更改,并在pom更改时接收电子邮件 我想从通知中排除所有其他文件更改,因为我只对监视依赖项(因此POM)中的任何可能更改感兴趣。是否有使用Jenkins订阅Mercurial repo中单个文件的更改历史记录的Mercurial扩展或解决方法?会发送关于repo更改的电子邮件 (参见第6节)提供了一种迭代变更集中文件的方法 将这两件事放在一个定制挂钩中应该相当简单。查看上下文,只
import re, traceback
import hgext
def check_changegroup(ui, repo, hooktype, node=None, source=None, **kwargs):
ui.note("Checking for files in %s with path: %s\n" % (repo.__class__.__name__, repo.root))
file_match = ".*base.*" #ui.config('monitor_files', 'file_match')
ui.note("file_match: %s\n" % file_match)
file_match_re = re.compile(file_match, re.I)
monitored_file_changed = False
for rev in xrange(repo[node].rev(), len(repo)):
changectx = repo[rev]
for f in changectx.files():
if file_match_re.match(f):
ui.note(" matched: %s\n" % f)
monitored_file_changed = True
if monitored_file_changed:
ui.note("rev: %s from user: %s has changes on monitored files\n" % (rev, changectx.user()))
if monitored_file_changed:
ui.note("calling notify hook\n")
try:
hgext.notify.hook(ui, repo, hooktype, node, source)
except Exception as exc:
ui.warn(('%s error calling notify hook: %s\n') % (exc.__class__.__name__, exc))
traceback.print_exc()
raise
看起来是这样:)但你能更详细地描述一下怎么做吗?据我所知,我应该用钩子的代码覆盖changegroup.notify=python:hgext.notify.hook。但是,如果发现目标文件已更改,如何从代码中调用原始的“hgext.notify.hook”?