Exemplo n.º 1
0
Arquivo: file.c Projeto: rcls/crap
version_t * file_find_version (const file_t * f, const char * s)
{
    return version_normalise (
        find_version_string (
            f->versions, f->versions_end - f->versions,
            sizeof (version_t), offsetof (version_t, version), s));
}
Exemplo n.º 2
0
static void print_commit (FILE * out, const database_t * db, changeset_t * cs,
                          cvs_connection_t * s)
{
    version_t * v = cs->versions[0];

    version_t ** fetch = NULL;
    version_t ** fetch_end = NULL;

    // Get the list of versions to fetch.
    for (version_t ** i = cs->versions; i != cs->versions_end; ++i) {
        if (!(*i)->used)
            continue;

        version_t * cv = version_live (*i);
        if (cv != NULL && cv->mark == SIZE_MAX)
            ARRAY_APPEND (fetch, cv);
    }

    fprintf (stderr, "%s COMMIT", format_date (&cs->time, false));

    // Get the versions.
    grab_versions (out, db, s, fetch, fetch_end);
    xfree (fetch);

    v->branch->last = cs;
    cs->mark = ++mark_counter;
    v->branch->changeset.mark = cs->mark;

    fprintf (out, "commit %s/%s\n",
             branch_prefix, *v->branch->tag ? v->branch->tag : master);
    fprintf (out, "mark :%zu\n", cs->mark);
    fprintf (out, "committer %s <%s> %ld +0000\n",
             v->author, v->author, cs->time);
    fprintf (out, "data %zu\n%s\n", strlen (v->log), v->log);
    for (changeset_t ** i = cs->merge; i != cs->merge_end; ++i)
        if ((*i)->mark == 0)
            fprintf (stderr, "Whoops, out of order!\n");
        else if ((*i)->mark == mark_counter)
            fprintf (stderr, "Whoops, self-ref\n");
        else
            fprintf (out, "merge :%zu\n", (*i)->mark);

    const char * last_path = NULL;
    for (version_t ** i = cs->versions; i != cs->versions_end; ++i)
        if ((*i)->used) {
            version_t * vv = version_normalise (*i);
            if (vv->dead)
                fprintf (out, "D %s\n", vv->file->path);
            else
                fprintf (out, "M %s :%zu %s\n",
                         vv->exec ? "755" : "644", vv->mark, vv->file->path);
            last_path = output_entries_list (
                out, db, v->branch->branch_versions, vv->file, last_path);
        }

    fprintf (stderr, "\n");
}