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
|
|
9 '''Store class for local filesystem.'''
|
|
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):
|
|
20 '''Because there is a system wide cache, the local store always uses that
|
|
21 cache. Since the cache is updated elsewhere, we can just read from it here
|
|
22 as if it were the store.'''
|
|
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):
|
|
29 '''Any file that is put must already be in the system wide cache so do
|
|
30 nothing.'''
|
|
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
|