tests/test-contrib-check-commit.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Tue, 09 Apr 2024 02:54:19 +0200
changeset 51586 1cef1412af3e
parent 43112 24a07347aa60
permissions -rw-r--r--
phases: rework the logic of _pushdiscoveryphase to bound complexity This rework the various graph traversal in _pushdiscoveryphase to keep the complexity in check. This is done though a couple of things: - first, limiting the space we have to explore, for example, if we are not in publishing push, we don't need to consider remote draft roots that are also draft locally, as there is nothing to be moved there. - avoid unbounded descendant computation, and use the faster "rev between" computation. This provide a massive boost to performance when exchanging with repository with a massive amount of draft, like mozilla-try: ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # benchmark.name = hg.command.push # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.reuse-external-delta-parent = default ## benchmark.variants.revs = any-1-extra-rev before: 20.346590 seconds after: 11.232059 seconds (-38.15%, -7.48 seconds) ## benchmark.variants.revs = any-100-extra-rev before: 24.752051 seconds after: 15.367412 seconds (-37.91%, -9.38 seconds) After this changes, the push operation is still quite too slow. Some of this can be attributed to general phases slowness (reading all the roots from disk for example) and other know slowness (not using persistent-nodemap, branchmap, tags, etc. We are also working on them, but with this series, phase discovery during push no longer showing up in profile and this is a pretty nice and bit low-hanging fruit out of the way. ### (same case as the above) # benchmark.variants.revs = any-1-extra-rev pre-%ln-change: 44.235070 this-changeset: 11.232059 seconds (-74.61%, -33.00 seconds) # benchmark.variants.revs = any-100-extra-rev pre-%ln-change: 49.234697 this-changeset: 15.367412 seconds (-68.79%, -33.87 seconds) Note that with this change, the `hg push` performance is now much closer to the `hg pull` performance, even it still lagging behind a bit. (and the overall performance are still too slow). ### data-env-vars.name = mozilla-try-2023-03-22-ds2-pnm # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default # bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 6.517450 hg.command.push: 11.219888 ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 10.160991 hg.command.push: 14.251107 ### data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog # bin-env-vars.hg.py-re2-module = default # benchmark.variants.explicit-rev = all-out-heads # benchmark.variants.issue6528 = disabled # benchmark.variants.protocol = ssh # benchmark.variants.pulled-delta-reuse-policy = default ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.577772 hg.command.push: 11.232059 ## bin-env-vars.hg.flavor = default ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.152976 hg.command.push: 15.367412 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-1-extra-rev hg.command.pull: 8.731982 hg.command.push: 11.178751 ## bin-env-vars.hg.flavor = rust ## benchmark.variants.revs = any-100-extra-rev hg.command.pull: 13.184236 hg.command.push: 15.620843

Test the 'check-commit' script
==============================

A fine patch:

  $ cat > patch-with-long-header.diff << EOF
  > # HG changeset patch
  > # User timeless <timeless@mozdev.org>
  > # Date 1448911706 0
  > #      Mon Nov 30 19:28:26 2015 +0000
  > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
  > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
  > # ClownJoke This is a veryly long header that should not be warned about because its not the description
  > bundle2: use Oxford comma (issue123) (BC)
  > 
  > diff --git a/hgext/transplant.py b/hgext/transplant.py
  > --- a/hgext/transplant.py
  > +++ b/hgext/transplant.py
  > @@ -599,7 +599,7 @@
  >              return
  >          if not (opts.get('source') or revs or
  >                  opts.get('merge') or opts.get('branch')):
  > -            raise error.Abort(_('no source URL, branch revision or revision '
  > +            raise error.Abort(_('no source URL, branch revision, or revision '
  >                                 'list provided'))
  >          if opts.get('all'):
  > 
  > + def blahblah(x):
  > +     pass
  > EOF
  $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit

This would normally be against the rules, but it's okay because that's
what tagging and signing looks like:

  $ cat > creates-a-tag.diff << EOF
  > # HG changeset patch
  > # User Augie Fackler <raf@durin42.com>
  > # Date 1484787778 18000
  > #      Wed Jan 18 20:02:58 2017 -0500
  > # Branch stable
  > # Node ID c177635e4acf52923bc3aa9f72a5b1ad1197b173
  > # Parent  a1dd2c0c479e0550040542e392e87bc91262517e
  > Added tag 4.1-rc for changeset a1dd2c0c479e
  > 
  > diff --git a/.hgtags b/.hgtags
  > --- a/.hgtags
  > +++ b/.hgtags
  > @@ -150,3 +150,4 @@ 438173c415874f6ac653efc1099dec9c9150e90f
  >  eab27446995210c334c3d06f1a659e3b9b5da769 4.0
  >  b3b1ae98f6a0e14c1e1ba806a6c18e193b6dae5c 4.0.1
  >  e69874dc1f4e142746ff3df91e678a09c6fc208c 4.0.2
  > +a1dd2c0c479e0550040542e392e87bc91262517e 4.1-rc
  > EOF
  $ $TESTDIR/../contrib/check-commit < creates-a-tag.diff

A patch with lots of errors:

  $ cat > patch-with-long-header.diff << EOF
  > # HG changeset patch
  > # User timeless
  > # Date 1448911706 0
  > #      Mon Nov 30 19:28:26 2015 +0000
  > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
  > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
  > # ClownJoke This is a veryly long header that should not be warned about because its not the description
  > transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  > 
  > diff --git a/hgext/transplant.py b/hgext/transplant.py
  > --- a/hgext/transplant.py
  > +++ b/hgext/transplant.py
  > @@ -599,7 +599,7 @@
  >              return
  >          if not (opts.get('source') or revs or
  >                  opts.get('merge') or opts.get('branch')):
  > -            raise error.Abort(_('no source URL, branch revision or revision '
  > +            raise error.Abort(_('no source URL, branch revision, or revision '
  >                                 'list provided'))
  >          if opts.get('all'):
  > EOF
  $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
  1: username is not an email address
   # User timeless
  7: summary keyword should be most user-relevant one-word command or topic
   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  7: (BC) needs to be uppercase
   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  7: use (issueDDDD) instead of bug
   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  7: no space allowed between issue and number
   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  7: summary line too long (limit is 78)
   transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
  [1]

A patch with other errors:

  $ cat > patch-with-long-header.diff << EOF
  > # HG changeset patch
  > # User timeless
  > # Date 1448911706 0
  > #      Mon Nov 30 19:28:26 2015 +0000
  > # Node ID c41cb6d2b7dbd62b1033727f8606b8c09fc4aa88
  > # Parent  42aa0e570eaa364a622bc4443b0bcb79b1100a58
  > # ClownJoke This is a veryly long header that should not be warned about because its not the description
  > This has no topic and ends with a period.
  > 
  > diff --git a/hgext/transplant.py b/hgext/transplant.py
  > --- a/hgext/transplant.py
  > +++ b/hgext/transplant.py
  > @@ -599,7 +599,7 @@
  >          if opts.get('all'):
  >  
  > 
  > +
  > + some = otherjunk
  > +
  > +
  > + def blah_blah(x):
  > +     pass
  > +
  >  
  > EOF
  $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
  1: username is not an email address
   # User timeless
  7: don't capitalize summary lines
   This has no topic and ends with a period.
  7: summary line doesn't start with 'topic: '
   This has no topic and ends with a period.
  7: don't add trailing period on summary line
   This has no topic and ends with a period.
  [1]