hghooks: pin mercurial version to 4.2 in tests (bug 1454296) r?gps draft
authorbyron jones <glob@mozilla.com>
Tue, 24 Apr 2018 15:33:13 +0800
changeset 12222 6b9c6e06245e23c5d84d62a21827ecb5890a6f23
parent 12221 2531f3f69030b62a015ef43d14423293e0ece7bc
child 12223 d3a06a620e3772764feb5ea8031d8370cc6b1941
push id1918
push userbjones@mozilla.com
push dateTue, 24 Apr 2018 07:37:18 +0000
reviewersgps
bugs1454296
hghooks: pin mercurial version to 4.2 in tests (bug 1454296) r?gps pin mercurial version to 4.2 in tests, and fixes some tests. of note the ducktyping in mozhg/util to detect 4.3+ was broken. MozReview-Commit-ID: 9vG9PWPP3hi
hghooks/tests/test-advertise-upgrade.t
hghooks/tests/test-author-format.t
hghooks/tests/test-case-only-rename.t
hghooks/tests/test-changelog_correctness.t
hghooks/tests/test-commit-messages.t
hghooks/tests/test-css-image-only-changes.t
hghooks/tests/test-populate-caches.t
hghooks/tests/test-prevent-bookmarks.t
hghooks/tests/test-prevent-cross-channel-messages.t
hghooks/tests/test-prevent-ftl-changes.t
hghooks/tests/test-prevent-hgweb-changes.t
hghooks/tests/test-prevent-nspr-nss-changes.t
hghooks/tests/test-prevent-string-changes.t
hghooks/tests/test-prevent-subrepos.t
hghooks/tests/test-prevent-symlinks.t
hghooks/tests/test-prevent-try-config.t
hghooks/tests/test-prevent-vendored-changes.t
hghooks/tests/test-prevent-webidl.t
hghooks/tests/test-prevent-wptsync-changes.t
hghooks/tests/test-push_printurls.t
hghooks/tests/test-pushlog-no-extension.t
hghooks/tests/test-single-root.t
hghooks/tests/test-single_head_per_branch.t
hghooks/tests/test-treeclosure-comm-central.t
hghooks/tests/test-treeclosure.t
hghooks/tests/test-try-warning.t
pylib/mozhg/mozhg/util.py
--- a/hghooks/tests/test-advertise-upgrade.t
+++ b/hghooks/tests/test-advertise-upgrade.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
   $ hg init server
   $ configurehooks server
 
   $ hg -q clone --pull server client
   $ cd client
 
--- a/hghooks/tests/test-author-format.t
+++ b/hghooks/tests/test-author-format.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ export HGUSER='Valid User <someone@example.com>'
   $ hg init server
   $ cat > server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.author_format = python:mozhghooks.author_format.hook
   > EOF
 
   $ hg -q clone --pull server client
--- a/hghooks/tests/test-case-only-rename.t
+++ b/hghooks/tests/test-case-only-rename.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
 #require no-icasefs
 
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.prevent_case_only_names = python:mozhghooks.prevent_case_only_renames.hook
   > EOF
  
--- a/hghooks/tests/test-changelog_correctness.t
+++ b/hghooks/tests/test-changelog_correctness.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cd server
   $ cat > .hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.changelog_correctness = python:mozhghooks.changelog_correctness.hook
   > EOF
 
   $ echo foo > foo
--- a/hghooks/tests/test-commit-messages.t
+++ b/hghooks/tests/test-commit-messages.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.commit_message = python:mozhghooks.commit-message.hook
   > EOF
 
   $ hg clone server client
   updating to branch default
--- a/hghooks/tests/test-css-image-only-changes.t
+++ b/hghooks/tests/test-css-image-only-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.verify_css_image_only_approvals = python:mozhghooks.verify_css_image_only_approvals.hook
   > pretxnchangegroup.treeclosure = python:mozhghooks.treeclosure.hook
   > 
   > [extensions]
   > urlintercept = $TESTDIR/testing/url-intercept.py
--- a/hghooks/tests/test-populate-caches.t
+++ b/hghooks/tests/test-populate-caches.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [extensions]
   > blackbox =
   > [blackbox]
   > track = *
   > EOF
 
--- a/hghooks/tests/test-prevent-bookmarks.t
+++ b/hghooks/tests/test-prevent-bookmarks.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cd server
   $ cat >> .hg/hgrc << EOF
   > [hooks]
   > prepushkey.prevent_bookmarks = python:mozhghooks.prevent_bookmarks.hook
   > EOF
   $ cd ..
 
--- a/hghooks/tests/test-prevent-cross-channel-messages.t
+++ b/hghooks/tests/test-prevent-cross-channel-messages.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
 X-Channel- is allowed in normal repos
 
   $ hg init normal
   $ configurehooks normal
   $ hg -q clone normal client-normal
   $ cd client-normal
--- a/hghooks/tests/test-prevent-ftl-changes.t
+++ b/hghooks/tests/test-prevent-ftl-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
 Commit adding an FTL file without appropriate reviewer errors
 
   $ hg init normal
   $ configurehooks normal
   $ touch normal/.hg/IS_FIREFOX_REPO
   $ hg -q clone normal client-normal
--- a/hghooks/tests/test-prevent-hgweb-changes.t
+++ b/hghooks/tests/test-prevent-hgweb-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cd server
   $ echo 0 > foo
   $ hg add foo
   $ hg commit -m initial
   $ cd ..
 
   $ hg init client
--- a/hghooks/tests/test-prevent-nspr-nss-changes.t
+++ b/hghooks/tests/test-prevent-nspr-nss-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat > server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.prevent_nspr_nss = python:mozhghooks.prevent_nspr_nss_changes.hook
   > EOF
 
   $ hg -q clone server client
   $ cat >> client/.hg/hgrc << EOF
--- a/hghooks/tests/test-prevent-string-changes.t
+++ b/hghooks/tests/test-prevent-string-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.prevent_string_changes = python:mozhghooks.prevent_string_changes.hook
   > EOF
 
 Add file (tracked extension, outside expected path), should work
 
--- a/hghooks/tests/test-prevent-subrepos.t
+++ b/hghooks/tests/test-prevent-subrepos.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
 We cannot create subrepos on user repos (but a warning is printed)
 
   $ mkdir -p users/someuser
   $ hg init users/someuser/repo
   $ hg init users/someuser/repo/subrepo
   $ configurehooks users/someuser/repo
--- a/hghooks/tests/test-prevent-symlinks.t
+++ b/hghooks/tests/test-prevent-symlinks.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
 #require symlink
 
   $ . $TESTDIR/hghooks/tests/common.sh
 
 We can create symlinks on user repos
 
   $ mkdir -p users/someuser
   $ hg init users/someuser/repo
--- a/hghooks/tests/test-prevent-try-config.t
+++ b/hghooks/tests/test-prevent-try-config.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
 try_task_config.json is allowed on normal repos
 
   $ hg init normal
   $ configurehooks normal
   $ hg -q clone normal client-normal
   $ cd client-normal
--- a/hghooks/tests/test-prevent-vendored-changes.t
+++ b/hghooks/tests/test-prevent-vendored-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat > server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.prevent_vendored = python:mozhghooks.prevent_vendored_changes.hook
   > EOF
 
   $ hg -q clone server client
   $ cd client
--- a/hghooks/tests/test-prevent-webidl.t
+++ b/hghooks/tests/test-prevent-webidl.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cd server
   $ cat >> .hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.prevent_webidl = python:mozhghooks.prevent_webidl_changes.hook
   > EOF
 
   $ echo "interface Foo{};" > original.webidl
--- a/hghooks/tests/test-prevent-wptsync-changes.t
+++ b/hghooks/tests/test-prevent-wptsync-changes.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
   $ hg init integration/mozilla-inbound
   $ configurehooks integration/mozilla-inbound
   $ touch integration/mozilla-inbound/.hg/IS_FIREFOX_REPO
   $ hg -q clone integration/mozilla-inbound client
   $ cd client
   $ mkdir -p testing/web-platform/tests
   $ mkdir testing/web-platform/meta
@@ -121,17 +125,16 @@ wptsync user can push changes to testing
   added 1 changesets with 2 changes to 2 files
 
 Test pushes to try
 
   $ cd ..
   $ rm -rf client
   $ hg init try
   $ configurehooks try
-  $ touch try/.hg/IS_FIREFOX_REPO
   $ hg -q clone try client
   $ cd client
   $ mkdir -p testing/web-platform/tests
   $ mkdir testing/web-platform/meta
   $ mkdir -p taskcluster/ci
   $ mkdir other
 
 
--- a/hghooks/tests/test-push_printurls.t
+++ b/hghooks/tests/test-push_printurls.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
 
   $ mkdir integration
   $ hg init integration/mozilla-inbound
   $ configurehooks integration/mozilla-inbound
   $ cat >> integration/mozilla-inbound/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.push_printurls = python:mozhghooks.push_printurls.hook
--- a/hghooks/tests/test-pushlog-no-extension.t
+++ b/hghooks/tests/test-pushlog-no-extension.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.pushlog = python:mozhghooks.pushlog.log
   > EOF
 
   $ hg init client
   $ cd client
--- a/hghooks/tests/test-single-root.t
+++ b/hghooks/tests/test-single-root.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ . $TESTDIR/hghooks/tests/common.sh
   $ hg init server
   $ configurehooks server
 
 Pushing to an empty repository works
 
   $ hg init client
   $ cd client
--- a/hghooks/tests/test-single_head_per_branch.t
+++ b/hghooks/tests/test-single_head_per_branch.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init mozilla-central
   $ cat >> mozilla-central/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.b_singlehead = python:mozhghooks.single_head_per_branch.hook
   > EOF
 
   $ cd mozilla-central
   $ echo orig > file.txt
--- a/hghooks/tests/test-treeclosure-comm-central.t
+++ b/hghooks/tests/test-treeclosure-comm-central.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init comm-central
   $ cat >> comm-central/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.treeclosure_comm_central = python:mozhghooks.treeclosure_comm_central.hook
   > 
   > [extensions]
   > urlintercept = $TESTDIR/testing/url-intercept.py
   > 
--- a/hghooks/tests/test-treeclosure.t
+++ b/hghooks/tests/test-treeclosure.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init mozilla-central
   $ cat >> mozilla-central/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.treeclosure = python:mozhghooks.treeclosure.hook
   > 
   > [extensions]
   > urlintercept = $TESTDIR/testing/url-intercept.py
   > 
--- a/hghooks/tests/test-try-warning.t
+++ b/hghooks/tests/test-try-warning.t
@@ -1,8 +1,12 @@
+# pin to the version of mercurial running on hg.m.o
+#require hg42
+#require no-hg43
+
   $ hg init server
   $ cat >> server/.hg/hgrc << EOF
   > [hooks]
   > pretxnchangegroup.try_mandatory = python:mozhghooks.try_warning.hook
   > EOF
 
   $ hg init client
   $ cd client
--- a/pylib/mozhg/mozhg/util.py
+++ b/pylib/mozhg/mozhg/util.py
@@ -1,24 +1,18 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 from __future__ import absolute_import
 
 from mercurial import (
     error,
+    util,
 )
 
-# TRACKING hg43
-try:
-    from mercurial import configitems
-except ImportError:
-    configitems = None
-
-
 FIREFOX_ROOT_NODE = '8ba995b74e18334ab3707f27e9eb8f4e37ba3d29'
 THUNDERBIRD_ROOT_NODE = 'e4f4569d451a5e0d12a6aa33ebd916f979dd8faa'
 
 
 def is_firefox_repo(repo):
     """Determine if a repository is a Firefox repository."""
     try:
         if len(repo) and repo[0].hex() == FIREFOX_ROOT_NODE:
@@ -63,17 +57,17 @@ def identify_repo(repo):
        Path to the repository. If a hosted repo, this will be the repo path
        minus the hosting prefix. Else, this will be the repo's path.
     """
     repo_root = repo.ui.config('mozilla', 'repo_root', '/repo/hg/mozilla')
     if not repo_root.endswith('/'):
         repo_root += '/'
 
     # TRACKING hg43
-    if configitems:
+    if util.versiontuple(n=2) >= (4, 3):
         publishing = repo.ui.configbool('phases', 'publish')
     else:
         publishing = repo.ui.configbool('phases', 'publish', True)
 
     d = {
         'firefox': is_firefox_repo(repo),
         'thunderbird': is_thunderbird_repo(repo),
         'publishing': publishing,