equal
deleted
inserted
replaced
1581 Possible source values are: |
1581 Possible source values are: |
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 """ |
1587 """ |
1587 opts = _byteskwargs(opts) |
1588 opts = _byteskwargs(opts) |
1588 |
1589 |
1589 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) |
1590 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) |
1590 rllen = getlen(ui)(rl) |
1591 rllen = getlen(ui)(rl) |
1592 startrev = rllen + startrev |
1593 startrev = rllen + startrev |
1593 if stoprev < 0: |
1594 if stoprev < 0: |
1594 stoprev = rllen + stoprev |
1595 stoprev = rllen + stoprev |
1595 |
1596 |
1596 source = opts['source'] |
1597 source = opts['source'] |
1597 validsource = (b'full', b'parent-1', b'parent-2') |
1598 validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest') |
1598 if source not in validsource: |
1599 if source not in validsource: |
1599 raise error.Abort('invalid source type: %s' % source) |
1600 raise error.Abort('invalid source type: %s' % source) |
1600 |
1601 |
1601 ### actually gather results |
1602 ### actually gather results |
1602 count = opts['count'] |
1603 count = opts['count'] |
1705 parent = p2 |
1706 parent = p2 |
1706 if p2 == nullid: |
1707 if p2 == nullid: |
1707 parent = p1 |
1708 parent = p1 |
1708 baserev = orig.rev(parent) |
1709 baserev = orig.rev(parent) |
1709 cachedelta = (baserev, orig.revdiff(parent, rev)) |
1710 cachedelta = (baserev, orig.revdiff(parent, rev)) |
|
1711 elif source == b'parent-smallest': |
|
1712 p1diff = orig.revdiff(p1, rev) |
|
1713 parent = p1 |
|
1714 diff = p1diff |
|
1715 if p2 != nullid: |
|
1716 p2diff = orig.revdiff(p2, rev) |
|
1717 if len(p1diff) > len(p2diff): |
|
1718 parent = p2 |
|
1719 diff = p2diff |
|
1720 baserev = orig.rev(parent) |
|
1721 cachedelta = (baserev, diff) |
1710 |
1722 |
1711 return ((text, tr, linkrev, p1, p2), |
1723 return ((text, tr, linkrev, p1, p2), |
1712 {'node': node, 'flags': flags, 'cachedelta': cachedelta}) |
1724 {'node': node, 'flags': flags, 'cachedelta': cachedelta}) |
1713 |
1725 |
1714 @contextlib.contextmanager |
1726 @contextlib.contextmanager |