Mercurial > hg
annotate hgext/largefiles/localstore.py @ 15252:6e809bb4f969
largefiles: improve comments, internal docstrings
- fix some ungrammatical/unclear/incorrect comments/docstrings
- rewrite some really unclear comments/docstrings
- make formatting/style more consistent with the rest of Mercurial
(lowercase without period unless it's really multiple sentences)
- wrap to 75 columns
- always say "largefile(s)", not "lfile(s)" (or "big files")
- one space between sentences, not two
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Wed, 12 Oct 2011 20:59:27 -0400 |
parents | cfccd3bee7b3 |
children | c65f5b6e26d4 |
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): | |
34 return lfutil.insystemcache(self.repo.ui, hash) | |
35 | |
36 def _getfile(self, tmpfile, filename, hash): | |
37 if lfutil.insystemcache(self.ui, hash): | |
38 return lfutil.systemcachepath(self.ui, hash) | |
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) | |
53 if not lfutil.insystemcache(self.ui, expecthash): | |
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: | |
61 storepath = lfutil.systemcachepath(self.ui, expecthash) | |
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 |