##// END OF EJS Templates
spelling: Failing
timeless@mozdev.org -
r17480:4e092da9 default
parent child Browse files
Show More
@@ -1,82 +1,82
1 1 # Copyright 2009-2010 Gregory P. Ward
2 2 # Copyright 2009-2010 Intelerad Medical Systems Incorporated
3 3 # Copyright 2010-2011 Fog Creek Software
4 4 # Copyright 2010-2011 Unity Technologies
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 9 '''store class for local filesystem'''
10 10
11 11 import os
12 12
13 13 from mercurial import util
14 14 from mercurial.i18n import _
15 15
16 16 import lfutil
17 17 import basestore
18 18
19 19 class localstore(basestore.basestore):
20 20 '''localstore first attempts to grab files out of the store in the remote
21 Mercurial repository. Failling that, it attempts to grab the files from
21 Mercurial repository. Failing that, it attempts to grab the files from
22 22 the user cache.'''
23 23
24 24 def __init__(self, ui, repo, remote):
25 25 url = os.path.join(remote.local().path, '.hg', lfutil.longname)
26 26 super(localstore, self).__init__(ui, repo, util.expandpath(url))
27 27 self.remote = remote.local()
28 28
29 29 def put(self, source, hash):
30 30 util.makedirs(os.path.dirname(lfutil.storepath(self.remote, hash)))
31 31 if lfutil.instore(self.remote, hash):
32 32 return
33 33 lfutil.link(lfutil.storepath(self.repo, hash),
34 34 lfutil.storepath(self.remote, hash))
35 35
36 36 def exists(self, hash):
37 37 return lfutil.instore(self.remote, hash)
38 38
39 39 def _getfile(self, tmpfile, filename, hash):
40 40 if lfutil.instore(self.remote, hash):
41 41 path = lfutil.storepath(self.remote, hash)
42 42 elif lfutil.inusercache(self.ui, hash):
43 43 path = lfutil.usercachepath(self.ui, hash)
44 44 else:
45 45 raise basestore.StoreError(filename, hash, '',
46 46 _("can't get file locally"))
47 47 fd = open(path, 'rb')
48 48 try:
49 49 return lfutil.copyandhash(fd, tmpfile)
50 50 finally:
51 51 fd.close()
52 52
53 53 def _verifyfile(self, cctx, cset, contents, standin, verified):
54 54 filename = lfutil.splitstandin(standin)
55 55 if not filename:
56 56 return False
57 57 fctx = cctx[standin]
58 58 key = (filename, fctx.filenode())
59 59 if key in verified:
60 60 return False
61 61
62 62 expecthash = fctx.data()[0:40]
63 63 verified.add(key)
64 64 if not lfutil.instore(self.remote, expecthash):
65 65 self.ui.warn(
66 66 _('changeset %s: %s missing\n'
67 67 ' (looked for hash %s)\n')
68 68 % (cset, filename, expecthash))
69 69 return True # failed
70 70
71 71 if contents:
72 72 storepath = lfutil.storepath(self.remote, expecthash)
73 73 actualhash = lfutil.hashfile(storepath)
74 74 if actualhash != expecthash:
75 75 self.ui.warn(
76 76 _('changeset %s: %s: contents differ\n'
77 77 ' (%s:\n'
78 78 ' expected hash %s,\n'
79 79 ' but got %s)\n')
80 80 % (cset, filename, storepath, expecthash, actualhash))
81 81 return True # failed
82 82 return False
General Comments 0
You need to be logged in to leave comments. Login now