Show More
@@ -1615,13 +1615,17 b' def getdiffmeta(diff):' | |||||
1615 | def readpatch(ui, drevs, write): |
|
1615 | def readpatch(ui, drevs, write): | |
1616 | """generate plain-text patch readable by 'hg import' |
|
1616 | """generate plain-text patch readable by 'hg import' | |
1617 |
|
1617 | |||
1618 | write is usually ui.write. drevs is what "querydrev" returns, results of |
|
1618 | write takes a list of (DREV, bytes), where DREV is the differential number | |
|
1619 | (as bytes, without the "D" prefix) and the bytes are the text of a patch | |||
|
1620 | to be imported. drevs is what "querydrev" returns, results of | |||
1619 | "differential.query". |
|
1621 | "differential.query". | |
1620 | """ |
|
1622 | """ | |
1621 | # Prefetch hg:meta property for all diffs |
|
1623 | # Prefetch hg:meta property for all diffs | |
1622 | diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs)) |
|
1624 | diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs)) | |
1623 | diffs = callconduit(ui, b'differential.querydiffs', {b'ids': diffids}) |
|
1625 | diffs = callconduit(ui, b'differential.querydiffs', {b'ids': diffids}) | |
1624 |
|
1626 | |||
|
1627 | patches = [] | |||
|
1628 | ||||
1625 | # Generate patch for each drev |
|
1629 | # Generate patch for each drev | |
1626 | for drev in drevs: |
|
1630 | for drev in drevs: | |
1627 | ui.note(_(b'reading D%s\n') % drev[b'id']) |
|
1631 | ui.note(_(b'reading D%s\n') % drev[b'id']) | |
@@ -1640,7 +1644,10 b' def readpatch(ui, drevs, write):' | |||||
1640 | header += b'# %s %s\n' % (_metanamemap[k], meta[k]) |
|
1644 | header += b'# %s %s\n' % (_metanamemap[k], meta[k]) | |
1641 |
|
1645 | |||
1642 | content = b'%s%s\n%s' % (header, desc, body) |
|
1646 | content = b'%s%s\n%s' % (header, desc, body) | |
1643 | write(content) |
|
1647 | patches.append((drev[b'id'], content)) | |
|
1648 | ||||
|
1649 | # Write patches to the supplied callback | |||
|
1650 | write(patches) | |||
1644 |
|
1651 | |||
1645 |
|
1652 | |||
1646 | @vcrcommand( |
|
1653 | @vcrcommand( | |
@@ -1672,7 +1679,12 b' def phabread(ui, repo, spec, **opts):' | |||||
1672 | if opts.get(b'stack'): |
|
1679 | if opts.get(b'stack'): | |
1673 | spec = b':(%s)' % spec |
|
1680 | spec = b':(%s)' % spec | |
1674 | drevs = querydrev(repo.ui, spec) |
|
1681 | drevs = querydrev(repo.ui, spec) | |
1675 | readpatch(repo.ui, drevs, ui.write) |
|
1682 | ||
|
1683 | def _write(patches): | |||
|
1684 | for drev, content in patches: | |||
|
1685 | ui.write(content) | |||
|
1686 | ||||
|
1687 | readpatch(repo.ui, drevs, _write) | |||
1676 |
|
1688 | |||
1677 |
|
1689 | |||
1678 | @vcrcommand( |
|
1690 | @vcrcommand( |
General Comments 0
You need to be logged in to leave comments.
Login now