comparison tests/test-archive.t @ 29177:df6b5c6d252a

tests: test-archive.t use print_function
author timeless <timeless@mozdev.org>
date Fri, 06 May 2016 19:15:37 +0000
parents cd34bf29987e
children 0fb2fddd00a3
comparison
equal deleted inserted replaced
29176:8c8442523eef 29177:df6b5c6d252a
193 > echo "extension $ext was not autodetected." 193 > echo "extension $ext was not autodetected."
194 > fi 194 > fi
195 > done 195 > done
196 196
197 $ cat > md5comp.py <<EOF 197 $ cat > md5comp.py <<EOF
198 > from __future__ import print_function
198 > try: 199 > try:
199 > from hashlib import md5 200 > from hashlib import md5
200 > except ImportError: 201 > except ImportError:
201 > from md5 import md5 202 > from md5 import md5
202 > import sys 203 > import sys
203 > f1, f2 = sys.argv[1:3] 204 > f1, f2 = sys.argv[1:3]
204 > h1 = md5(file(f1, 'rb').read()).hexdigest() 205 > h1 = md5(file(f1, 'rb').read()).hexdigest()
205 > h2 = md5(file(f2, 'rb').read()).hexdigest() 206 > h2 = md5(file(f2, 'rb').read()).hexdigest()
206 > print h1 == h2 or "md5 differ: " + repr((h1, h2)) 207 > print(h1 == h2 or "md5 differ: " + repr((h1, h2)))
207 > EOF 208 > EOF
208 209
209 archive name is stored in the archive, so create similar archives and 210 archive name is stored in the archive, so create similar archives and
210 rename them afterwards. 211 rename them afterwards.
211 212
341 $ hg init repo 342 $ hg init repo
342 $ echo a > repo/a 343 $ echo a > repo/a
343 $ hg -R repo add repo/a 344 $ hg -R repo add repo/a
344 $ hg -R repo commit -m '#0' -d '456789012 21600' 345 $ hg -R repo commit -m '#0' -d '456789012 21600'
345 $ cat > show_mtime.py <<EOF 346 $ cat > show_mtime.py <<EOF
347 > from __future__ import print_function
346 > import sys, os 348 > import sys, os
347 > print int(os.stat(sys.argv[1]).st_mtime) 349 > print(int(os.stat(sys.argv[1]).st_mtime))
348 > EOF 350 > EOF
349 351
350 $ hg -R repo archive --prefix tar-extracted archive.tar 352 $ hg -R repo archive --prefix tar-extracted archive.tar
351 $ (TZ=UTC-3; export TZ; tar xf archive.tar) 353 $ (TZ=UTC-3; export TZ; tar xf archive.tar)
352 $ python show_mtime.py tar-extracted/a 354 $ python show_mtime.py tar-extracted/a