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
3 files
+ 80
51
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 5
50
@@ -14,12 +14,11 @@
unknown_error,
unavailable_error,
)
from ..oid import (
blob_oid,
)
from ..git import (
NULL_BLOB_OID,
EMPTY_TREE_OID,
from ..diff import (
old_new_blob_oids,
old_new_file_mode,
old_new_file_path,
parse_diff_request_cid,
)
from mercurial import (
copies,
@@ -512,14 +511,6 @@
)
def parse_diff_request_cid(cid):
"""Perform the conversions from a request commit_id to a usable revision.
"""
if cid == EMPTY_TREE_OID:
return nullhex
return pycompat.sysbytes(cid)
def parse_diff_request(servicer, request, context):
repo = servicer.load_repo(request.repository, context)
@@ -541,42 +532,6 @@
return (True, repo, ctx_from, ctx_to)
def old_new_blob_oids(header, old_ctx, new_ctx):
"""Return a tuple of (old, new) blob oids."""
old_path, new_path = old_new_file_path(header)
old_bid = new_bid = NULL_BLOB_OID
if old_path in old_ctx:
cid = pycompat.sysstr(old_ctx.hex())
old_bid = blob_oid(None, cid, old_path)
if new_path in new_ctx:
cid = pycompat.sysstr(new_ctx.hex())
new_bid = blob_oid(None, cid, new_path)
return old_bid, new_bid
def old_new_file_mode(header, old_ctx, new_ctx):
"""Return a tuple of (old, new) file mode."""
old_path, new_path = old_new_file_path(header)
old_mode, new_mode = b'0', b'0'
if old_path in old_ctx:
old_fctx = old_ctx[old_path]
old_mode = gitmode[old_fctx.flags()]
if new_path in new_ctx:
new_fctx = new_ctx[new_path]
new_mode = gitmode[new_fctx.flags()]
return old_mode, new_mode
def old_new_file_path(header):
"""Return a tuple of (old, new) file path."""
fname = header.filename()
from_path, to_path = fname, fname
if len(header.files()) > 1:
# file is copied/renamed
from_path, to_path = header.files()
return from_path, to_path
def additions_deletions(header):
adds, dels = 0, 0
for hunk in header.hunks:
Loading