##// END OF EJS Templates
largefiles: respect store.createmode and avoid extra file copy...
Martin Geisler -
r16155:1b2b42e8 stable
parent child Browse files
Show More
@@ -13,7 +13,6 b' import errno'
13 import platform
13 import platform
14 import shutil
14 import shutil
15 import stat
15 import stat
16 import tempfile
17
16
18 from mercurial import dirstate, httpconnection, match as match_, util, scmutil
17 from mercurial import dirstate, httpconnection, match as match_, util, scmutil
19 from mercurial.i18n import _
18 from mercurial.i18n import _
@@ -439,13 +438,6 b' def islfilesrepo(repo):'
439 return ('largefiles' in repo.requirements and
438 return ('largefiles' in repo.requirements and
440 util.any(shortname + '/' in f[0] for f in repo.store.datafiles()))
439 util.any(shortname + '/' in f[0] for f in repo.store.datafiles()))
441
440
442 def mkstemp(repo, prefix):
443 '''Returns a file descriptor and a filename corresponding to a temporary
444 file in the repo's largefiles store.'''
445 path = repo.join(longname)
446 util.makedirs(path)
447 return tempfile.mkstemp(prefix=prefix, dir=path)
448
449 class storeprotonotcapable(Exception):
441 class storeprotonotcapable(Exception):
450 def __init__(self, storetypes):
442 def __init__(self, storetypes):
451 self.storetypes = storetypes
443 self.storetypes = storetypes
@@ -20,23 +20,22 b' def putlfile(repo, proto, sha):'
20 user cache.'''
20 user cache.'''
21 proto.redirect()
21 proto.redirect()
22
22
23 fd, tmpname = lfutil.mkstemp(repo, prefix='hg-putlfile')
23 tmpfp = util.atomictempfile(lfutil.storepath(repo, sha),
24 tmpfp = os.fdopen(fd, 'wb+')
24 createmode=repo.store.createmode)
25 try:
25 try:
26 try:
26 try:
27 proto.getfile(tmpfp)
27 proto.getfile(tmpfp)
28 tmpfp.seek(0)
28 tmpfp._fp.seek(0)
29 if sha != lfutil.hexsha1(tmpfp):
29 if sha != lfutil.hexsha1(tmpfp._fp):
30 raise IOError(0, _('largefile contents do not match hash'))
30 raise IOError(0, _('largefile contents do not match hash'))
31 tmpfp.close()
31 tmpfp.close()
32 lfutil.copytostoreabsolute(repo, tmpname, sha)
32 lfutil.linktousercache(repo, sha)
33 except IOError, e:
33 except IOError, e:
34 repo.ui.warn(_('largefiles: failed to put %s into store: %s') %
34 repo.ui.warn(_('largefiles: failed to put %s into store: %s') %
35 (sha, e.strerror))
35 (sha, e.strerror))
36 return wireproto.pushres(1)
36 return wireproto.pushres(1)
37 finally:
37 finally:
38 tmpfp.close()
38 tmpfp.discard()
39 os.unlink(tmpname)
40
39
41 return wireproto.pushres(0)
40 return wireproto.pushres(0)
42
41
@@ -103,3 +103,19 b' Test permission of with files in .hg/lar'
103 $ hg pull ../src --update -q
103 $ hg pull ../src --update -q
104 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
104 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
105 640
105 640
106
107 Test permission of files created by push:
108
109 $ hg serve -R ../src -d -p $HGPORT --pid-file hg.pid \
110 > --config "web.allow_push=*" --config web.push_ssl=no
111 $ cat hg.pid >> $DAEMON_PIDS
112
113 $ echo change >> large
114 $ hg commit -m change
115
116 $ rm -r "$USERCACHE"
117
118 $ hg push -q http://localhost:$HGPORT/
119
120 $ ../ls-l.py ../src/.hg/largefiles/b734e14a0971e370408ab9bce8d56d8485e368a9
121 640
General Comments 0
You need to be logged in to leave comments. Login now