Mercurial > public > mercurial-scm > hg
comparison hgext/lfs/blobstore.py @ 35473:02f54a1ec9eb
lfs: add note messages indicating what store holds the lfs blob
The following corruption related patches were written prior to adding the user
level cache, and it took awhile to track down why the tests changed. (It
generally made things more resilient.) But I think this will be useful to the
end user as well. I didn't make it --debug level, because there can be a ton of
info coming out of clone/push/pull --debug. The pointers are sorted for test
stability.
I opted for ui.note() instead of checking ui.verbose and then using ui.write()
for convenience, but I see most of this extension does the latter. I have no
idea what the preferred form is.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 19 Dec 2017 17:53:44 -0500 |
parents | e333d27514b0 |
children | b0c01a5ee35c |
comparison
equal
deleted
inserted
replaced
35472:c1f7037c2ded | 35473:02f54a1ec9eb |
---|---|
94 def __init__(self, repo): | 94 def __init__(self, repo): |
95 fullpath = repo.svfs.join('lfs/objects') | 95 fullpath = repo.svfs.join('lfs/objects') |
96 self.vfs = lfsvfs(fullpath) | 96 self.vfs = lfsvfs(fullpath) |
97 usercache = lfutil._usercachedir(repo.ui, 'lfs') | 97 usercache = lfutil._usercachedir(repo.ui, 'lfs') |
98 self.cachevfs = lfsvfs(usercache) | 98 self.cachevfs = lfsvfs(usercache) |
99 self.ui = repo.ui | |
99 | 100 |
100 def write(self, oid, data): | 101 def write(self, oid, data): |
101 """Write blob to local blobstore.""" | 102 """Write blob to local blobstore.""" |
102 with self.vfs(oid, 'wb', atomictemp=True) as fp: | 103 with self.vfs(oid, 'wb', atomictemp=True) as fp: |
103 fp.write(data) | 104 fp.write(data) |
104 | 105 |
105 # XXX: should we verify the content of the cache, and hardlink back to | 106 # XXX: should we verify the content of the cache, and hardlink back to |
106 # the local store on success, but truncate, write and link on failure? | 107 # the local store on success, but truncate, write and link on failure? |
107 if not self.cachevfs.exists(oid): | 108 if not self.cachevfs.exists(oid): |
109 self.ui.note(_('lfs: adding %s to the usercache\n') % oid) | |
108 lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid)) | 110 lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid)) |
109 | 111 |
110 def read(self, oid): | 112 def read(self, oid): |
111 """Read blob from local blobstore.""" | 113 """Read blob from local blobstore.""" |
112 if not self.vfs.exists(oid): | 114 if not self.vfs.exists(oid): |
113 lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid)) | 115 lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid)) |
116 self.ui.note(_('lfs: found %s in the usercache\n') % oid) | |
117 else: | |
118 self.ui.note(_('lfs: found %s in the local lfs store\n') % oid) | |
114 return self.vfs.read(oid) | 119 return self.vfs.read(oid) |
115 | 120 |
116 def has(self, oid): | 121 def has(self, oid): |
117 """Returns True if the local blobstore contains the requested blob, | 122 """Returns True if the local blobstore contains the requested blob, |
118 False otherwise.""" | 123 False otherwise.""" |