Skip to content
Snippets Groups Projects
Commit 47e737d2 authored by Matt Harbison's avatar Matt Harbison
Browse files

lfs: factor out a method for extracting the pointer of a single file

This will be useful for filesets, among other things, instead of traversing the
whole context.
parent 2912bed9
No related branches found
No related tags found
No related merge requests found
......@@ -307,7 +307,21 @@
pointers[p.oid()] = p
return sorted(pointers.values())
def pointerfromctx(ctx, f):
"""return a pointer for the named file from the given changectx, or None if
the file isn't LFS."""
if f not in ctx:
return None
fctx = ctx[f]
if not _islfs(fctx.filelog(), fctx.filenode()):
return None
try:
return pointer.deserialize(fctx.rawdata())
except pointer.InvalidPointer as ex:
raise error.Abort(_('lfs: corrupted pointer (%s@%s): %s\n')
% (f, short(ctx.node()), ex))
def pointersfromctx(ctx):
"""return a dict {path: pointer} for given single changectx"""
result = {}
for f in ctx.files():
......@@ -310,17 +324,10 @@
def pointersfromctx(ctx):
"""return a dict {path: pointer} for given single changectx"""
result = {}
for f in ctx.files():
if f not in ctx:
continue
fctx = ctx[f]
if not _islfs(fctx.filelog(), fctx.filenode()):
continue
try:
result[f] = pointer.deserialize(fctx.rawdata())
except pointer.InvalidPointer as ex:
raise error.Abort(_('lfs: corrupted pointer (%s@%s): %s\n')
% (f, short(ctx.node()), ex))
p = pointerfromctx(ctx, f)
if p:
result[f] = p
return result
def uploadblobs(repo, pointers):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment