Commits

Anonymous committed b4af511

fix HGREV so it uses actual rev of working tree

Comments (0)

Files changed (1)

 try:
     # don't get confused if our sdist is unzipped in a subdir of some 
     # other hg repo
-    if os.path.isdir('./.hg'):
-        p = subprocess.Popen(['hg', 'log', '-l1', '--template={rev}'],
+    if os.path.isdir('.hg'):
+        p = subprocess.Popen(['hg', 'parents', r'--template={rev}\n'],
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         if not p.returncode:
             fh = open('HGREV', 'w')
-            fh.write(p.communicate()[0])
+            fh.write(p.communicate()[0].splitlines()[0])
             fh.close()
-except OSError:
+except (OSError, IndexError):
     pass
     
 try: