Return revision for a file.
761443
def get_revision_file(self, location):
        """"""

        current_rev = self.run(['info', location])

        _INI_RE = re.compile(r"^([^:]+):\s+(\S.*)$", re.M)

        info_list = _INI_RE.findall(current_rev)
        return int(dict(info_list)['Revision'])
181335
def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
    """"""

    # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
    # __file__, we can work backwards from there to the root. Some
    # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
    # case we can only use expanded keywords.

    keywords = { "refnames": git_refnames,
                 "full_revisionid": git_full_revisionid,
                 "short_revisionid": git_short_revisionid }
    ver = git_versions_from_keywords(keywords, tag_prefix, verbose)
    if ver:
        return ver

    try:
        root = os.path.abspath(__file__)
        # versionfile_source is the relative path from the top of the source
        # tree (where the .git directory might live) to this file. Invert
        # this to find the root from __file__.
# TODO(dustin): Shouldn't this always loop until it fails?
        for i in range(len(versionfile_source.split(os.sep))):
            root = os.path.dirname(root)
    except NameError:
        return default

    return (git_versions_from_vcs(tag_prefix, root, verbose)
            or versions_from_parentdir(parentdir_prefix, root, verbose)
            or default)
544652
def _get_rev(self, fpath):
        
        rev = None
        
        try:
            cmd = ["git", "log", "-n1", "--pretty=format:\"%h\"", fpath]
            rev = Popen(cmd, stdout=PIPE, stderr=PIPE).communicate()[0]
        except:
            pass
        
        if not rev:
            try:
                cmd = ["svn", "info", fpath]
                svninfo = Popen(cmd,
                                stdout=PIPE,
                                stderr=PIPE).stdout.readlines()
                for info in svninfo:
                    tokens = info.split(":")
                    if tokens[0].strip() == "Last Changed Rev":
                        rev = tokens[1].strip()
            except:
                pass
        
        return rev
759024
def _get_local_rev_and_branch(target, user, password, output_encoding=None):
    '''
    
    '''
    log.info('Checking local revision for %s', target)
    try:
        local_rev = __salt__['git.revision'](
            target,
            user=user,
            password=password,
            ignore_retcode=True,
            output_encoding=output_encoding)
    except CommandExecutionError:
        log.info('No local revision for %s', target)
        local_rev = None

    log.info('Checking local branch for %s', target)
    try:
        local_branch = __salt__['git.current_branch'](
            target,
            user=user,
            password=password,
            ignore_retcode=True,
            output_encoding=output_encoding)
    except CommandExecutionError:
        log.info('No local branch for %s', target)
        local_branch = None

    return local_rev, local_branch
1203204
def generateRevision(self):
        
        revpath = self.sourcePath()
        if not os.path.exists(revpath):
            return

        # determine the revision location
        revfile = os.path.join(revpath, self.revisionFilename())
        mode = ''
        # test for svn revision
        try:
            args = ['svn', 'info', revpath]
            proc = subprocess.Popen(args, stdout=subprocess.PIPE)
            mode = 'svn'
        except WindowsError:
            try:
                args = ['git', 'rev-parse', 'HEAD', revpath]
                proc = subprocess.Popen(args, stdout=subprocess.PIPE)
                mode = 'git'
            except WindowsError:
                return

        # process SVN revision
        rev = None

        if mode == 'svn':
            for line in proc.stdout:
                data = re.match('^Revision: (\d+)', line)
                if data:
                    rev = int(data.group(1))
                    break

        if rev is not None:
            try:
                f = open(revfile, 'w')
                f.write('__revision__ = {0}\n'.format(rev))
                f.close()
            except IOError:
                pass
1149259
def find_revision_id(self, revision=None):
        """"""
        # Make sure the local repository exists.
        self.create()
        # Try to find the revision id of the specified revision.
        revision = self.expand_branch_name(revision)
        output = self.context.capture('git', 'rev-parse', revision)
        # Validate the `git rev-parse' output.
        return self.ensure_hexadecimal_string(output, 'git rev-parse')
1309396
def get_file(self, *args, **kwargs):
        """"""
        return get_file(*args, **self._merge_overrides(**kwargs)).run()
633194
def get_repo_revision():
    '''
    
    '''
    repopath = _findrepo()
    if not repopath:
        return ''
    try:
        head = open(os.path.join(repopath, 'HEAD'), 'rU').read()
        for l in head.splitlines():
            l = l.split()
            if l[0] == 'ref:':
                ref = l[1]
                break
        else:
            ref = None
        if ref:
            rev = open(os.path.join(repopath, ref), 'rU').read()
            rev = rev[:7]
            if rev:
                return rev
    except IOError:
        pass
    try:
        rev = compat.exec_command('git', 'rev-parse', '--short', 'HEAD').strip()
        if rev:
            return rev
    except:
        pass
    return ''
573563
def stored_version(self, name):
        """"""
        link_path = self._link_path(name)
        if not _path_exists(link_path):
            return None
        return _file_version(link_path)
130950
def get_version_from_file(path):
    
    filename = os.path.join(path, VERSION_FILE)
    if not os.path.isfile(filename):
        # Look in the parent directory of path instead.
        filename = os.path.join(os.path.dirname(path), VERSION_FILE)
        if not os.path.isfile(filename):
            filename = ''

    if filename:
        with open(filename) as fh:
            version = fh.readline().strip()
            if version:
                return version
1208537
def get_revision():
    
    package_dir = os.path.dirname(__file__)
    checkout_dir = os.path.normpath(os.path.join(package_dir, '..'))
    path = os.path.join(checkout_dir, '.git')
    if os.path.exists(path):
        return _get_git_revision(path)
    return None
962071
def get_version():
    """"""
    VERSION_FILE = '../malcolm/version.py'
    mo = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]',
                   open(VERSION_FILE, 'rt').read(), re.M)
    if mo:
        return mo.group(1)
    else:
        raise RuntimeError(
            'Unable to find version string in {0}.'.format(VERSION_FILE))
1064141
def get_version(path):
    """"""

    with open(os.path.join(path, 'VERSION'), 'rb') as f:
        version = f.read().decode('ascii').strip()
    return version.strip()
633713
def get_tuids_from_revision(self, revision):
        
        result = []
        URL_TO_FILES = self.hg_url / self.config.hg.branch / 'json-info' / revision
        try:
            mozobject = http.get_json(url=URL_TO_FILES, retry=RETRY)
        except Exception as e:
            Log.warning("Unexpected error trying to get file list for revision {{revision}}", cause=e)
            return None

        files = mozobject[revision]['files']

        results = self.get_tuids(files, revision)
        return results
1090700
def get_version(filepath='src/birding/version.py'):
    """"""
    with open(get_abspath(filepath)) as version_file:
        return re.search(
            r"""__version__\s+=\s+(['"])(?P<version>.+?)\1""",
            version_file.read()).group('version')
798310
def get_file_contents(self, pointer=False):
        '''
        
        '''
        if self.pointer:
            if pointer:
                return self.old_pointed
            else:
                return self.old_data
        else:
            return self.old_data
568809
def show_revisions(context, page, content_type, lang=None):
    """"""
    if not pages_settings.PAGE_CONTENT_REVISION:
        return {'revisions': None}
    revisions = Content.objects.filter(page=page, language=lang,
                                type=content_type).order_by('-creation_date')
    if len(revisions) < 2:
        return {'revisions': None}
    return {'revisions': revisions[0:10]}