sapling/tests/test-bindag-t.py
Jun Wu 330516f923 dagparser: add a binary dag serialization format
Summary:
The binary format allows us to checkin a large repo's dag and use it for
testing. The format is designed to be compat and easy for machine parsing.

`hg debugbindag` was added to generate such format from an existing repo,
and `hg debugpreviewbindag` was added to preview such binary format.

Size of serialized DAGs:

  repo     | method      | size (KB) | size (KB), zstd -19
  --------------------------------------------------------
  mozilla  | debugbindag |    101    |    66
           | debugdag    |    193    |    72
           | changelog.i | 213925    | 80118
  --------------------------------------------------------
  fbsource | debugbindag |   1400    |   700
           | debugdag    |    n/a *  |   n/a
  --------------------------------------------------------
  www      | debugbindag |    5.6    |   3.2
           | debugdag    |    n/a    |   n/a

Note:
`hg debugdag` and `hg debugbuilddag` exist, and they compress
relatively well. However, they have some (critical) issues:

- crashes on fbsource and www (*)
- complex syntax
- does not support selecting a subset of revs (ex. "::master")

Therefore I decided to invent something new.

Reviewed By: sfilipco

Differential Revision: D16294467

fbshipit-source-id: 754ab8942359ef73f5f53c427c7d38d94641fa75
2019-08-09 16:17:49 -07:00

76 lines
1020 B
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 testutil.dott import feature, sh, testtmp # noqa: F401
sh % "newrepo"
sh % "hg debugdrawdag" << r"""
J K
|/|
H I
| |
F G
|/
E
|\
A D
|\|
B C
"""
sh % "hg debugbindag -r '::A' -o a.dag"
sh % "hg debugpreviewbindag a.dag" == r"""
o 2
|\
o | 1
/
o 0"""
sh % "hg debugbindag -r '::J' -o j.dag"
sh % "hg debugpreviewbindag j.dag" == r"""
o 7
|
o 6
|
o 5
|
o 4
|\
| o 3
| |
o | 2
|\|
| o 1
|
o 0"""
sh % "hg debugbindag -r 'all()' -o all.dag"
sh % "hg debugpreviewbindag all.dag" == r"""
o 10
|\
| | o 9
| |/
o | 8
| |
| o 7
| |
o | 6
| |
| o 5
|/
o 4
|\
| o 3
| |
o | 2
|\|
| o 1
|
o 0"""