Bug 1674762 - Skip non-draft changesets when automationrelevantdraftancestors is set. r=sheehan default tip @
authorMike Hommey <mh@glandium.org>
Fri, 26 Nov 2021 14:28:03 +0000
changeset 7769 669795eaa54331f0e248e71a1a83127bab6df9a0
parent 7768 9dfc6b5fda88f48189946c2c3a2d476058ee4b33
push id3884
push usercosheehan@mozilla.com
push dateFri, 26 Nov 2021 14:30:10 +0000
treeherderversion-control-tools@669795eaa543 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssheehan
bugs1674762
Bug 1674762 - Skip non-draft changesets when automationrelevantdraftancestors is set. r=sheehan Differential Revision: https://phabricator.services.mozilla.com/D132195
hgext/hgmo/__init__.py
hgext/hgmo/tests/test-automationrelevant.t
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -35,16 +35,17 @@ from mercurial import (
     bookmarks,
     commands,
     configitems,
     encoding,
     error,
     exchange,
     extensions,
     hg,
+    phases,
     pycompat,
     registrar,
     revset,
     scmutil,
     templatefilters,
     templateutil,
     util,
     wireprototypes,
@@ -523,31 +524,33 @@ def revset_automationrelevant(repo, subs
     """
     s = revset.getset(repo, revset.fullreposet(repo), x)
     if len(s) > 1:
         raise error.Abort(b'can only evaluate single changeset')
 
     ctx = repo[s.first()]
     revs = {ctx.rev()}
 
+    drafts = repo.ui.configbool(b'hgmo', b'automationrelevantdraftancestors', False)
+
     # The pushlog is used to get revisions part of the same push as
     # the requested revision.
     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():
+            if pctx.rev() <= ctx.rev() and (not drafts or pctx.phase() > phases.draft):
                 revs.add(pctx.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(b'hgmo', b'automationrelevantdraftancestors', False):
+    if drafts:
         for rev in repo.revs(b'::%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.
--- a/hgext/hgmo/tests/test-automationrelevant.t
+++ b/hgext/hgmo/tests/test-automationrelevant.t
@@ -101,16 +101,29 @@ Draft from previous push head not includ
   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
 
+Only draft changesets from current push included when automationrelevantdraftancestors set.
+
+  $ hg phase -f --public -r 3
+
+  $ 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'
+  4 push 2 commit 2
+  5 push 2 commit 3
+
 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