D7961: lfs: add a method to the local blobstore to convert OIDs to file paths

2020-01-21 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is less ugly than passing an open callback to the `httpsendfile`
  constuctor.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7961

AFFECTED FILES
  hgext/lfs/blobstore.py

CHANGE DETAILS

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -139,6 +139,17 @@
 def open(self, oid):
 """Open a read-only file descriptor to the named blob, in either the
 usercache or the local store."""
+return open(self.path(oid), b'rb')
+
+def path(self, oid):
+"""Build the path for the given blob ``oid``.
+
+If the blob exists locally, the path may point to either the usercache
+or the local store.  If it doesn't, it will point to the local store.
+This is meant for situations where existing code that isn't LFS aware
+needs to open a blob.  Generally, prefer the ``open`` method on this
+class.
+"""
 # The usercache is the most likely place to hold the file.  Commit will
 # write to both it and the local store, as will anything that downloads
 # the blobs.  However, things like clone without an update won't
@@ -146,9 +157,9 @@
 # the usercache is the only place it _could_ be.  If not present, the
 # missing file msg here will indicate the local repo, not the 
usercache.
 if self.cachevfs.exists(oid):
-return self.cachevfs(oid, b'rb')
+return self.cachevfs.join(oid)
 
-return self.vfs(oid, b'rb')
+return self.vfs.join(oid)
 
 def download(self, oid, src, content_length):
 """Read the blob from the remote source in chunks, verify the content,



To: mharbison72, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7961: lfs: add a method to the local blobstore to convert OIDs to file paths

2020-02-05 Thread marmoute (Pierre-Yves David)
marmoute added a comment.
marmoute accepted this revision.


  looks like a clear win.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7961/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7961

To: mharbison72, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7961: lfs: add a method to the local blobstore to convert OIDs to file paths

2020-02-06 Thread mharbison72 (Matt Harbison)
Closed by commit rHG06de4a673f48: lfs: add a method to the local blobstore to 
convert OIDs to file paths (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7961?vs=19495&id=19972

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7961/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7961

AFFECTED FILES
  hgext/lfs/blobstore.py

CHANGE DETAILS

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -139,6 +139,17 @@
 def open(self, oid):
 """Open a read-only file descriptor to the named blob, in either the
 usercache or the local store."""
+return open(self.path(oid), b'rb')
+
+def path(self, oid):
+"""Build the path for the given blob ``oid``.
+
+If the blob exists locally, the path may point to either the usercache
+or the local store.  If it doesn't, it will point to the local store.
+This is meant for situations where existing code that isn't LFS aware
+needs to open a blob.  Generally, prefer the ``open`` method on this
+class.
+"""
 # The usercache is the most likely place to hold the file.  Commit will
 # write to both it and the local store, as will anything that downloads
 # the blobs.  However, things like clone without an update won't
@@ -146,9 +157,9 @@
 # the usercache is the only place it _could_ be.  If not present, the
 # missing file msg here will indicate the local repo, not the 
usercache.
 if self.cachevfs.exists(oid):
-return self.cachevfs(oid, b'rb')
+return self.cachevfs.join(oid)
 
-return self.vfs(oid, b'rb')
+return self.vfs.join(oid)
 
 def download(self, oid, src, content_length):
 """Read the blob from the remote source in chunks, verify the content,



To: mharbison72, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7961: lfs: add a method to the local blobstore to convert OIDs to file paths

2020-02-08 Thread marmoute (Pierre-Yves David)
marmoute added a comment.


  This change seems to break on python3:
  
  https://foss.heptapod.net/octobus/mercurial-devel/-/jobs/56838

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7961/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7961

To: mharbison72, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel