Mercurial > hg
changeset 15778:f15c646bffc7
author | Kevin Gessner <kevin@fogcreek.com> |
---|---|
date | Thu, 05 Jan 2012 07:26:22 -0800 |
parents | 12309c09d19a |
children | 713ee57f817b |
files | hgext/largefiles/proto.py tests/test-largefiles.t |
diffstat | 2 files changed, 29 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/proto.py Thu Jan 05 20:35:10 2012 -0600 +++ b/hgext/largefiles/proto.py Thu Jan 05 07:26:22 2012 -0800 @@ -27,12 +27,12 @@ proto.getfile(tmpfp) tmpfp.seek(0) if sha != lfutil.hexsha1(tmpfp): - return wireproto.pushres(1) + raise IOError(0, _('largefile contents do not match hash')) tmpfp.close() lfutil.copytostoreabsolute(repo, tmpname, sha) except IOError, e: - repo.ui.warn(_('largefiles: failed to put %s (%s) into store: %s') % - (sha, tmpname, e.strerror)) + repo.ui.warn(_('largefiles: failed to put %s into store: %s') % + (sha, e.strerror)) return wireproto.pushres(1) finally: tmpfp.close() @@ -81,10 +81,16 @@ # input file-like into a bundle before sending it, so we can't use # it ... if issubclass(self.__class__, httprepo.httprepository): + res = None try: - return int(self._call('putlfile', data=fd, sha=sha, - headers={'content-type':'application/mercurial-0.1'})) + res = self._call('putlfile', data=fd, sha=sha, + headers={'content-type':'application/mercurial-0.1'}) + d, output = res.split('\n', 1) + for l in output.splitlines(True): + self.ui.warn(_('remote: '), l, '\n') + return int(d) except (ValueError, urllib2.HTTPError): + self.ui.warn(_('unexpected putlfile response: %s') % res) return 1 # ... but we can't use sshrepository._call because the data= # argument won't get sent, and _callpush does exactly what we want
--- a/tests/test-largefiles.t Thu Jan 05 20:35:10 2012 -0600 +++ b/tests/test-largefiles.t Thu Jan 05 07:26:22 2012 -0800 @@ -1,5 +1,7 @@ $ "$TESTDIR/hghave" symlink unix-permissions serve || exit 80 + $ USERCACHE=`pwd`/cache; export USERCACHE + $ mkdir -p ${USERCACHE} $ cat >> $HGRCPATH <<EOF > [extensions] > largefiles= @@ -11,6 +13,7 @@ > [largefiles] > minsize=2 > patterns=glob:**.dat + > usercache=${USERCACHE} > EOF Create the repo with a couple of revisions of both large and normal @@ -824,6 +827,21 @@ [255] $ cd .. +putlfile errors are shown (issue3123) +Corrupt the cached largefile in r7 + $ echo corruption > $USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8 + $ hg init empty + $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \ + > --config 'web.allow_push=*' --config web.push_ssl=False + $ cat hg.pid >> $DAEMON_PIDS + $ hg push -R r7 http://localhost:$HGPORT1 + pushing to http://localhost:$HGPORT1/ + searching for changes + remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash + abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/ + [255] + $ rm -rf empty + Clone a local repository owned by another user We have to simulate that here by setting $HOME and removing write permissions $ ORIGHOME="$HOME"