comparison contrib/perf.py @ 40557:355ae096faef

perf: add `storage` as possible source for perfrevlogwrite This source will use the stored delta.
author Boris Feld <boris.feld@octobus.net>
date Mon, 05 Nov 2018 15:24:09 +0100
parents e14d44772fb3
children 4756a33d0d31
comparison
equal deleted inserted replaced
40556:e14d44772fb3 40557:355ae096faef
1582 * `full`: add from a full text (default). 1582 * `full`: add from a full text (default).
1583 * `parent-1`: add from a delta to the first parent 1583 * `parent-1`: add from a delta to the first parent
1584 * `parent-2`: add from a delta to the second parent if it exists 1584 * `parent-2`: add from a delta to the second parent if it exists
1585 (use a delta from the first parent otherwise) 1585 (use a delta from the first parent otherwise)
1586 * `parent-smallest`: add from the smallest delta (either p1 or p2) 1586 * `parent-smallest`: add from the smallest delta (either p1 or p2)
1587 * `storage`: add from the existing precomputed deltas
1587 """ 1588 """
1588 opts = _byteskwargs(opts) 1589 opts = _byteskwargs(opts)
1589 1590
1590 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) 1591 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts)
1591 rllen = getlen(ui)(rl) 1592 rllen = getlen(ui)(rl)
1593 startrev = rllen + startrev 1594 startrev = rllen + startrev
1594 if stoprev < 0: 1595 if stoprev < 0:
1595 stoprev = rllen + stoprev 1596 stoprev = rllen + stoprev
1596 1597
1597 source = opts['source'] 1598 source = opts['source']
1598 validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest') 1599 validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest',
1600 b'storage')
1599 if source not in validsource: 1601 if source not in validsource:
1600 raise error.Abort('invalid source type: %s' % source) 1602 raise error.Abort('invalid source type: %s' % source)
1601 1603
1602 ### actually gather results 1604 ### actually gather results
1603 count = opts['count'] 1605 count = opts['count']
1717 if len(p1diff) > len(p2diff): 1719 if len(p1diff) > len(p2diff):
1718 parent = p2 1720 parent = p2
1719 diff = p2diff 1721 diff = p2diff
1720 baserev = orig.rev(parent) 1722 baserev = orig.rev(parent)
1721 cachedelta = (baserev, diff) 1723 cachedelta = (baserev, diff)
1724 elif source == b'storage':
1725 baserev = orig.deltaparent(rev)
1726 cachedelta = (baserev, orig.revdiff(orig.node(baserev), rev))
1722 1727
1723 return ((text, tr, linkrev, p1, p2), 1728 return ((text, tr, linkrev, p1, p2),
1724 {'node': node, 'flags': flags, 'cachedelta': cachedelta}) 1729 {'node': node, 'flags': flags, 'cachedelta': cachedelta})
1725 1730
1726 @contextlib.contextmanager 1731 @contextlib.contextmanager