GET /projects/{projectName}/repos/{repoName}/revision/{revision}

<p>Normalizes the revision into an absolute revision.
335210
@Get("/projects/{projectName}/repos/{repoName}/revision/{revision}")
    @RequiresReadPermission
    public Map<String, Integer> normalizeRevision(Repository repository, @Param("revision") String revision) {
        final Revision normalizedRevision = repository.normalizeNow(new Revision(revision));
        return ImmutableMap.of("revision", normalizedRevision.major());
    }
699835
def rev(self, rev):
        """"""
        d = self.dict
        d['revision'] = rev
        return self.from_dict(d)
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')
1178312
@Post("/projects/{projectName}/repos/{repoName}/preview")
    public CompletableFuture<Iterable<ChangeDto<?>>> preview(
            @Param("revision") @Default("-1") String revision,
            Repository repository,
            @RequestConverter(ChangesRequestConverter.class) Iterable<Change<?>> changes) {

        final CompletableFuture<Map<String, Change<?>>> changesFuture =
                repository.previewDiff(new Revision(revision), changes);

        return changesFuture.thenApply(previewDiffs -> previewDiffs.values().stream()
                                                                   .map(DtoConverter::convert)
                                                                   .collect(toImmutableList()));
    }
75577
def get_revision(cls, id, revision, api=None):
        
        api = api if api else cls._API
        extra = {'resource': cls.__name__, 'query': {
            'id': id,
            'revision': revision
        }}
        logger.info('Get revision', extra=extra)
        app = api.get(url=cls._URL['get_revision'].format(
            id=id, revision=revision)).json()
        return App(api=api, **app)
551742
def get_revision(self, location):
        
        # Note: taken from setuptools.command.egg_info
        revision = 0

        for base, dirs, files in os.walk(location):
            if self.dirname not in dirs:
                dirs[:] = []
                continue    # no sense walking uncontrolled subdirs
            dirs.remove(self.dirname)
            entries_fn = os.path.join(base, self.dirname, 'entries')
            if not os.path.exists(entries_fn):
                ## FIXME: should we warn?
                continue
            f = open(entries_fn)
            data = f.read()
            f.close()

            if data.startswith('8') or data.startswith('9') or data.startswith('10'):
                data = list(map(str.splitlines, data.split('\n\x0c\n')))
                del data[0][0]  # get rid of the '8'
                dirurl = data[0][3]
                revs = [int(d[9]) for d in data if len(d)>9 and d[9]]+[0]
                if revs:
                    localrev = max(revs)
                else:
                    localrev = 0
            elif data.startswith('<?xml'):
                dirurl = _svn_xml_url_re.search(data).group(1)    # get repository URL
                revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)]+[0]
                if revs:
                    localrev = max(revs)
                else:
                    localrev = 0
            else:
                logger.warn("Unrecognized .svn/entries format; skipping %s", base)
                dirs[:] = []
                continue
            if base == location:
                base_url = dirurl+'/'   # save the root url
            elif not dirurl.startswith(base_url):
                dirs[:] = []
                continue    # not part of the same svn tree, skip it
            revision = max(revision, localrev)
        return revision
1176421
def get_version(svn=False, limit=3):
    ""
    v = '.'.join([str(i) for i in VERSION[:limit]])
    if svn and limit >= 3:
        from django.utils.version import get_svn_revision
        import os
        svn_rev = get_svn_revision(os.path.dirname(__file__))
        if svn_rev:
            v = '%s.%s' % (v, svn_rev)
    return v
398578
def location_in_cache( revision = nil )
      begin
        elements = [cache, repo_type, split_url, revision].flatten.compact.collect { |i| i.to_s } 
        File.join( elements )
      rescue => e
        raise CacheCalculationError.new(e.msg + e.backtrace.to_s)
      end
    end
298011
@Patch("/metadata/{projectName}/repos/{repoName}/perm/tokens/{appId}")
    @Consumes("application/json-patch+json")
    public CompletableFuture<Revision> updateSpecificTokenPermission(@Param("projectName") String projectName,
                                                                     @Param("repoName") String repoName,
                                                                     @Param("appId") String appId,
                                                                     JsonPatch jsonPatch,
                                                                     Author author) {
        final ReplaceOperation operation = ensureSingleReplaceOperation(jsonPatch, "/permissions");
        final Collection<Permission> permissions = Jackson.convertValue(operation.value(), permissionsTypeRef);
        return mds.findTokenByAppId(appId)
                  .thenCompose(token -> mds.updatePerTokenPermission(
                          author, projectName, repoName, appId, permissions));
    }
548538
def versions(self, rev=None, index=None):
        """"""
        raise NotImplementedError
        _revisions = [line.split()[0] for line in self.log.split('\n') if line]
        _versions = [Version(self.obj.repo.commit(r)) for r in _revisions if rev is None or r.startswith(rev)]
        if index is not None and len(_versions) > index:
            _versions = _versions[index]
        return _versions
147340
def _evaluate(self):
        """"""
        if not self.__retrieved:
            self._elements = self._retrieve_revisions()
            self.__retrieved = True

        return super(RevisionCursor, self)._evaluate()
240311
private void merge(Versioning versioning, ArtifactRepository from, List<VersionInfo> found) {
        if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
            found.add(new VersionInfo(versioning.getRelease(),from));

        if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
            found.add(new VersionInfo(versioning.getLatest(),from));

        for ( String v : versioning.getVersions() )
            found.add(new VersionInfo(v,from));
    }

    VersionInfo findLatest(List<VersionInfo> infos) {
        Collections.sort(infos);
        if (infos.isEmpty())    return null;
        return infos.get(infos.size()-1);
    }

    private static class VersionInfo implements Comparable<VersionInfo> {
        final VersionNumber version;
        final ArtifactRepository repository;

        public VersionInfo(String version, ArtifactRepository repository) {
            this.version = new VersionNumber(version);
            this.repository = repository;
        }

        public int compareTo(VersionInfo that) {
            return this.version.compareTo(that.version);
        }
    }
    
    private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                     ArtifactRepository repository, VersionResult result )
    {
        Versioning versioning = null;

        FileInputStream fis = null;
        try
        {
            if ( metadata != null )
            {
                SyncContext syncContext = syncContextFactory.newInstance( session, true );

                try
                {
                    syncContext.acquire( null, Collections.singleton( metadata ) );

                    if ( metadata.getFile() != null && metadata.getFile().exists() )
                    {
                        fis = new FileInputStream( metadata.getFile() );
                        org.apache.maven.artifact.repository.metadata.Metadata m =
                            new MetadataXpp3Reader().read( fis, false );
                        versioning = m.getVersioning();

                        /*
                         * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
                         * of the local repository. This is especially troublesome during snapshot resolution so we try
                         * to handle that gracefully.
                         */
                        if ( versioning != null && repository instanceof LocalRepository)
                        {
                            if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
                            {
                                Versioning repaired = new Versioning();
                                repaired.setLastUpdated( versioning.getLastUpdated() );
                                Snapshot snapshot = new Snapshot();
                                snapshot.setLocalCopy( true );
                                repaired.setSnapshot( snapshot );
                                versioning = repaired;

                                throw new IOException( "Snapshot information corrupted with remote repository data"
                                    + ", please verify that no remote repository uses the id '" + repository.getId()
                                    + "'" );
                            }
                        }
                    }
                }
                finally
                {
                    syncContext.release();
                }
            }
        }
        catch ( Exception e )
        {
            invalidMetadata( session, trace, metadata, repository, e );
            result.addException( e );
        }
        finally
        {
            IOUtil.close(fis);
        }

        return ( versioning != null ) ? versioning : new Versioning();
    }

    private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                  ArtifactRepository repository, Exception exception )
    {
        RepositoryListener listener = session.getRepositoryListener();
        if ( listener != null )
        {
            DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace );
            event.setMetadata( metadata );
            event.setException( exception );
            event.setRepository( repository );
            listener.metadataInvalid( event );
        }
    }

    private static final String MAVEN_METADATA_XML = "maven-metadata.xml";

    private static final String LATEST = "LATEST";

    private static final String SNAPSHOT = "SNAPSHOT";
}
992910
def revision(directory=None, message=None, autogenerate=False, sql=False,
             head='head', splice=False, branch_label=None, version_path=None,
             rev_id=None):
    """"""
    config = current_app.extensions['migrate'].migrate.get_config(directory)
    if alembic_version >= (0, 7, 0):
        command.revision(config, message, autogenerate=autogenerate, sql=sql,
                         head=head, splice=splice, branch_label=branch_label,
                         version_path=version_path, rev_id=rev_id)
    else:
        command.revision(config, message, autogenerate=autogenerate, sql=sql)
1126715
def get_version(version_tuple):
    """"""
    if version_tuple[3] == FINAL and version_tuple[4] != 0:
        raise Exception(
            'Project version number misconfigured:\n'
            '   version may not be final and have segment number.')

    if version_tuple[3] not in (DEV, FINAL) and version_tuple[4] == 0:
        raise Exception(
            'Project version number misconfigured:\n'
            '   version must have segment number.')

    if version_tuple[3] == DEV:
        segment_num = get_git_changeset()
    else:
        segment_num = str(abs(version_tuple[4]))

    # X.X.X
    sem_ver = ".".join([
        str(abs(int(number)))
        for number in version_tuple[:3]
    ])

    if version_tuple[3] != FINAL:
        if version_tuple[3] in (ALPHA, BETA, RC):
            sem_ver = "%s%s%s" % (sem_ver, version_tuple[3], segment_num)
        elif version_tuple[3] in (DEV, POST):
            sem_ver = "%s%s%s%s" % (
                sem_ver, SEPARATOR, version_tuple[3], segment_num)
        else:
            raise Exception(
                'Project version number misconfigured:\n'
                '   Unrecognized release type')

    return sem_ver
481181
private CompletableFuture<Revision> removePermissionAtPointer(Author author, String projectName,
                                                                  JsonPointer path, String commitSummary) {
        final Change<JsonNode> change = Change.ofJsonPatch(METADATA_JSON,
                                                           new RemoveOperation(path).toJsonNode());
        return metadataRepo.push(projectName, Project.REPO_DOGMA, author, commitSummary, change);
    }
661551
public static MavenArtifactUrlReference.VersionResolver asInProject() {
        return new MavenArtifactUrlReference.VersionResolver() {

            @Override
            public String getVersion(final String groupId, final String artifactId) {
                return getArtifactVersion(groupId, artifactId);
            }

        };
    }
531524
def revision(config, message):
    """"""
    with open(config, 'r'):
        main.revision(yaml.load(open(config)), message)