Proper check to see if zip dest needs to be wrapped in tellable
From hgweb, calling archival.zipit fails with the error message
"Illegal seek". This happens because sys.stdout.tell() throws an
exception:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mercurial/archival.py", line 99, in addfile
self.z.writestr(i, data)
File "/usr/lib/python2.4/zipfile.py", line 468, in writestr
zinfo.header_offset = self.fp.tell() # Start of header bytes
Checking whether hasattr(dest, 'tell') is insufficient, because
sys.stdout has a tell() method; you just can't call it.
This patch instead determines whether a fileobj is tellable by trying
to tell(), wrapping the fileobj if an exception is generated.
precommit hook: p1=0000000000000000000000000000000000000000 p2=
pretxncommit hook: n=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p1=0000000000000000000000000000000000000000 p2=
0:29b62aeb769f
commit hook: n=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p1=0000000000000000000000000000000000000000 p2=
commit hook b
precommit hook: p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
pretxncommit hook: n=b702efe9688826e3a91283852b328b84dbf37bc2 p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
1:b702efe96888
commit hook: n=b702efe9688826e3a91283852b328b84dbf37bc2 p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
commit hook b
precommit hook: p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
pretxncommit hook: n=1324a5531bac09b329c3845d35ae6a7526874edb p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
2:1324a5531bac
commit hook: n=1324a5531bac09b329c3845d35ae6a7526874edb p1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b p2=
commit hook b
precommit hook: p1=1324a5531bac09b329c3845d35ae6a7526874edb p2=b702efe9688826e3a91283852b328b84dbf37bc2
pretxncommit hook: n=4c52fb2e402287dd5dc052090682536c8406c321 p1=1324a5531bac09b329c3845d35ae6a7526874edb p2=b702efe9688826e3a91283852b328b84dbf37bc2
3:4c52fb2e4022
commit hook: n=4c52fb2e402287dd5dc052090682536c8406c321 p1=1324a5531bac09b329c3845d35ae6a7526874edb p2=b702efe9688826e3a91283852b328b84dbf37bc2
commit hook b
prechangegroup hook
changegroup hook: n=b702efe9688826e3a91283852b328b84dbf37bc2
incoming hook: n=b702efe9688826e3a91283852b328b84dbf37bc2
incoming hook: n=1324a5531bac09b329c3845d35ae6a7526874edb
incoming hook: n=4c52fb2e402287dd5dc052090682536c8406c321
pulling from ../a
searching for changes
adding changesets
adding manifests
adding file changes
added 3 changesets with 2 changes to 2 files
(run 'hg update' to get a working copy)
pretag hook: t=a n=4c52fb2e402287dd5dc052090682536c8406c321 l=0
precommit hook: p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
pretxncommit hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
4:4f92e785b90a
commit hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p1=4c52fb2e402287dd5dc052090682536c8406c321 p2=
commit hook b
tag hook: t=a n=4c52fb2e402287dd5dc052090682536c8406c321 l=0
pretag hook: t=la n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
tag hook: t=la n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
pretag hook: t=fa n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=0
pretag.forbid hook
abort: pretag.forbid hook exited with status 1
pretag hook: t=fla n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 l=1
pretag.forbid hook
abort: pretag.forbid hook exited with status 1
4:4f92e785b90a
precommit hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
pretxncommit hook: n=7792358308a2026661cea44f9d47c072813004cb p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
5:7792358308a2
pretxncommit.forbid hook: tip=5:7792358308a2
abort: pretxncommit.forbid hook exited with status 1
transaction abort!
rollback completed
4:4f92e785b90a
precommit hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
precommit.forbid hook
abort: precommit.forbid hook exited with status 1
4:4f92e785b90a
3:4c52fb2e4022
prechangegroup.forbid hook
pulling from ../a
searching for changes
abort: prechangegroup.forbid hook exited with status 1
pretxnchangegroup.forbid hook: tip=4:4f92e785b90a
pulling from ../a
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
abort: pretxnchangegroup.forbid hook exited with status 1
transaction abort!
rollback completed
3:4c52fb2e4022
preoutgoing hook: s=pull
outgoing hook: n=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 s=pull
pulling from ../a
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
rolling back last transaction
preoutgoing hook: s=pull
preoutgoing.forbid hook
pulling from ../a
searching for changes
abort: preoutgoing.forbid hook exited with status 1
# test python hooks
error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
error: preoutgoing.raise hook raised an exception: exception from hook
pulling from ../a
searching for changes
error: preoutgoing.abort hook failed: raise abort from hook
abort: raise abort from hook
pulling from ../a
searching for changes
hook args:
hooktype preoutgoing
source pull
abort: preoutgoing.fail hook failed
pulling from ../a
searching for changes
abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
pulling from ../a
searching for changes
abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
pulling from ../a
searching for changes
abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
pulling from ../a
searching for changes
abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
pulling from ../a
searching for changes
abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
pulling from ../a
searching for changes
hook args:
hooktype preoutgoing
source pull
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)
# make sure --traceback works
Traceback (most recent call last):