Used to find out if the revision is in the given branch.

        :param revision: Revision to check.
        :param branch: Branch to check revision on.
        :return: True/False - Found it/Didn't find it
190133
def _check_branch(self, revision, branch):
        '''
        
        '''

        # Get a changelog
        clog_url = self.hg_url / branch / 'json-log' / revision
        try:
            Log.note("Searching through changelog {{url}}", url=clog_url)
            clog_obj = http.get_json(clog_url, retry=RETRY)
            if isinstance(clog_obj, (text_type, str)):
                Log.note(
                    "Revision {{cset}} does not exist in the {{branch}} branch",
                    cset=revision, branch=branch
                )
                return False
        except Exception as e:
            Log.note("Unexpected error getting changset-log for {{url}}: {{error}}", url=clog_url, error=e)
            return False
        return True
795398
def checkout( revision, destination, branch=nil )
     
      puts "Checking out branch in not supported for SVN" if branch
      
      if revision != :head
        raise "Checking out revisions other than head currently not supported"
      end
      
      cache_destination = location_in_cache(revision)
      
      # Try and copy into the cache first
      begin
        perform_cache_checkout_or_update(cache_destination)
        FileUtils.mkdir_p(destination)
        
        FileUtils.cp_r(cache_destination+'/.', destination)
        # Ensure the final copy is consistent
        raise CopyError if !Dir.exist?(destination)
        output = perform_update(destination)
        if !output[:status]
          raise UpdateError.new(output)
        end
        
      rescue => e
        puts "Unhandled randomness: " + e.to_s + ' - ' + e.backtrace.to_s
        # If we can't copy into the cache, copy directly to the destination
        perform_checkout(destination)
      end
      
      true
    end
1356493
def status(ctx, client, revision, no_output, path):
    """"""
    graph = Graph(client)
    # TODO filter only paths = {graph.normalize_path(p) for p in path}
    status = graph.build_status(revision=revision, can_be_cwl=no_output)

    click.echo('On branch {0}'.format(client.repo.active_branch))
    if status['outdated']:
        click.echo(
            'Files generated from newer inputs:\n'
            '  (use "renku log [<file>...]" to see the full lineage)\n'
            '  (use "renku update [<file>...]" to '
            'generate the file from its latest inputs)\n'
        )

        for filepath, stts in sorted(status['outdated'].items()):
            outdated = (
                ', '.join(
                    '{0}#{1}'.format(
                        click.style(
                            graph._format_path(n.path), fg='blue', bold=True
                        ),
                        _format_sha1(graph, n),
                    ) for n in stts
                    if n.path and n.path not in status['outdated']
                )
            )

            click.echo(
                '\t{0}: {1}'.format(
                    click.style(
                        graph._format_path(filepath), fg='red', bold=True
                    ), outdated
                )
            )

        click.echo()

    else:
        click.secho(
            'All files were generated from the latest inputs.', fg='green'
        )

    if status['multiple-versions']:
        click.echo(
            'Input files used in different versions:\n'
            '  (use "renku log --revision <sha1> <file>" to see a lineage '
            'for the given revision)\n'
        )

        for filepath, files in sorted(status['multiple-versions'].items()):
            # Do not show duplicated commits!  (see #387)
            commits = {_format_sha1(graph, key) for key in files}
            click.echo(
                '\t{0}: {1}'.format(
                    click.style(
                        graph._format_path(filepath), fg='blue', bold=True
                    ), ', '.join(commits)
                )
            )

        click.echo()

    if status['deleted']:
        click.echo(
            'Deleted files used to generate outputs:\n'
            '  (use "git show <sha1>:<file>" to see the file content '
            'for the given revision)\n'
        )

        for filepath, node in status['deleted'].items():
            click.echo(
                '\t{0}: {1}'.format(
                    click.style(
                        graph._format_path(filepath), fg='blue', bold=True
                    ), _format_sha1(graph, node)
                )
            )

        click.echo()

    ctx.exit(1 if status['outdated'] else 0)
518533
def has_commit(self):
        
        current_revision = self.history.current_revision
        revision_id = self.state.revision_id

        return current_revision.revision_id != revision_id
364539
def find_config(revision):
    """"""
    if not is_git_repo():
        return None

    cfg_path = f"{revision}:.cherry_picker.toml"
    cmd = "git", "cat-file", "-t", cfg_path

    try:
        output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        path_type = output.strip().decode("utf-8")
        return cfg_path if path_type == "blob" else None
    except subprocess.CalledProcessError:
        return None
1151509
def is_local_branch?(branch)
      branch_names = self.branches.local.map {|b| b.name}
      branch_names.include?(branch)
    end
972543
def version(self):
        
        git_rev = len(os.popen('git rev-list HEAD').readlines())
        if git_rev != 0:
            self.version_list[-1] = '%d' % git_rev
        version = '.'.join(self.version_list)
        return version
989720
def is_revision_chain_placeholder(pid):
    """"""
    return d1_gmn.app.models.ReplicaRevisionChainReference.objects.filter(
        pid__did=pid
    ).exists()
461389
def check(branch: str = 'master'):
    
    if os.environ.get('TRAVIS') == 'true':
        travis(branch)
    elif os.environ.get('SEMAPHORE') == 'true':
        semaphore(branch)
    elif os.environ.get('FRIGG') == 'true':
        frigg(branch)
    elif os.environ.get('CIRCLECI') == 'true':
        circle(branch)
    elif os.environ.get('GITLAB_CI') == 'true':
        gitlab(branch)
    elif 'BITBUCKET_BUILD_NUMBER' in os.environ:
        bitbucket(branch)
143586
def find_revision_number(self, revision=None):
        """"""
        # Make sure the local repository exists.
        self.create()
        # Try to find the revision number of the specified revision.
        revision = revision or self.default_revision
        output = self.context.capture('hg', 'id', '--rev=%s' % revision, '--num').rstrip('+')
        # Validate the `hg id --num' output.
        if not output.isdigit():
            msg = "Failed to find local revision number! ('hg id --num' gave unexpected output)"
            raise EnvironmentError(msg)
        return int(output)
569421
def revision(revision, path, branch_label, splice, head, sql, autogenerate, message):
    
    alembic_command.revision(
        config=get_config(),
        rev_id=revision,
        version_path=path,
        branch_label=branch_label,
        splice=splice,
        head=head,
        sql=sql,
        autogenerate=autogenerate,
        message=message
    )
452945
def get_revision_sha(self, dest, rev):
        
        # Pass rev to pre-filter the list.
        output = self.run_command(['show-ref', rev], cwd=dest,
                                  show_stdout=False, on_returncode='ignore')
        refs = {}
        for line in output.strip().splitlines():
            try:
                sha, ref = line.split()
            except ValueError:
                # Include the offending line to simplify troubleshooting if
                # this error ever occurs.
                raise ValueError('unexpected show-ref line: {!r}'.format(line))

            refs[ref] = sha

        branch_ref = 'refs/remotes/origin/{}'.format(rev)
        tag_ref = 'refs/tags/{}'.format(rev)

        sha = refs.get(branch_ref)
        if sha is not None:
            return (sha, True)

        sha = refs.get(tag_ref)

        return (sha, False)
126290
def merged(revision)
      # By hand, build a list of all branches known to be merged into master
      git_args = ['branch', '-a', '--merged', revision]
      all_merged = []
      @repo.git_output(git_args).lines.each do |line|
        line.strip!
        all_merged << Branch.new(@repo, line)
      end

      # Filter the contents of this collection according to the big list
      merged = []
      @branches.each do |candidate|
        # For some reason Set#include? does not play nice with our overridden comparison operators
        # for branches, so we need to do this the hard way :(
        merged << candidate if all_merged.detect { |b| candidate == b }
      end

      BranchCollection.new(@repo, merged)
    end
127378
def restore_revision(id, revision_number)
      revision_record = revision(id, revision_number)
      return revision_record.restore if revision_record
    end
717997
def _get_revision(self, revision):
        

        is_null = lambda o: len(o) == revision.count('0')

        try:
            self.revisions[0]
        except (KeyError, IndexError):
            raise EmptyRepositoryError("There are no changesets yet")

        if revision in (None, '', 'tip', 'HEAD', 'head', -1):
            return self.revisions[-1]

        is_bstr = isinstance(revision, (str, unicode))
        if ((is_bstr and revision.isdigit() and len(revision) < 12)
            or isinstance(revision, int) or is_null(revision)):
            try:
                revision = self.revisions[int(revision)]
            except Exception:
                raise ChangesetDoesNotExistError("Revision %s does not exist "
                    "for this repository" % (revision))

        elif is_bstr:
            # get by branch/tag name
            _ref_revision = self._parsed_refs.get(revision)
            if _ref_revision:  # and _ref_revision[1] in ['H', 'RH', 'T']:
                return _ref_revision[0]

            _tags_shas = self.tags.values()
            # maybe it's a tag ? we don't have them in self.revisions
            if revision in _tags_shas:
                return _tags_shas[_tags_shas.index(revision)]

            elif not SHA_PATTERN.match(revision) or revision not in self.revisions:
                raise ChangesetDoesNotExistError("Revision %s does not exist "
                    "for this repository" % (revision))

        # Ensure we return full id
        if not SHA_PATTERN.match(str(revision)):
            raise ChangesetDoesNotExistError("Given revision %s not recognized"
                % revision)
        return revision
488603
def get_changeset(self, revision=None):
        
        if isinstance(revision, GitChangeset):
            return revision
        revision = self._get_revision(revision)
        changeset = GitChangeset(repository=self, revision=revision)
        return changeset
1350312
def set_version(self, version, force=True):
        

        if version in self.versions:
            self._version = version
            if 'working' in self.repo.branch().stdout:
                if force:
                    logger.info('Found working branch. Removing...')
                    cmd = self.repo.checkout('master')
                    cmd = self.repo.branch('working', d=True)                    
                else:
                    logger.info('Found working branch from previous session. Use force=True to remove it and start anew.')
                    return

            stdout = self.repo.checkout(version, b='working').stdout  # active version set in 'working' branch
            logger.info('Version {0} set'.format(version))
        else:
            raise AttributeError('Version {0} not found'.format(version))