hgbook
changeset 138:d374685eb7fa
Handle a few more common regexps. Clean up on exit nicely.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue Mar 06 20:45:50 2007 -0800 (2007-03-06) |
parents | 9d7dffe74b2c |
children | ceaca14e49f0 |
files | en/examples/run-example |
line diff
1.1 --- a/en/examples/run-example Mon Mar 05 23:56:30 2007 -0800 1.2 +++ b/en/examples/run-example Tue Mar 06 20:45:50 2007 -0800 1.3 @@ -182,8 +182,13 @@ 1.4 r'^(?:---|\+\+\+) .*', # diff header with dates 1.5 r'^date:.*', # date 1.6 r'^diff -r.*', # "diff -r" is followed by hash 1.7 + r'^# Date \d+ \d+', # hg patch header 1.8 + r'^# Node ID [0-9a-f]{40}', # hg patch header 1.9 + r'^# Parent [0-9a-f]{40}', # hg patch header 1.10 ] 1.11 1.12 + err = False 1.13 + 1.14 try: 1.15 try: 1.16 # eat first prompt string from shell 1.17 @@ -201,7 +206,7 @@ 1.18 assert os.sep not in out 1.19 if ofp is not None: 1.20 ofp.close() 1.21 - self.rename_output(ofp_basename, ignore) 1.22 + err = self.rename_output(ofp_basename, ignore) 1.23 if out: 1.24 ofp_basename = '%s.%s' % (self.name, out) 1.25 ofp = open(ofp_basename + '.tmp', 'w') 1.26 @@ -234,8 +239,10 @@ 1.27 else: 1.28 try: 1.29 ps, output = self.sendreceive('exit\n') 1.30 - if ofp: 1.31 + if ofp is not None: 1.32 ofp.write(output) 1.33 + ofp.close() 1.34 + err = self.rename_output(ofp_basename, ignore) 1.35 os.close(self.cfd) 1.36 except IOError: 1.37 pass 1.38 @@ -248,7 +255,7 @@ 1.39 print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc) 1.40 else: 1.41 open(self.name + '.run', 'w') 1.42 - return rc 1.43 + return rc or err 1.44 finally: 1.45 shutil.rmtree(tmpdir) 1.46 1.47 @@ -286,6 +293,7 @@ 1.48 else: 1.49 print >> sys.stderr, '\nOutput of %s has changed!' % base 1.50 os.system('diff -u %s %s 1>&2' % (oldname, errname)) 1.51 + return True 1.52 1.53 def main(path='.'): 1.54 opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])