hghooks: remove legacy IDL/UUID change verification hooks (
bug 1170718); r?froydnj
These deleted hooks (and references to them) were used to prevent
unwanted binary compatibility breakage with XPIDL interfaces (which
would impact extensions).
We no longer support binary extensions on any repository that we still
release from. So these hooks no longer serve a purpose and can be
deleted.
MozReview-Commit-ID: 2y9yxZ9cFJ0
--- a/docs/hgmods/hooks.rst
+++ b/docs/hgmods/hooks.rst
@@ -37,34 +37,22 @@ targeted towards the Firefox commit mess
prevent_case_only_renames.py
----------------------------
This hook prevents file renames that only change the case of a file. e.g.
renaming ``foo`` to ``FOO`` would be disallowed.
This hooks exists to prevent issues with case-insensitive filesystems.
-prevent_idl_change_without_uuid_change.py
------------------------------------------
-
-This hook prevents non-comment changes to IDL interfaces without accompanying
-UUID bumps.
-
prevent_string_changes.py
-------------------------
This hook is used to prevent changes to strings in string frozen release
heads without the explicit approval from l10n-drivers.
-prevent_uuid_changes.py
------------------------
-
-This hook prevents changes to IDL IIDs or UUIDs when they shouldn't be made.
-This hook helps ensure binary compatibility of Firefox as it is released.
-
prevent_webidl_changes.py
-------------------------
This hook prevents changes to WebIDL files that shouldn't be made.
All WebIDL changes must be reviewed by a DOM peer and this hook enforces
that.
deleted file mode 100644
--- a/hghooks/mozhghooks/prevent_idl_change_without_uuid_bump.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2015 Mozilla Foundation
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-"""
-This hook prevents non-comment changes to IDL interfaces without accompanying
-UUID bumps.
-
-The check can be skipped by adding 'IGNORE IDL' to the relevant commit messages
-or 'a=release' to the tip commit message.
-"""
-
-import re
-from mercurial.node import short
-
-REJECT_MESSAGE = """
-*************************** ERROR ***************************
-Push rejected because the following IDL interfaces were
-modified without changing the UUID:
- - %s
-
-To update the UUID for all of the above interfaces and their
-descendants, run:
- ./mach update-uuids %s
-
-If you intentionally want to keep the current UUID, include
-'IGNORE IDL' in the commit message.
-*************************************************************
-
-"""
-
-# From mozilla-central/xpcom/idl-parser/xpidl.py.
-IDL_MULTI_LINE_COMMENT_RE = re.compile(r'/\*(?s).*?\*/')
-IDL_SINGLE_LINE_COMMENT_RE = re.compile(r'(?m)//.*?$')
-IDL_UUID_PATTERN = r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
-IDL_IDENT_PATTERN = r'_?[A-Za-z][A-Za-z_0-9]*'
-
-IDL_MATCH_ATTRIBUTE_LIST_AND_CAPTURE_UUID_PATTERN = \
- r'\[[^\[]*?\buuid\s*?\(\s*?(' + IDL_UUID_PATTERN + r')\s*?\)[^\[]*?\]'
-
-IDL_MATCH_INTERFACE_BODY_AND_CAPTURE_NAME_PATTERN = \
- r'\s+?interface\s+?(' + IDL_IDENT_PATTERN + r').*?\};'
-
-ILD_RE = re.compile(
- r'(' + IDL_MATCH_ATTRIBUTE_LIST_AND_CAPTURE_UUID_PATTERN +
- IDL_MATCH_INTERFACE_BODY_AND_CAPTURE_NAME_PATTERN + r')',
- re.DOTALL | re.IGNORECASE)
-
-IDL_WHITESPACE_RE = re.compile(r'\s+')
-
-def check_unbumped_idl_interfaces(old_idl, new_idl):
- """Compares the interfaces in old_idl and new_idl and returns the names
- of the interfaces that need a UUID bump. Any non-comment change in the
- interface body is considered to require a UUID bump.
- """
- def parse(idl):
- # Strip away comments first.
- idl = IDL_MULTI_LINE_COMMENT_RE.sub('', idl)
- idl = IDL_SINGLE_LINE_COMMENT_RE.sub('', idl)
- idl = IDL_WHITESPACE_RE.sub(' ', idl)
- return dict((name, {'uuid': uuid, 'body': body})
- for body, uuid, name in ILD_RE.findall(idl))
- old_interfaces = parse(old_idl)
- new_interfaces = parse(new_idl)
- return [x for x in new_interfaces
- if (x in old_interfaces and
- new_interfaces[x]['uuid'] == old_interfaces[x]['uuid'] and
- new_interfaces[x]['body'] != old_interfaces[x]['body'])]
-
-def hook(ui, repo, hooktype, node, source=None, **kwargs):
- if source in ('pull', 'strip'):
- return 0
-
- changesets = list(repo.changelog.revs(repo[node].rev()))
- description = repo.changectx(changesets[-1]).description()
-
- # Leave uplifts alone.
- if 'a=release' in description.lower():
- return 0
-
- unbumped_interfaces = []
-
- for rev in changesets:
- ctx = repo[rev]
- if 'IGNORE IDL' in ctx.description():
- continue
-
- if len(ctx.parents()) > 1:
- # Skip merge changesets.
- continue
-
- for path in ctx.files():
- if not path.endswith('.idl'):
- continue
-
- if path not in ctx: # Deleted file
- continue
-
- fctx = ctx[path]
- if fctx.filerev() == 0: # New file
- continue
-
- prev_fctx = fctx.filectx(fctx.filerev() - 1)
- unbumped_interfaces.extend([(x, short(ctx.node())) for x in
- check_unbumped_idl_interfaces(prev_fctx.data(), fctx.data())])
-
- if unbumped_interfaces:
- names_and_revs = sorted(name + ' in changeset ' + rev
- for name, rev in unbumped_interfaces)
- names = sorted(set(name for name, rev in unbumped_interfaces))
- ui.warn(REJECT_MESSAGE % ('\n - '.join(names_and_revs),
- ' '.join(names)))
- return 1
-
- return 0
deleted file mode 100755
--- a/hghooks/mozhghooks/prevent_uuid_changes.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2012 Mozilla Foundation
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-"""
-This hook is to prevent changes to IID or UUID in pushes to trees where such changes could cause critical issues (eg: beta, release).
-"""
-
-import re
-
-from mercurial.node import short
-
-
-def hook(ui, repo, hooktype, node, source=None, **kwargs):
- if source in ('pull', 'strip'):
- return 0
-
- error = ""
- bc = False
- # Loop through each changeset being added to the repository
- for change_id in xrange(repo[node].rev(), len(repo)):
- ctx = repo[change_id]
- # Loop through each file for the current changeset
- for f in ctx.files():
- # Only Check IDL Files
- if f.endswith('.idl'):
- bc = True
- if not re.search('ba\S*=', repo.changectx('tip').description().lower()):
- error += "IDL file %s altered in changeset %s" % (
- f, short(ctx.node()))
- # Check if an error occured in any of the files that were changed
- if error != "":
- print "\n\n************************** ERROR ****************************"
- ui.warn("\n*** " + error + "***\n")
- print "\nChanges to IDL files in this repo require you to provide binary change approval in your top comment in the form of ba=... (or, more accurately, ba\\S*=...)\nThis is to ensure that UUID changes (or method changes missing corresponding UUID change) are caught early, before release.\n"
- print "*************************************************************\n\n"
- # Reject the changesets
- return 1
- else:
- if bc:
- print "You've signaled approval for the binary change(s) in your push, thanks for the extra caution."
- # Accept the changesets
- return 0
deleted file mode 100644
--- a/hghooks/tests/test-prevent-idl-change-without-uuid-bump.t
+++ /dev/null
@@ -1,568 +0,0 @@
-#require hg32+
- $ hg init server
- $ cat >> server/.hg/hgrc << EOF
- > [hooks]
- > pretxnchangegroup.prevent_idl_change_without_uuid_bump = python:mozhghooks.prevent_idl_change_without_uuid_bump.hook
- > EOF
-
-Initing repo should work.
-
- $ hg init client
- $ cd client
-
-Adding and modifying non-IDL files should work.
-
- $ cat > a.txt << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.txt'
- adding a.txt
-
- $ cat > a.txt << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > void test();
- > };
- > EOF
-
- $ hg commit -A -m 'a.txt'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
-Adding a new IDL file should work.
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- adding a.idl
-
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Modifying interface should fail.
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > void test();
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - A in changeset d37488062eb5
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids A
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
-Using 'IGNORE IDL' should work.
-
- $ hg commit --amend -m 'a.idl IGNORE IDL' >/dev/null
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Modifying interface in two separate commits should fail.
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ cat > a.idl << EOF
- > [scriptable, uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - A in changeset 6166c7b45675
- - A in changeset d275ef228c2c
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids A
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
-Using 'a=release' in tip commit should work.
-
- $ hg commit --amend -m 'a.idl a=release' >/dev/null
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
-Modifying interface should work if UUID is changed.
-
- $ cat > a.idl << EOF
- > [uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Adding a new interface should work.
-
- $ cat >> a.idl << EOF
- > [uuid(204555e7-04ad-4cc8-9f0e-840615cc43e8)]
- > interface A2 {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Modifying both interfaces file should fail.
-
- $ cat > a.idl << EOF
- > [uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
- > interface A {
- > void test();
- > };
- > [scriptable, uuid(204555e7-04ad-4cc8-9f0e-840615cc43e8)]
- > interface A2 {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - A in changeset 8fa01e4e5a1d
- - A2 in changeset 8fa01e4e5a1d
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids A A2
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
-Modifying both interfaces should fail even when one UUID is changed.
-
- $ cat > a.idl << EOF
- > [uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
- > interface A {
- > void test();
- > };
- > [scriptable, uuid(1f341018-521a-49de-b806-1bef5c9a00b0)]
- > interface A2 {
- > };
- > EOF
-
- $ hg commit --amend -A >/dev/null
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - A in changeset be234b691fe3
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids A
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
-Modifying one interface and its UUID should work.
-
- $ cat > a.idl << EOF
- > [uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
- > interface A {
- > };
- > [scriptable, uuid(1f341018-521a-49de-b806-1bef5c9a00b0)]
- > interface A2 {
- > };
- > EOF
-
- $ hg commit --amend -A >/dev/null
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Removing one interface should work.
-
- $ cat > a.idl << EOF
- > [uuid(395fe045-7d18-4adb-a3fd-af98c8a1af11)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Copying an IDL file should work.
-
- $ hg cp a.idl acopy.idl
- $ hg commit -A -m 'acopy.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Moving an IDL file should work.
-
- $ hg mv acopy.idl amove.idl
- $ hg commit -A -m 'amove.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Deleting an IDL file should work.
-
- $ hg rm a.idl
- $ hg commit -A -m 'a.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 0 changes to 0 files
-
-Adding and modifying multiple IDL files should fail if UUID is not bumped.
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ cat > b.idl << EOF
- > [uuid(1f341018-521a-49de-b806-1bef5c9a00b0)]
- > interface B {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl b.idl'
- adding a.idl
- adding b.idl
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > void test();
- > };
- > EOF
-
- $ cat > b.idl << EOF
- > [uuid(1f341018-521a-49de-b806-1bef5c9a00b0)]
- > interface B : public A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl b.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - A in changeset a1f62287c4dd
- - B in changeset a1f62287c4dd
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids A B
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
-Comments, whitespaces, and changes outside interface blocks should be ignored.
-
- $ cat > a.idl << EOF
- > /* test */[uuid(00000000-0000-0000-c000-000000000046)]
- > interface A { // foo
- > void /* bar */ test(); // baz
- > };
- > EOF
-
- $ cat > b.idl << EOF
- > interface Foo;
- > /* test
- > * test
- > */
- > [ptr] native x(x);
- > [uuid(1f341018-521a-49de-b806-1bef5c9a00b0)]
- > interface B {
- >
- > };
- > test
- > EOF
-
- $ hg commit --amend -A >/dev/null
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 3 changes to 2 files
-
-Adding and modifying an oddly formatted but still valid IDL should fail if
-UUID is not bumped.
-
- $ cat > nsISupports.idl << EOF
- > [ scriptable,
- > uuid (
- > 00000000-0000-0000-c000-000000000046
- > ), builtinclass
- > ]
- > interface nsISupports {
- > };
- > EOF
-
- $ hg commit -A -m 'nsISupports.idl'
- adding nsISupports.idl
-
- $ cat > nsISupports.idl << EOF
- > [ scriptable,
- > uuid (
- > 00000000-0000-0000-c000-000000000046
- > )
- > ]
- > interface nsISupports {
- > };
- > EOF
-
- $ hg commit -A -m 'nsISupports.idl'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
- *************************** ERROR ***************************
- Push rejected because the following IDL interfaces were
- modified without changing the UUID:
- - nsISupports in changeset 06ce567ad247
-
- To update the UUID for all of the above interfaces and their
- descendants, run:
- ./mach update-uuids nsISupports
-
- If you intentionally want to keep the current UUID, include
- 'IGNORE IDL' in the commit message.
- *************************************************************
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_idl_change_without_uuid_bump hook failed
- [255]
-
- $ hg commit --amend -m 'nsISupports.idl IGNORE IDL'
- saved backup bundle to * (glob)
-
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 1 files
-
-Merge commits should be ignored
-
- $ cat > a.idl << EOF
- > [uuid(00000000-0000-0000-c000-000000000046)]
- > interface A {
- > };
- > EOF
-
- $ hg commit -A -m 'a.idl IGNORE IDL'
- $ mergerev=`hg log --template {rev} -r .`
- $ hg up -r 'last(public())'
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-
- $ echo 'merge' > dummy
- $ hg commit -A -m 'create a head'
- adding dummy
- created new head
-
- $ hg merge $mergerev
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- (branch merge, don't forget to commit)
-
- $ hg commit -m 'merge'
- $ hg push $TESTTMP/server
- pushing to $TESTTMP/server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 3 changesets with 2 changes to 2 files
-
-Stripping should not trigger hook
-
- $ cd ..
- $ hg init striptest
- $ cd striptest
- $ cat > original.idl << EOF
- > [uuid(00000000-0000-0000-0000-000000000001)]
- > interface nsIOriginal { };
- > EOF
-
- $ hg -q commit -A -m 'initial'
- $ cat > original.idl << EOF
- > [uuid(00000000-0000-0000-0000-000000000001)]
- > interface nsIOriginal { foo; };
- > EOF
-
- $ hg commit -m 'interface change, IGNORE IDL'
- $ hg -q up -r 0
- $ cat > original.idl << EOF
- > [uuid(00000000-0000-0000-0000-000000000001)]
- > interface nsIOriginal { bar; };
- > EOF
-
- $ hg commit -m 'bad interface change'
- created new head
-
- $ cat >> .hg/hgrc << EOF
- > [extensions]
- > strip =
- >
- > [hooks]
- > pretxnchangegroup.prevent_idl_change_without_uuid_bump = python:mozhghooks.prevent_idl_change_without_uuid_bump.hook
- > EOF
-
- $ hg strip -r 1 --no-backup
- $ hg log -T '{rev} {desc}\n'
- 1 bad interface change
- 0 initial
deleted file mode 100644
--- a/hghooks/tests/test-prevent-uuid-changes.t
+++ /dev/null
@@ -1,228 +0,0 @@
- $ hg init server
- $ cat >> server/.hg/hgrc << EOF
- > [hooks]
- > pretxnchangegroup.prevent_uuid_changes = python:mozhghooks.prevent_uuid_changes.hook
- > EOF
-
- $ hg init client
- $ cd client
- $ echo "uuid(abc123)" > original.idl
- $ hg commit -A -m 'Add original.idl; ba=me'
- adding original.idl
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
- You've signaled approval for the binary change(s) in your push, thanks for the extra caution.
-
-Editing a UUID without ba= should fail
-
- $ echo "uuid(def456)" > original.idl
- $ hg commit -m 'Changing UUID'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-
- ************************** ERROR ****************************
-
- *** IDL file original.idl altered in changeset 5475ca91db3f***
-
- Changes to IDL files in this repo require you to provide binary change approval in your top comment in the form of ba=... (or, more accurately, ba\S*=...)
- This is to ensure that UUID changes (or method changes missing corresponding UUID change) are caught early, before release.
-
- *************************************************************
-
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_uuid_changes hook failed
- [255]
-
-Editing a UUID with ba= should pass
-
- $ hg -q commit --amend -m 'Changing UUID; ba=me'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
- You've signaled approval for the binary change(s) in your push, thanks for the extra caution.
-
-Editing .idl file with UUID with other files and no ba= should fail
-
- $ echo "uuid(something here)" > testfile1.idl
- $ hg commit -A -m 'adding testfile1'
- adding testfile1.idl
- $ echo "checkin2" > testfile2.txt
- $ hg commit -A -m 'testfile2'
- adding testfile2.txt
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 2 files
-
-
- ************************** ERROR ****************************
-
- *** IDL file testfile1.idl altered in changeset ddac17c4b26e***
-
- Changes to IDL files in this repo require you to provide binary change approval in your top comment in the form of ba=... (or, more accurately, ba\S*=...)
- This is to ensure that UUID changes (or method changes missing corresponding UUID change) are caught early, before release.
-
- *************************************************************
-
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_uuid_changes hook failed
- [255]
-
-Adding ba= anywhere in the push will get through the hook
-
- $ hg -q commit --amend -m 'Unrelated commit; ba=approver'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 2 changesets with 2 changes to 2 files
- You've signaled approval for the binary change(s) in your push, thanks for the extra caution.
-
-uuid( in a non-idl file shouldn't be screened by the hook
-
- $ echo "uuid(ignored)" > ignored.txt
- $ hg commit -A -m 'adding ignored.txt'
- adding ignored.txt
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-Removing uuid() from an .idl file without ba= should fail
-
- $ echo "not idl" > original.idl
- $ hg commit -m 'removing uuid'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
-
-
- ************************** ERROR ****************************
-
- *** IDL file original.idl altered in changeset 72d6c9de6844***
-
- Changes to IDL files in this repo require you to provide binary change approval in your top comment in the form of ba=... (or, more accurately, ba\S*=...)
- This is to ensure that UUID changes (or method changes missing corresponding UUID change) are caught early, before release.
-
- *************************************************************
-
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_uuid_changes hook failed
- [255]
-
-Removing UUID with ba= approval should pass
-
- $ hg -q commit --amend -m 'Removing UUID; ba=me'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 1 changes to 1 files
- You've signaled approval for the binary change(s) in your push, thanks for the extra caution.
-
-Removing an .idl with UUID without approval should fail
-
- $ echo "uuid(123)" > existing.idl
- $ hg commit -A -m 'adding existing.idl; ba=me'
- adding existing.idl
- $ hg push ../server >/dev/null
- $ hg rm existing.idl
- $ hg commit -m 'Removing existing'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 0 changes to 0 files
-
-
- ************************** ERROR ****************************
-
- *** IDL file existing.idl altered in changeset d6eafdbb87e1***
-
- Changes to IDL files in this repo require you to provide binary change approval in your top comment in the form of ba=... (or, more accurately, ba\S*=...)
- This is to ensure that UUID changes (or method changes missing corresponding UUID change) are caught early, before release.
-
- *************************************************************
-
-
- transaction abort!
- rollback completed
- abort: pretxnchangegroup.prevent_uuid_changes hook failed
- [255]
-
-Removing an .idl with UUID with approval should pass
-
- $ hg -q commit --amend -m 'Removing existing; ba=me'
- $ hg push ../server
- pushing to ../server
- searching for changes
- adding changesets
- adding manifests
- adding file changes
- added 1 changesets with 0 changes to 0 files
- You've signaled approval for the binary change(s) in your push, thanks for the extra caution.
-
- $ cd ..
-
-Stripping should not trigger hook
-
- $ hg init striptest
- $ cd striptest
- $ echo 'uuid(abc123)' > original.idl
- $ hg -q commit -A -m initial
- $ echo 'uuid(def456)' > original.idl
- $ hg commit -m 'Changing UUID; ba=me'
- $ hg -q up -r 0
- $ echo 'uuid(bad789)' > original.idl
- $ hg commit -m 'Bad UUID'
- created new head
-
- $ cat >> .hg/hgrc << EOF
- > [extensions]
- > strip =
- >
- > [hooks]
- > pretxnchangegroup.prevent_uuid_changes = python:mozhghooks.prevent_uuid_changes.hook
- > EOF
-
- $ hg strip -r 1 --no-backup
- $ hg log -T '{rev} {desc}\n'
- 1 Bad UUID
- 0 initial
--- a/hgserver/tests/test-hooks-smoketest.t
+++ b/hgserver/tests/test-hooks-smoketest.t
@@ -7,17 +7,16 @@
(recorded repository creation in replication log)
$ standarduser
Install hooks that mimic production
$ hgmo exec hgssh /set-hgrc-option mozilla-central hooks pretxnchangegroup.b_singlehead python:mozhghooks.single_head_per_branch.hook
$ hgmo exec hgssh /set-hgrc-option mozilla-central hooks pretxnchangegroup.c_commitmessage python:mozhghooks.commit-message.hook
$ hgmo exec hgssh /set-hgrc-option mozilla-central hooks pretxnchangegroup.d_webidl python:mozhghooks.prevent_webidl_changes.hook
- $ hgmo exec hgssh /set-hgrc-option mozilla-central hooks pretxnchangegroup.e_idl_no_uuid python:mozhghooks.prevent_idl_change_without_uuid_bump.hook
$ hg -q clone ${HGWEB_0_URL}mozilla-central
$ cd mozilla-central
Verify hooks are working by pushing something that should be rejected
$ touch foo
$ hg -q commit -A -m 'This is a bad commit message'