1607 if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'): |
1607 if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'): |
1608 meta[b'parent'] = diff[b'sourceControlBaseRevision'] |
1608 meta[b'parent'] = diff[b'sourceControlBaseRevision'] |
1609 return meta |
1609 return meta |
1610 |
1610 |
1611 |
1611 |
1612 def readpatch(repo, drevs, write): |
1612 def readpatch(ui, drevs, write): |
1613 """generate plain-text patch readable by 'hg import' |
1613 """generate plain-text patch readable by 'hg import' |
1614 |
1614 |
1615 write is usually ui.write. drevs is what "querydrev" returns, results of |
1615 write is usually ui.write. drevs is what "querydrev" returns, results of |
1616 "differential.query". |
1616 "differential.query". |
1617 """ |
1617 """ |
1618 # Prefetch hg:meta property for all diffs |
1618 # Prefetch hg:meta property for all diffs |
1619 diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs)) |
1619 diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs)) |
1620 diffs = callconduit(repo.ui, b'differential.querydiffs', {b'ids': diffids}) |
1620 diffs = callconduit(ui, b'differential.querydiffs', {b'ids': diffids}) |
1621 |
1621 |
1622 # Generate patch for each drev |
1622 # Generate patch for each drev |
1623 for drev in drevs: |
1623 for drev in drevs: |
1624 repo.ui.note(_(b'reading D%s\n') % drev[b'id']) |
1624 ui.note(_(b'reading D%s\n') % drev[b'id']) |
1625 |
1625 |
1626 diffid = max(int(v) for v in drev[b'diffs']) |
1626 diffid = max(int(v) for v in drev[b'diffs']) |
1627 body = callconduit( |
1627 body = callconduit(ui, b'differential.getrawdiff', {b'diffID': diffid}) |
1628 repo.ui, b'differential.getrawdiff', {b'diffID': diffid} |
|
1629 ) |
|
1630 desc = getdescfromdrev(drev) |
1628 desc = getdescfromdrev(drev) |
1631 header = b'# HG changeset patch\n' |
1629 header = b'# HG changeset patch\n' |
1632 |
1630 |
1633 # Try to preserve metadata from hg:meta property. Write hg patch |
1631 # Try to preserve metadata from hg:meta property. Write hg patch |
1634 # headers that can be read by the "import" command. See patchheadermap |
1632 # headers that can be read by the "import" command. See patchheadermap |
1669 """ |
1667 """ |
1670 opts = pycompat.byteskwargs(opts) |
1668 opts = pycompat.byteskwargs(opts) |
1671 if opts.get(b'stack'): |
1669 if opts.get(b'stack'): |
1672 spec = b':(%s)' % spec |
1670 spec = b':(%s)' % spec |
1673 drevs = querydrev(repo, spec) |
1671 drevs = querydrev(repo, spec) |
1674 readpatch(repo, drevs, ui.write) |
1672 readpatch(repo.ui, drevs, ui.write) |
1675 |
1673 |
1676 |
1674 |
1677 @vcrcommand( |
1675 @vcrcommand( |
1678 b'phabupdate', |
1676 b'phabupdate', |
1679 [ |
1677 [ |