change: refactor to print_change()

laumann
Nov 23, 2022, 9:39 AM
XTVLIC243WZF52NVTNRA3SV3WLE2ZZ5GTFQOK45IOLMXYQMTLOSAC

Dependencies

  • [2] ZKAOPMCH change: Implement decoding of edits, atoms, positions, among others
  • [3] YDQLW2ZO change: rework printing of patches - print Edit and Newvertex types
  • [4] RIWSVVAS change: decompress the 'contents' with zstd_seekable
  • [5] CJEOFJ27 change: minor output adjustment
  • [6] KDJUAAAL change: prefix function names with change_
  • [7] QYRJIOYP change: separate decoding and printing of hashed struct
  • [8] OBKF6SII change: decompress the hashed section too
  • [9] QEFCNNVC change: display offsets for given change file
  • [10] XTKRT6OQ format the codebase
  • [11] Q7TKZCJP Add initial support for reading the offsets from a (fixed) change
  • [12] JAGXXSR7 change: initial work on decoding hunks
  • [13] KEC3WLFN change: remove debugging lines
  • [14] 2U7P5SFQ Change struct names "struct foo -> typedef struct Foo"
  • [*] YG4DZB3A add representation of hash, decode dependencies

Change contents

  • replacement in hunk.c at line 42
    [4.2135][4.2135:2146]()
    abort();
    [4.2135]
    [4.2146]
    abort(); // FIXME Replace with die()
  • edit in hash.h at line 21
    [4.604]
    [16.320]
    void hashlist_free(Hashlist *h);
  • edit in hash.c at line 34
    [16.699]
    [16.699]
    }
    void
    hashlist_free(Hashlist *h)
    {
    free(h->entries);
  • edit in change.c at line 357
    [2.5020][2.5020:5096]()
    /* printf("%d. %s\n", i + 1, hunk_basehunk_type_str(bhunk->hunktype)); */
  • replacement in change.c at line 526
    [4.2599][3.239:339]()
    * TODO To properly print EDGE_MAP types we need access to referenced changes to pull deleted lines
    [4.2599]
    [3.339]
    * TODO To properly print EDGE_MAP types we need access to referenced changes to
    * pull deleted lines.
  • replacement in change.c at line 534
    [3.417][3.417:430]()
    char *c, x;
    [3.417]
    [3.430]
    char x;
  • edit in change.c at line 569
    [3.992]
    [3.992]
    }
    }
    void
    print_change(Hashed *hashed, uint8_t *contents)
    {
    int i;
    printf("message = %s\n", hashed->header.message);
    if (hashed->header.description)
    printf("description = '%s'\n", hashed->header.description);
    printf("timestamp = '%s'\n\n", hashed->header.timestamp);
    printf("[[authors]]\n");
    for (i = 0; i < hashed->header.authors.len; i++) {
    int j;
    for (j = 0; j < hashed->header.authors.map[i].len; j++) {
    printf("%s = '%s'\n",
    hashed->header.authors.map[i].entries[j].key,
    hashed->header.authors.map[i].entries[j].value);
    }
    }
    printf("\n");
    printf("# Dependencies\n");
    for (i = 0; i < hashed->dependencies.len; i++) {
    printf(" ");
    hashprintln(&hashed->dependencies.entries[i]);
    }
    for (i = 0; i < hashed->extraknown.len; i++) {
    printf("+");
    hashprintln(&hashed->extraknown.entries[i]);
    }
    printf("\n#Hunks\n\n");
    /* FIXME: Put all the hashes of dependencies in a big list, and number them from 2 */
    for (i = 0; i < hashed->hunks.len; i++) {
    Basehunk *hunk = &hashed->hunks.entries[i];
    printf("%d. %s", i + 1, hunk_basehunk_type_str(hunk->hunktype));
    switch (hunk->hunktype) {
    case EDIT:
    Edit *e = &hunk->edit;
    Atom *c = &e->change;
    printf(" in %s:%u (%s)", e->local.path, e->local.line,
    e->encoding);
    printf("\n");
    print_atom(c, contents);
    break;
    case REPLACEMENT:
    Replacement *r = &hunk->replacement;
    printf(" in %s:%u (%s)", r->local.path, r->local.line,
    r->encoding);
    print_atom(c, contents);
    printf("\n");
    break;
    default:
    printf(" [not yet implemented]\n");
    break;
    }
  • edit in change.c at line 632
    [3.997]
    [3.997]
  • replacement in change.c at line 693
    [3.1313][4.1473:1674](),[4.1473][4.1473:1674]()
    printf("message = %s\n", hashed.header.message);
    if (hashed.header.description)
    printf("description = '%s'\n", hashed.header.description);
    printf("timestamp = '%s'\n\n", hashed.header.timestamp);
    [3.1313]
    [4.1674]
    print_change(&hashed, contents);
  • edit in change.c at line 695
    [4.1675][4.1675:1962](),[4.1962][4.2584:2587](),[4.2584][4.2584:2587](),[4.2587][4.1963:1978](),[4.1978][4.2621:2622](),[4.2587][4.2621:2622](),[4.2622][4.1979:2072](),[4.2072][2.5675:5723](),[4.3391][4.2119:2122](),[2.5723][4.2119:2122](),[4.2119][4.2119:2122](),[4.2122][4.3392:3439](),[4.3439][4.2170:2185](),[4.2170][4.2170:2185](),[4.2185][2.5724:5770](),[4.3484][4.2231:2234](),[2.5770][4.2231:2234](),[4.2231][4.2231:2234](),[4.2234][3.1314:1339](),[3.1339][4.2249:2250](),[4.2249][4.2249:2250](),[4.2250][3.1340:2045](),[3.2045][4.2866:2870](),[4.2866][4.2866:2870]()
    printf("[[authors]]\n");
    for (i = 0; i < hashed.header.authors.len; i++) {
    int j;
    for (j = 0; j < hashed.header.authors.map[i].len; j++) {
    printf("%s = '%s'\n",
    hashed.header.authors.map[i].entries[j].key,
    hashed.header.authors.map[i].entries[j].value);
    }
    }
    printf("\n");
    printf("# Dependencies\n");
    for (i = 0; i < hashed.dependencies.len; i++) {
    printf(" ");
    hashprintln(&hashed.dependencies.entries[i]);
    }
    for (i = 0; i < hashed.extraknown.len; i++) {
    printf("+");
    hashprintln(&hashed.extraknown.entries[i]);
    }
    printf("\n#Hunks\n\n");
    /* FIXME: Put all the hashes of dependencies in a big list, and number them from 2 */
    for (i = 0; i < hashed.hunks.len; i++) {
    Basehunk *hunk = &hashed.hunks.entries[i];
    printf("%d. %s", i + 1, hunk_basehunk_type_str(hunk->hunktype));
    switch (hunk->hunktype) {
    case EDIT:
    Edit *e = &hunk->edit;
    Atom *c = &e->change;
    printf(" in %s:%u (%s)", e->local.path, e->local.line,
    e->encoding);
    printf("\n");
    print_atom(c, contents);
    break;
    case REPLACEMENT:
    Replacement *r = &hunk->replacement;
    printf(" in %s:%u (%s)", r->local.path, r->local.line,
    r->encoding);
    printf("\n");
    break;
    default:
    printf(" [not yet implemented]\n");
    break;
    }
    }