def _getHgVersion(filename):
 dirname = os.path.dirname
 if ((not os.path.exists(filename)) or (not os.path.isdir(os.path.join(dirname(filename), '.hg')))):
  return None
 try:
  (hgParentLines, err) = shellCall(['hg', 'parents', filename], stderr=True)
  changeset = hgParentLines.splitlines()[0].split()[(-1)]
 except Exception:
  changeset = ''
 try:
  (hgID, err) = shellCall(['hg', 'id', '-nibt', dirname(filename)], stderr=True)
 except Exception:
  if err:
   hgID = ''
 if (len(hgID) or len(changeset)):
  return ((hgID.strip() + ' | parent: ') + changeset.strip())
 else:
  return None

def _getHgVersion ( filename ) : dirname = os . path . dirname if ( ( not os . path . exists ( filename ) ) or ( not os . path . isdir ( os . path . join ( dirname ( filename ) , '.hg' ) ) ) ) : return None try : ( hgParentLines , err ) = shellCall ( [ 'hg' , 'parents' , filename ] , stderr = True ) changeset = hgParentLines . splitlines ( ) [ 0 ] . split ( ) [ ( - 1 ) ] except Exception : changeset = '' try : ( hgID , err ) = shellCall ( [ 'hg' , 'id' , '-nibt' , dirname ( filename ) ] , stderr = True ) except Exception : if err : hgID = '' if ( len ( hgID ) or len ( changeset ) ) : return ( ( hgID . strip ( ) + ' | parent: ' ) + changeset . strip ( ) ) else : return None
tries to discover the mercurial parent and id of a file .