diff --git a/src/SConscript b/src/SConscript
--- a/src/SConscript
+++ b/src/SConscript
@@ -333,6 +333,12 @@ env.Command('base/traceflags.cc', flags,
 env.Command('base/traceflags.cc', flags, generate.traceFlagsCC)
 Source('base/traceflags.cc')
 
+# Generate hginfo.cc
+# If we pass something other than none we setup a cycle in the 
+# depndence graph that we can't get rid of so we just do os.getcwd()
+# in the hgInfo generate function
+env.Command('base/hginfo.cc', None, generate.hgInfo)
+
 # Build the zip file
 py_compiled = []
 py_zip_depends = []
@@ -365,11 +371,20 @@ envList = []
 # date.cc.
 def make_objs(sources, env):
     objs = [env.Object(s) for s in sources]
+  
     # make date.cc depend on all other objects so it always gets
     # recompiled whenever anything else does
     date_obj = env.Object('base/date.cc')
+
+    # Abuse the SCons dependence code to make the generation
+    # of hginfo.cc dependend on all the other objects and the
+    # compiling of hginfo.cc dependent on all the objects
+    # but hginfo.o not depnedent of hginfo.cc
+    hg_obj = env.Object('base/hginfo.cc')
+    env.Depends('base/hginfo.cc', objs)
     env.Depends(date_obj, objs)
-    objs.append(date_obj)
+    env.Depends(hg_obj, objs)
+    objs.extend([date_obj,hg_obj])
     return objs
 
 # Function to create a new build environment as clone of current
diff --git a/src/python/generate.py b/src/python/generate.py
--- a/src/python/generate.py
+++ b/src/python/generate.py
@@ -30,6 +30,7 @@ import imp
 import imp
 import py_compile
 import sys
+import os
 import zipfile
 
 from os.path import basename
@@ -528,3 +529,37 @@ extern const Flags *compoundFlags[];
 '''
 
         f.close()
+
+    def hgInfo(self, target, source, env):
+        try:
+            # We have to just guse os.getcwd() and can use the source parameter here
+            # because the source parameter seems to setup a dependence we can't get 
+            # rid of with Ignore() which resuts in a cycle in the dependence graph
+            scons_dir = os.getcwd()
+            import  mercurial.hg, mercurial.ui, mercurial.util, mercurial.node
+            if not exists(scons_dir) or not isdir(scons_dir) or \
+                   not exists(os.path.join(scons_dir, ".hg")):
+                raise ValueError
+            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])
+
+            hg_stats = file(str(target[0]), 'w')
+            print >>hg_stats, 'const char *hgRev = "%s:%s";' %  (rev, mercurial.node.hex(changenode))
+            print >>hg_stats, 'const char *hgDate = "%s";' % date
+            hg_stats.close()
+            mercurial.demandimport.disable()
+        except ImportError:
+            pass
+        except:
+            hg_stats = file(str(target[0]), 'w')
+            print >>hg_stats, 'const char *hgRev = "Unknown";'
+            print >>hg_stats, 'const char *hgDate = "Unknown";'
+            hg_stats.close()
+            mercurial.demandimport.disable()
+
+
+
+
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -269,6 +269,10 @@ def main():
         print "M5 compiled %s" % internal.core.cvar.compileDate;
         print "M5 started %s" % datetime.datetime.now().ctime()
         print "M5 executing on %s" % socket.gethostname()
+
+        print "M5 revision %s" % internal.core.cvar.hgRev
+        print "M5 commit date %s" % internal.core.cvar.hgDate
+
         print "command line:",
         for argv in sys.argv:
             print argv,
diff --git a/src/python/swig/core.i b/src/python/swig/core.i
--- a/src/python/swig/core.i
+++ b/src/python/swig/core.i
@@ -39,6 +39,8 @@
 #include "sim/startup.hh"
 
 extern const char *compileDate;
+extern const char *hgRev;
+extern const char *hgDate;
 %}
 
 %include "stdint.i"
@@ -51,6 +53,8 @@ void doExitCleanup();
 void doExitCleanup();
 
 char *compileDate;
+char *hgRev;
+char *hgDate;
 
 void setClockFrequency(Tick ticksPerSecond);
 
