Bug 1679937 - Add .ftl files to HG hook for string changes, r=sheehan
Differential Revision:
https://phabricator.services.mozilla.com/D98291
--- a/hghooks/mozhghooks/prevent_string_changes.py
+++ b/hghooks/mozhghooks/prevent_string_changes.py
@@ -33,17 +33,17 @@ def hook(ui, repo, hooktype, node, sourc
if b'a=release' in repo[b'tip'].description().lower():
# Accept the entire push for code uplifts
return 0
# Loop through each changeset being added to the repository
for change_id in range(repo[node].rev(), len(repo)):
# Loop through each file for the current changeset
for file in repo[change_id].files():
# Interested only in files potentially used for l10n
- if (re.search(b'locales/en-US/', file) and file.endswith((b'.dtd', b'.ini', b'.properties'))):
+ if (re.search(b'locales/en-US/', file) and file.endswith((b'.dtd', b'.ftl', b'.ini', b'.properties'))):
changed_strings = True
if not re.search(b'l10n=', repo[b'tip'].description().lower()):
error += b"* File used for localization (%s) altered in this changeset *\n" % file
# Check if an error occurred
if error != b"":
ui.write(b"\n************************** ERROR ****************************\n\n")
ui.write(error)
ui.write(b"\nThis repository is string frozen. Please request explicit permission from\n")
--- a/hghooks/tests/test-prevent-string-changes.t
+++ b/hghooks/tests/test-prevent-string-changes.t
@@ -65,30 +65,31 @@ Remove file (untracked extension, inside
$ 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
-Add file (tracked extension, inside expected path), wrong commit message, should fail
+Add DTD files (tracked extension, inside expected path), wrong commit message, should fail
$ mkdir -p browser/locales/en-US
$ echo "DTD file #1" >> browser/locales/en-US/test.dtd
$ echo "DTD file #2" >> browser/locales/en-US/test2.dtd
$ hg commit -A -m "Commit .dtd files inside l10n path, a=l10n"
adding browser/locales/en-US/test.dtd
adding browser/locales/en-US/test2.dtd
$ hg push ../server
pushing to ../server
searching for changes
adding changesets
adding manifests
adding file changes
+ added 1 changesets with 2 changes to 2 files
************************** ERROR ****************************
* File used for localization (browser/locales/en-US/test.dtd) altered in this changeset *
* File used for localization (browser/locales/en-US/test2.dtd) altered in this changeset *
This repository is string frozen. Please request explicit permission from
release managers to break string freeze in your bug.
@@ -105,42 +106,84 @@ Amend commit message to use correct keyw
$ hg -q commit --amend -m "Commit .dtd files inside l10n path, l10n=foo"
$ hg push ../server
pushing to ../server
searching for changes
adding changesets
adding manifests
adding file changes
+ added 1 changesets with 2 changes to 2 files
You've signaled approval for changes to strings in your push, thanks.
- added 1 changesets with 2 changes to 2 files
+
+Add Fluent file (tracked extension, inside expected path), wrong commit message, should fail
+
+ $ mkdir -p browser/locales/en-US
+ $ echo "FTL file" >> browser/locales/en-US/test.ftl
+ $ hg commit -A -m "Commit .ftl files inside l10n path, a=l10n"
+ adding browser/locales/en-US/test.ftl
+ $ 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 ****************************
+
+ * File used for localization (browser/locales/en-US/test.ftl) altered in this changeset *
+
+ This repository is string frozen. Please request explicit permission from
+ release managers to break string freeze in your bug.
+ If you have that explicit permission, denote that by including in
+ your commit message l10n=...
+ *************************************************************
+
+ transaction abort!
+ rollback completed
+ abort: pretxnchangegroup.prevent_string_changes hook failed
+ [255]
+
+Amend commit message to use correct keyword, should work
+
+ $ hg -q commit --amend -m "Commit .ftl files inside l10n path, l10n=foo"
+ $ 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 changes to strings in your push, thanks.
Edit existing file and commit with correct keyword, should work
$ echo "Updated DTD content" >> browser/locales/en-US/test.dtd
$ hg commit -A -m "Update .dtd file inside l10n path, l10n=foo"
$ 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 changes to strings in your push, thanks.
- added 1 changesets with 1 changes to 1 files
Delete a file and commit without the correct keyword, should fail
$ hg rm browser/locales/en-US/test.dtd
$ hg commit -A -m "Remove .dtd file inside l10n path"
$ 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 ****************************
* File used for localization (browser/locales/en-US/test.dtd) altered in this changeset *
This repository is string frozen. Please request explicit permission from
release managers to break string freeze in your bug.
If you have that explicit permission, denote that by including in
@@ -154,18 +197,18 @@ Delete a file and commit without the cor
$ hg -q commit --amend -m "Remove .dtd file inside l10n path, l10n=foo"
$ 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 changes to strings in your push, thanks.
- added 1 changesets with 0 changes to 0 files
Edit a file (tracked extension, inside expected path), as part of code uplift, should work
$ echo "DTD file #1" >> browser/locales/en-US/test.dtd
$ hg commit -A -m 'Change DTD file on trunk, no need of approval'
adding browser/locales/en-US/test.dtd
$ echo "uplift1" > dummy
$ hg commit -A -m 'Doing code upload; a=release'
@@ -185,16 +228,17 @@ Same edit of a tracked file after releas
$ echo "DTD file #1" >> browser/locales/en-US/test.dtd
$ hg commit -m 'Change DTD file'
$ 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 ****************************
* File used for localization (browser/locales/en-US/test.dtd) altered in this changeset *
This repository is string frozen. Please request explicit permission from
release managers to break string freeze in your bug.
If you have that explicit permission, denote that by including in
@@ -212,18 +256,18 @@ Message check should be case insensitive
$ echo "DTD file #1" >> browser/locales/en-US/test.dtd
$ hg commit -m 'Change DTD file, l10N='
$ hg push ../server
pushing to ../server
searching for changes
adding changesets
adding manifests
adding file changes
+ added 3 changesets with 3 changes to 2 files
You've signaled approval for changes to strings in your push, thanks.
- added 3 changesets with 3 changes to 2 files
$ cd ..
Hook should not run when stripping
$ hg init striptest
$ cd striptest
$ echo initial > foo