def get_version(self, spec=None):
        # detect presence only if we need path for cwd in popen
        if spec is not None:
            if self.detect_presence():
                command = 'hg log -r %s' % sanitized(spec)
                repeated = False
                output = ''
                # we repeat the call once after pullin if necessary
                while output == '':
                    _, output, _ = run_shell_command(command,
                                                     shell=True,
                                                     cwd=self._path,
                                                     us_env=True)
                    if (output.strip() != '' and
                            not output.startswith("abort") or
                            repeated is True):

                        matches = [l for l in output.splitlines() if l.startswith('changeset: ')]
                        if len(matches) == 1:
                            return matches[0].split(':')[2]
                        else:
                            sys.stderr.write("Warning: found several candidates for hg spec %s" % spec)
                        break
                    self._do_pull()
                    repeated = True
            return None
        else:
            command = 'hg identify -i %s' % self._path
            _, output, _ = run_shell_command(command, shell=True, us_env=True)
            if output is None or output.strip() == '' or output.startswith("abort"):
                return None
            # hg adds a '+' to the end if there are uncommited
            # changes, inconsistent to hg log
            return output.strip().rstrip('+')
Get contents of file named by filename, in template package.
dataset/ETHPy150Open vcstools/vcstools/src/vcstools/hg.py/HgClient.get_version--crossover with--dataset/ETHPy150Open bkidwell/mdepub/mdepub/template/__init__.py/get_file_content