Mercurial > hg
annotate hgext/largefiles/localstore.py @ 15316:c65f5b6e26d4 stable
largefiles: rename functions and methods to match desired behavior
The original intent was that the largefiles would primarily be in the
repository, with the global cache being only that--a cache. The naming
conventions and actual intent have both strayed. In this first patch, the
naming conventions are switched to match the actual intent, as are the
configuration options.
author | Benjamin Pollack <benjamin@bitquabit.com> |
---|---|
date | Thu, 20 Oct 2011 13:24:09 -0400 |
parents | 6e809bb4f969 |
children | 41f371150ccb |
rev | line source |
---|---|
15168 | 1 # Copyright 2009-2010 Gregory P. Ward |
2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated | |
3 # Copyright 2010-2011 Fog Creek Software | |
4 # Copyright 2010-2011 Unity Technologies | |
5 # | |
6 # This software may be used and distributed according to the terms of the | |
7 # GNU General Public License version 2 or any later version. | |
8 | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
9 '''store class for local filesystem''' |
15168 | 10 |
11 import os | |
12 | |
13 from mercurial import util | |
14 from mercurial.i18n import _ | |
15 | |
16 import lfutil | |
17 import basestore | |
18 | |
19 class localstore(basestore.basestore): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
20 '''Because there is a system-wide cache, the local store always |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
21 uses that cache. Since the cache is updated elsewhere, we can |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
22 just read from it here as if it were the store.''' |
15168 | 23 |
24 def __init__(self, ui, repo, remote): | |
25 url = os.path.join(remote.path, '.hg', lfutil.longname) | |
26 super(localstore, self).__init__(ui, repo, util.expandpath(url)) | |
27 | |
28 def put(self, source, filename, hash): | |
15252
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
29 '''Any file that is put must already be in the system-wide |
6e809bb4f969
largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents:
15168
diff
changeset
|
30 cache so do nothing.''' |
15168 | 31 return |
32 | |
33 def exists(self, hash): | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15252
diff
changeset
|
34 return lfutil.inusercache(self.repo.ui, hash) |
15168 | 35 |
36 def _getfile(self, tmpfile, filename, hash): | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15252
diff
changeset
|
37 if lfutil.inusercache(self.ui, hash): |
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15252
diff
changeset
|
38 return lfutil.usercachepath(self.ui, hash) |
15168 | 39 raise basestore.StoreError(filename, hash, '', |
40 _("Can't get file locally")) | |
41 | |
42 def _verifyfile(self, cctx, cset, contents, standin, verified): | |
43 filename = lfutil.splitstandin(standin) | |
44 if not filename: | |
45 return False | |
46 fctx = cctx[standin] | |
47 key = (filename, fctx.filenode()) | |
48 if key in verified: | |
49 return False | |
50 | |
51 expecthash = fctx.data()[0:40] | |
52 verified.add(key) | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15252
diff
changeset
|
53 if not lfutil.inusercache(self.ui, expecthash): |
15168 | 54 self.ui.warn( |
55 _('changeset %s: %s missing\n' | |
56 ' (looked for hash %s)\n') | |
57 % (cset, filename, expecthash)) | |
58 return True # failed | |
59 | |
60 if contents: | |
15316
c65f5b6e26d4
largefiles: rename functions and methods to match desired behavior
Benjamin Pollack <benjamin@bitquabit.com>
parents:
15252
diff
changeset
|
61 storepath = lfutil.usercachepath(self.ui, expecthash) |
15168 | 62 actualhash = lfutil.hashfile(storepath) |
63 if actualhash != expecthash: | |
64 self.ui.warn( | |
65 _('changeset %s: %s: contents differ\n' | |
66 ' (%s:\n' | |
67 ' expected hash %s,\n' | |
68 ' but got %s)\n') | |
69 % (cset, filename, storepath, expecthash, actualhash)) | |
70 return True # failed | |
71 return False |