##// END OF EJS Templates
pull: return 1 when no changes found (BC)...
pull: return 1 when no changes found (BC) Currently we have the following return codes if nothing is found: commit incoming outgoing pull push intended 1 1 1 1 1 documented 1 1 1 0 1 actual 1 1 1 0 1 This makes pull agree with the rest of the table and makes it easy to detect "nothing was pulled" in scripts.

File last commit:

r15057:774da712 default
r16039:093b75c7 stable
Show More
test-atomictempfile.py
48 lines | 1.2 KiB | text/x-python | PythonLexer
/ tests / test-atomictempfile.py
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007 import os
import glob
from mercurial.util import atomictempfile
# basic usage
def test1_simple():
if os.path.exists('foo'):
os.remove('foo')
file = atomictempfile('foo')
(dir, basename) = os.path.split(file._tempname)
assert not os.path.isfile('foo')
assert basename in glob.glob('.foo-*')
file.write('argh\n')
Greg Ward
atomictempfile: make close() consistent with other file-like objects....
r15057 file.close()
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
assert os.path.isfile('foo')
assert basename not in glob.glob('.foo-*')
print 'OK'
Greg Ward
atomictempfile: make close() consistent with other file-like objects....
r15057 # discard() removes the temp file without making the write permanent
def test2_discard():
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007 if os.path.exists('foo'):
os.remove('foo')
file = atomictempfile('foo')
(dir, basename) = os.path.split(file._tempname)
file.write('yo\n')
Greg Ward
atomictempfile: make close() consistent with other file-like objects....
r15057 file.discard()
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007
assert not os.path.isfile('foo')
assert basename not in os.listdir('.')
print 'OK'
# if a programmer screws up and passes bad args to atomictempfile, they
# get a plain ordinary TypeError, not infinite recursion
def test3_oops():
try:
file = atomictempfile()
except TypeError:
print "OK"
else:
print "expected TypeError"
if __name__ == '__main__':
test1_simple()
Greg Ward
atomictempfile: make close() consistent with other file-like objects....
r15057 test2_discard()
Greg Ward
atomictempfile: avoid infinite recursion in __del__()....
r14007 test3_oops()