code: def run_mercurial_command(hg_command):
      hg_executable = os.environ.get("HG", "hg")
      hg_command_tuple = hg_command.split()
      hg_command_tuple.insert(0, hg_executable)
      # If you install your own mercurial version in your home
      # hg_executable does not always have execution permission.
      if not os.access(hg_executable, os.X_OK):
          hg_command_tuple.insert(0, sys.executable)
      try:
          hg_subprocess = Popen(
              hg_command_tuple, stdout=PIPE, stderr=PIPE
          )
      except OSError as e:
          print("Can't find the hg executable!", file=sys.stderr)
          print(e)
          sys.exit(1)
  
      hg_out, hg_err = hg_subprocess.communicate()
      if len(hg_err) > 0:
          raise MercurialRuntimeError(hg_err)
      return hg_out
  
imports: from __future__ import absolute_import, print_function, division
  import difflib
  import operator
  import os
  import string
  from subprocess import Popen, PIPE
  import sys
  import tabnanny
  import tokenize
  import reindent
  from six import StringIO
label_desc: Use image node_id 6 for calling a global function with example usage: run_mercurial_command(hg_command) and returns: hg_out