annotate contrib/fuzz/revlog_corpus.py @ 44717:3dc6a70779f2

phabricator: add an option to fold several commits into one review (issue6244) Now that all of the pieces are in place, alter the user facing command to allow it. This is the default behavior when using `arc`, but I much prefer the 1:1 approach, and I'm tempted to mark this advanced to limit its abuse. I started out calling this `--no-stack` like the feature request suggested, but I found it less obvious (especially when writing the code), so I went with the `hg fold` analogue. This will populate the `Commits` tab in the web UI with the hash of each commit folded into the review. From experimentation, it seems to list them in the order they are received from the extension instead of the actual parent/child relationship. The extension sends them in sorted order, thanks to `templatefilters.json()`. Since there's enough info there for them to put things in the right order, JSON is unordered aside from lists (IIUC), and there doesn't seem to be any harmful side effects, I guess we write this off as their bug. It is simple enough to workaround by putting a check for `util.sortdict` into `templatefilters.json()`, and don't resort in that case. There are a handful of restrictions that are documented in the code, which somebody could probably fix if they're interested. Notably, this requires the (default) `--amend` option, because there's not an easy way to apply a local tag across several commits. This also doesn't do preflight checking to ensure that all previous commits that were part of a single review are selected when updating. That seems expensive. What happens is the excluded commit is dropped from the review, but it keeps the Differential Revision line in the commit message. Not everything can be edited, so it doesn't seem worth making the code even more complicated to handle this edge case. There are a couple of "obsolete feature not enabled but X markers found!" messages that appeared on Windows but not macOS. I have no idea what's going on here, but that's an unrelated issue, so I conditionalized those lines. Differential Revision: https://phab.mercurial-scm.org/D8314
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 08 Apr 2020 17:30:10 -0400
parents ba84a1ae4ae5
children 6000f5b25c9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43808
54a6846ba96f fuzz: remove debug prints from revlog_corpus.py
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
1 from __future__ import absolute_import
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
2
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
3 import argparse
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
4 import os
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
5 import zipfile
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
6
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
7 ap = argparse.ArgumentParser()
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
8 ap.add_argument("out", metavar="some.zip", type=str, nargs=1)
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
9 args = ap.parse_args()
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
10
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
11 reporoot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
12 # typically a standalone index
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
13 changelog = os.path.join(reporoot, '.hg', 'store', '00changelog.i')
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
14 # an inline revlog with only a few revisions
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
15 contributing = os.path.join(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
16 reporoot, '.hg', 'store', 'data', 'contrib', 'fuzz', 'mpatch.cc.i'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41014
diff changeset
17 )
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
18
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
19 with zipfile.ZipFile(args.out[0], "w", zipfile.ZIP_STORED) as zf:
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
20 if os.path.exists(changelog):
43836
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43808
diff changeset
21 with open(changelog, 'rb') as f:
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
22 zf.writestr("00changelog.i", f.read())
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
23 if os.path.exists(contributing):
43836
ba84a1ae4ae5 fuzz: fix test-fuzz-targets.t to run with python3
Kyle Lippincott <spectral@google.com>
parents: 43808
diff changeset
24 with open(contributing, 'rb') as f:
41014
c06f0ef9a5ba fuzz: new fuzzer for revlog's parse_index2 method
Augie Fackler <augie@google.com>
parents:
diff changeset
25 zf.writestr("contributing.i", f.read())