def find_hg_tag(path):
 tags = {}
 try:
  client = subprocess.Popen(['hg', 'cat', '-r', 'tip', '.hgtags'], stdout=subprocess.PIPE, cwd=path)
  for line in client.communicate()[0].splitlines():
   line = line.strip()
   if (not line):
    continue
   (hash, tag) = line.split()
   tags[hash] = tag
 except OSError:
  return
 client = subprocess.Popen(['hg', 'parent', '--template', '#node#'], stdout=subprocess.PIPE, cwd=path)
 tip = client.communicate()[0].strip()
 tag = tags.get(tip)
 if (tag is not None):
  return tag
 return tip

def find_hg_tag ( path ) : tags = { } try : client = subprocess . Popen ( [ 'hg' , 'cat' , '-r' , 'tip' , '.hgtags' ] , stdout = subprocess . PIPE , cwd = path ) for line in client . communicate ( ) [ 0 ] . splitlines ( ) : line = line . strip ( ) if ( not line ) : continue ( hash , tag ) = line . split ( ) tags [ hash ] = tag except OSError : return client = subprocess . Popen ( [ 'hg' , 'parent' , '--template' , '#node#' ] , stdout = subprocess . PIPE , cwd = path ) tip = client . communicate ( ) [ 0 ] . strip ( ) tag = tags . get ( tip ) if ( tag is not None ) : return tag return tip
returns the current node or tag for the given path .