Using server side hook to check files changed
Aaron Bentley
aaron at aaronbentley.com
Mon Oct 22 16:54:12 UTC 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12-10-22 12:15 PM, Stuart Moore wrote:
> Hello,
>
> We're trying to use a server-side hook to check which files are
> changed in a commit, and if those changes are inappropriate (e.g.
> including temporary files) prevent that change being committed.
> (Ideally I'd also be able to examine those files' contents before
> the commit happened.)
>
> I've had a real problem working out how I'm meant to do this - I've
> been investigating the "pre_change_branch_tip" hook, but it doesn't
> seem to have any way of geting a list of the files changed in this
> commit.
Not itself, but a Branch has access to all the revisions, and
pre_change_branch_tip will tell you what revisions to look at.
Using the old_revid and new_revid, you can call
self.repository.revision_trees, to get the old and new trees, then
Tree.compare or Tree.iter_changes to compare them.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlCFejQACgkQ0F+nu1YWqI1T8gCghWVd6dzmjm1ui13kJRYj8+5i
dRwAnA5gB1uKW0G6xYjL14PTZ8Uuwccc
=KFvo
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list