Skip to content
Snippets Groups Projects

repositoryService: implement GetRawChanges

Open Sushil Khanchi requested to merge topic/default/repository-GetRawChanges into branch/default
1 unresolved thread
2 files
+ 52
49
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 2
49
@@ -19,6 +19,7 @@
old_new_file_mode,
old_new_file_path,
parse_diff_request_cid,
exportsingle,
)
from mercurial import (
copies,
@@ -26,7 +27,6 @@
patch as patchmod,
pycompat,
diffutil,
cmdutil,
scmutil,
)
from ..stub.diff_pb2 import (
@@ -65,7 +65,6 @@
# TODO even though, this is bytes and not octal, would be better
# to use the constants in `hgitaly.git`
gitmode = {b'l': b'120000', b'x': b'100755', b'': b'100644'}
nullid = node.nullid
nullhex = node.nullhex
nullrev = node.nullrev
hex = node.hex
@@ -434,7 +433,7 @@
def in_chunks():
for seqno, rev in enumerate(revs):
ctx = repo[rev]
itr_data = _exportsingle(repo, ctx, fm, seqno, diffopts)
itr_data = exportsingle(repo, ctx, fm, seqno, diffopts)
for data in itr_data:
yield data
for data in concat_resplit(in_chunks(), WRITE_BUFFER_SIZE):
@@ -563,52 +562,6 @@
return b''.join(headerlines)
def _exportsingle(repo, ctx, fm, seqno, diffopts):
"""Generator method which yields a bytes stream of `ctx` export.
This method overwrite upstream mercurial's cmdutil._exportsingle(), as
the upstream version directly writes the data to stdout and concatenates
the diff chunks instead of yielding them.
ctx - a changeset context being exported
fm - formatter
seqno - sequence number of `ctx` in the revs being exported by caller
"""
node = ctx.node()
parents = [p.node() for p in ctx.parents() if p]
branch = ctx.branch()
if parents:
p1 = parents[0]
else:
p1 = nullid
textlines = []
textlines.append(b'# HG changeset patch\n')
textlines.append(b'# User %s\n' % ctx.user())
textlines.append(b'# Date %d %d\n' % ctx.date())
textlines.append(b'# %s\n' % fm.formatdate(ctx.date()))
if branch and branch != b'default':
textlines.append(b'# Branch %s\n' % branch)
textlines.append(b'# Node ID %s\n' % hex(node))
textlines.append(b'# Parent %s\n' % hex(p1))
if len(parents) > 1:
textlines.append(b'# Parent %s\n' % hex(parents[1]))
for headerid in cmdutil.extraexport:
header = cmdutil.extraexportmap[headerid](seqno, ctx)
if header is not None:
textlines.append(b'# %s\n' % header)
textlines.append(b'%s\n' % ctx.description().rstrip())
textlines.append(b'\n')
yield b''.join(textlines)
chunkiter = patchmod.diff(repo, p1, node, opts=diffopts)
for chunk in chunkiter:
yield chunk
def commit_delta_size(delta):
size = (
len(delta.from_id) + len(delta.to_id)
Loading