hgmo: add config option to control and change default behavior of automationrelevant (bug 1297162); r?smacleod draft
authorGregory Szorc <gps@mozilla.com>
Mon, 07 Nov 2016 16:36:23 -0800
changeset 9851 cf12f3b01d1cd5b3032326e89e2a52a37a480d4c
parent 9850 d0b3d956b36d66ce8b1983d08fb17c9c5d1a8791
push id1350
push userbmo:gps@mozilla.com
push dateTue, 08 Nov 2016 00:36:26 +0000
reviewerssmacleod
bugs1297162
hgmo: add config option to control and change default behavior of automationrelevant (bug 1297162); r?smacleod The automationrelevant() revset determines what changesets are relevant to automation given an input changeset(s). It essentially allows automation to see what file changes should influence scheduling. At the time it was implemented, the only non-publishing repository that automation ran against was Try. Try is special in that heads on Try are often pushed on top of previous non-public heads. We want scheduling on Try to be influenced by non-public changesets from previous pushes because "unfinished" work should continue to influence scheduling. The "autoland" repository has since been introduced and it is also non-publishing. However, draft ancestors from previous pushes are effectively "finished" and not relevant to automation scheduling. The behavior of the revset to union with draft ancestors meant that scheduling on "autoland" frequently brought in file changes from dozens of draft ancestors from previous pushes that shouldn't have been influencing scheduling on this repository. This commit introduces a config option for controlling the behavior of adding draft ancestor changesets to the "automation relevant" set so both Try and "autoland" behave the way they should. We may introduce automation to more non-publishing repositories in the future. My guess is these repositories will behave more like "autoland" than Try with regards to the automation relevance of draft ancestors. Therefore, this commit changes the default behavior to *not* union with draft ancestors. This means we'll have to update a config option on the Try repository to maintain current behavior. MozReview-Commit-ID: 9O6DmUqPhF3
hgext/hgmo/__init__.py
hgext/hgmo/tests/test-automationrelevant-obsolete.t
hgext/hgmo/tests/test-automationrelevant.t
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -489,19 +489,23 @@ def revset_automationrelevant(repo, subs
     pushlog = getattr(repo, 'pushlog', None)
     if pushlog:
         push = repo.pushlog.pushfromchangeset(ctx)
         for n in push.nodes:
             pctx = repo[n]
             if pctx.rev() <= ctx.rev():
                 revs.add(pctx.rev())
 
-    # Union with non-public ancestors.
-    for rev in repo.revs('::%d & not public()', ctx.rev()):
-        revs.add(rev)
+    # Union with non-public ancestors if configured. By default, we only
+    # consider changesets from the push. However, on special repositories
+    # (namely Try), we want changesets from previous pushes to come into
+    # play too.
+    if repo.ui.configbool('hgmo', 'automationrelevantdraftancestors', False):
+        for rev in repo.revs('::%d & not public()', ctx.rev()):
+            revs.add(rev)
 
     return subset & revset.baseset(revs)
 
 
 def bmupdatefromremote(orig, ui, repo, remotemarks, path, trfunc, explicit=()):
     """Custom bookmarks applicator that overwrites with remote state.
 
     The default bookmarks merging code adds divergence. When replicating from
--- a/hgext/hgmo/tests/test-automationrelevant-obsolete.t
+++ b/hgext/hgmo/tests/test-automationrelevant-obsolete.t
@@ -65,16 +65,23 @@ Local revset evaluation against hidden c
   $ hg log -r 'automationrelevant(3208166ea109)'
   abort: hidden revision '3208166ea109'!
   (use --hidden to access hidden revisions)
   [255]
 
 Unless --hidden is used
 
   $ hg --hidden log -r 'automationrelevant(3208166ea109)'
+  changeset:   4:3208166ea109
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     file1 2
+  
+
+  $ hg --hidden --config hgmo.automationrelevantdraftancestors=true log -r 'automationrelevant(3208166ea109)'
   changeset:   3:11743f808184
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     file1 1
   
   changeset:   4:3208166ea109
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
--- a/hgext/hgmo/tests/test-automationrelevant.t
+++ b/hgext/hgmo/tests/test-automationrelevant.t
@@ -86,29 +86,41 @@ Push base to draft should still return e
   3 push 2 commit 1
   4 push 2 commit 2
   5 push 2 commit 3
 
   $ hg log -r 'automationrelevant(4)' -T '{rev} {desc}\n'
   3 push 2 commit 1
   4 push 2 commit 2
 
-Previous push head to draft should add it to relevant list
+Draft from previous push head not included unless config option changes behavior
 
   $ hg phase -f --draft -r 2
+
   $ hg log -r 'automationrelevant(5)' -T '{rev} {desc}\n'
+  3 push 2 commit 1
+  4 push 2 commit 2
+  5 push 2 commit 3
+
+  $ hg --config hgmo.automationrelevantdraftancestors=true log -r 'automationrelevant(5)' -T '{rev} {desc}\n'
   2 push 1 commit 2
   3 push 2 commit 1
   4 push 2 commit 2
   5 push 2 commit 3
 
-Previous push base to draft should add it to relevant list
+Draft from previous push base not included unless config option changes behavior
 
   $ hg phase -f --draft -r 1
+
   $ hg log -r 'automationrelevant(5)' -T '{rev} {desc}\n'
+  3 push 2 commit 1
+  4 push 2 commit 2
+  5 push 2 commit 3
+
+  $ hg --config hgmo.automationrelevantdraftancestors=true log -r 'automationrelevant(5)' -T '{rev} {desc}\n'
   1 push 1 commit 1
   2 push 1 commit 2
   3 push 2 commit 1
   4 push 2 commit 2
   5 push 2 commit 3
 
 web command for exposing automation relevance works
 
@@ -121,82 +133,16 @@ web command for exposing automation rele
       {
         "author": "test",
         "backsoutnodes": [],
         "bugs": [],
         "date": [
           0.0,
           0
         ],
-        "desc": "push 1 commit 1",
-        "extra": {
-          "branch": "default"
-        },
-        "files": [
-          "foo"
-        ],
-        "node": "0a971221ac36075c184743cba0490681eadca983",
-        "parents": [
-          "55482a6fb4b1881fa8f746fd52cf6f096bb21c89"
-        ],
-        "pushdate": [
-          \d+, (re)
-          0
-        ],
-        "pushhead": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
-        "pushid": 2,
-        "pushnodes": [
-          "0a971221ac36075c184743cba0490681eadca983",
-          "cb5c79007e91b09a4ba7ebe9210311491d09e96e"
-        ],
-        "pushuser": "testuser",
-        "rev": 1,
-        "reviewers": []
-      },
-      {
-        "author": "test",
-        "backsoutnodes": [],
-        "bugs": [],
-        "date": [
-          0.0,
-          0
-        ],
-        "desc": "push 1 commit 2",
-        "extra": {
-          "branch": "default"
-        },
-        "files": [
-          "foo"
-        ],
-        "node": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
-        "parents": [
-          "0a971221ac36075c184743cba0490681eadca983"
-        ],
-        "pushdate": [
-          \d+, (re)
-          0
-        ],
-        "pushhead": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
-        "pushid": 2,
-        "pushnodes": [
-          "0a971221ac36075c184743cba0490681eadca983",
-          "cb5c79007e91b09a4ba7ebe9210311491d09e96e"
-        ],
-        "pushuser": "testuser",
-        "rev": 2,
-        "reviewers": []
-      },
-      {
-        "author": "test",
-        "backsoutnodes": [],
-        "bugs": [],
-        "date": [
-          0.0,
-          0
-        ],
         "desc": "push 2 commit 1",
         "extra": {
           "branch": "default"
         },
         "files": [
           "foo"
         ],
         "node": "13855aae8fb3291c663ff46a8510c0e3fa673a4c",