I'm not really concerned if it catches all the exceptions. I guess I  
would rather have it say it's unknown, instead raising an exception  
that doesn't really matter all that much.

Ali

On Jun 7, 2008, at 4:19 PM, nathan binkert wrote:

> How about this? (I didn't actually run it).  I just worry that you
> catch all exceptions.  There might be some sort of bug lurking in
> there that we want to know about.
>
> def hgInfo(self, target, source, env):
>    def gen_file(target, rev="Unknown", node="Unknown",  
> date="Unknown"):
>        hg_stats = file(target, 'w')
>        print >>hg_stats, 'const char *hgRev = "%s:%s";' %  (rev, node)
>        print >>hg_stats, 'const char *hgDate = "%s";' % date
>        hg_stats.close()
>
>    target = str(target[0])
>    scons_dir = eval(str(source[0]))
>
>    if not exists(scons_dir) or not isdir(scons_dir) or \
>           not exists(join(scons_dir, ".hg")):
>        gen_file(target)
>        return
>
>    try:
>        import mercurial
>    except ImportError:
>        gen_file(target)
>        return
>
>    import mercurial.demandimport, mercurial.hg, mercurial.ui
>    import mercurial.util, mercurial.node
>
>    repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir)
>    rev = mercurial.node.nullrev + repo.changelog.count()
>    changenode = repo.changelog.node(rev)
>    changes = repo.changelog.read(changenode)
>    date = mercurial.util.datestr(changes[2])
>    gen_file(target, rev, mercurial.node.hex(changenode), date)
>    mercurial.demandimport.disable()
> _______________________________________________
> m5-dev mailing list
> [email protected]
> http://m5sim.org/mailman/listinfo/m5-dev
>

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to