202,203c202,205
< You're missing the M5 style hook.
< Please install the hook so we can ensure that all code fits a common style.
---
> You're missing the gem5 style hook, which automatically checks your code
> against the gem5 style rules on hg commit and qrefresh commands. This
> script will now install the hook in your .hg/hgrc file.
> Press enter to continue, or ctrl-c to abort: """
205,208c207,209
< All you'd need to do is add the following lines to your repository .hg/hgrc
< or your personal .hgrc
< ----------------
<
---
> mercurial_style_hook = """
> # The following lines were automatically added by gem5/SConstruct
> # to provide the gem5 style-checking hooks
215c216
< """ % (main.root)
---
> # End of SConstruct additions
217,222c218
< mercurial_bin_not_found = """
< Mercurial binary cannot be found, unfortunately this means that we
< cannot easily determine the version of M5 that you are running and
< this makes error messages more difficult to collect. Please consider
< installing mercurial if you choose to post an error message
< """
---
> """ % (main.root.abspath)
225,227c221,223
< Mercurial libraries cannot be found, ignoring style hook
< If you are actually a M5 developer, please fix this and
< run the style hook. It is important.
---
> Mercurial libraries cannot be found, ignoring style hook. If
> you are a gem5 developer, please fix this and run the style
> hook. It is important.
230,231c226,230
< if hgdir.exists():
< # Ensure that the style hook is in place.
---
> # Check for style hook and prompt for installation if it's not there.
> # Skip this if --ignore-style was specified, there's no .hg dir to
> # install a hook in, or there's no interactive terminal to prompt.
> if not GetOption('ignore_style') and hgdir.exists() and sys.stdin.isatty():
> style_hook = True
233,236c232,236
< ui = None
< if not GetOption('ignore_style'):
< from mercurial import ui
< ui = ui.ui()
---
> from mercurial import ui
> ui = ui.ui()
> ui.readconfig(hgdir.File('hgrc').abspath)
> style_hook = ui.config('hooks', 'pretxncommit.style', None) and \
> ui.config('hooks', 'pre-qrefresh.style', None)
240,245c240,246
< if ui is not None:
< ui.readconfig(hgdir.File('hgrc').abspath)
< style_hook = ui.config('hooks', 'pretxncommit.style', None)
<
< if not style_hook:
< print mercurial_style_message
---
> if not style_hook:
> print mercurial_style_message,
> # continue unless user does ctrl-c/ctrl-d etc.
> try:
> raw_input()
> except:
> print "Input exception, exiting scons.\n"
247,248c248,256
< else:
< print ".hg directory not found"
---
> hgrc_path = '%s/.hg/hgrc' % main.root.abspath
> print "Adding style hook to", hgrc_path, "\n"
> try:
> hgrc = open(hgrc_path, 'a')
> hgrc.write(mercurial_style_hook)
> hgrc.close()
> except:
> print "Error updating", hgrc_path
> sys.exit(1)
249a258
>