Comments
Patch
@@ -1608,13 +1608,17 @@
def readpatch(repo, drevs, write):
"""generate plain-text patch readable by 'hg import'
- write is usually ui.write. drevs is what "querydrev" returns, results of
+ write takes a list of (DREV, bytes), where DREV is the differential number
+ (as bytes, without the "D" prefix) and the bytes are the text of a patch
+ to be imported. drevs is what "querydrev" returns, results of
"differential.query".
"""
# Prefetch hg:meta property for all diffs
diffids = sorted(set(max(int(v) for v in drev[b'diffs']) for drev in drevs))
diffs = callconduit(repo.ui, b'differential.querydiffs', {b'ids': diffids})
+ patches = []
+
# Generate patch for each drev
for drev in drevs:
repo.ui.note(_(b'reading D%s\n') % drev[b'id'])
@@ -1635,7 +1639,10 @@
header += b'# %s %s\n' % (_metanamemap[k], meta[k])
content = b'%s%s\n%s' % (header, desc, body)
- write(content)
+ patches.append((drev[b'id'], content))
+
+ # Write patches to the supplied callback
+ write(patches)
@vcrcommand(
@@ -1667,7 +1674,12 @@
if opts.get(b'stack'):
spec = b':(%s)' % spec
drevs = querydrev(repo, spec)
- readpatch(repo, drevs, ui.write)
+
+ def _write(patches):
+ for drev, content in patches:
+ ui.write(content)
+
+ readpatch(repo, drevs, _write)
@vcrcommand(