集市:提交时自动进行文件修改,并提交修改 [英] Bazaar: Automatic file modification on commit with the modification committed

查看:74
本文介绍了集市:提交时自动进行文件修改,并提交修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望集市在提交到commit分支中的文件时写入修订号,以便在提交中包含此修改。

I would like bazaar to write revision number on commit to a file in the committed branch so that this modification is included in the commit.

我查看了钩子,但是pre_commit钩子是仅在更改集创建后才运行,因此不会提交更改。

I looked at hooks but the pre_commit hook is only run after the changeset is created, thus the modification performed by it is not committed.

我发现了一个相关问题:
Bazaar:通过钩子提交之前修改文件内容吗?
,但是,建议的bzr-keywords解决方案

I found a related question: Bazaar: Modify file content before commit via hook? , however, the proposed bzr-keywords solution does not work either as its write conversion is not applied on commit:


bzr commit不会隐式地应用
提交文件后的写转换器,因此也不起作用。如果对于提供
内容过滤器的给定插件有意义,则该插件通常可以通过使用
的start_commit或post_commit钩子来实现此效果。
``bzr commit`` does not implicitly apply write converters after comitting files. If this makes sense for a given plugin providing a content filter, the plugin can usually achieve this effect by using a ``start_commit`` or ``post_commit`` hook.

这使我回到pre_commit挂钩问题。

which gets me back to the pre_commit hook problem.

我这样做的原因:我的软件从一个版本读取其版本文件编译。版本由主号,分支号和修订号(例如5.3.78)组成。我希望集市在提交时自动将实际版本写入版本文件。

My reason for doing this: my software reads its version from a version file on compilation. The version is composed of main number, branch number and revision number (eg 5.3.78). I want bazaar to write the actual version to the version file automatically on commit.

推荐答案

您应使用 start_commit 钩子,因为这是在提交之前更改文件的唯一方法: http://doc.bazaar.canonical.com/bzr.2.3/en/user-reference/hooks-help.html#start-commit

You should use start_commit hook because this is the only way to change file before commit: http://doc.bazaar.canonical.com/bzr.2.3/en/user-reference/hooks-help.html#start-commit


start_commit

start_commit

在对树执行提交之前调用。启动提交钩子能够在提交发生之前更改树。使用执行提交的bzrlib.mutabletree.MutableTree调用start_commit。

Called before a commit is performed on a tree. The start commit hook is able to change the tree before the commit takes place. start_commit is called with the bzrlib.mutabletree.MutableTree that the commit is being performed on.

这篇关于集市:提交时自动进行文件修改,并提交修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆