Mercurial > hgbook
diff en/examples/run-example @ 138:d374685eb7fa
Handle a few more common regexps. Clean up on exit nicely.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Tue, 06 Mar 2007 20:45:50 -0800 |
parents | 9d7dffe74b2c |
children | 627effec9d4e |
line wrap: on
line diff
--- a/en/examples/run-example Mon Mar 05 23:56:30 2007 -0800 +++ b/en/examples/run-example Tue Mar 06 20:45:50 2007 -0800 @@ -182,8 +182,13 @@ r'^(?:---|\+\+\+) .*', # diff header with dates r'^date:.*', # date r'^diff -r.*', # "diff -r" is followed by hash + r'^# Date \d+ \d+', # hg patch header + r'^# Node ID [0-9a-f]{40}', # hg patch header + r'^# Parent [0-9a-f]{40}', # hg patch header ] + err = False + try: try: # eat first prompt string from shell @@ -201,7 +206,7 @@ assert os.sep not in out if ofp is not None: ofp.close() - self.rename_output(ofp_basename, ignore) + err = self.rename_output(ofp_basename, ignore) if out: ofp_basename = '%s.%s' % (self.name, out) ofp = open(ofp_basename + '.tmp', 'w') @@ -234,8 +239,10 @@ else: try: ps, output = self.sendreceive('exit\n') - if ofp: + if ofp is not None: ofp.write(output) + ofp.close() + err = self.rename_output(ofp_basename, ignore) os.close(self.cfd) except IOError: pass @@ -248,7 +255,7 @@ print >> sys.stderr, '(signal %s)' % os.WTERMSIG(rc) else: open(self.name + '.run', 'w') - return rc + return rc or err finally: shutil.rmtree(tmpdir) @@ -286,6 +293,7 @@ else: print >> sys.stderr, '\nOutput of %s has changed!' % base os.system('diff -u %s %s 1>&2' % (oldname, errname)) + return True def main(path='.'): opts, args = getopt.getopt(sys.argv[1:], 'v', ['verbose'])