change: rework printing of patches - print Edit and Newvertex types
Dependencies
- [2]
QYRJIOYPchange: separate decoding and printing of hashed struct - [3]
WMFNGOYTchange: reduce printed noise, rework some code - [4]
ZKAOPMCHchange: Implement decoding of edits, atoms, positions, among others - [5]
KDJUAAALchange: prefix function names with change_ - [6]
OBKF6SIIchange: decompress the hashed section too - [7]
3FT3XTJMchange: support -v/-h flags - [8]
RIWSVVASchange: decompress the 'contents' with zstd_seekable - [9]
Q7TKZCJPAdd initial support for reading the offsets from a (fixed) change - [10]
2U7P5SFQChange struct names "struct foo -> typedef struct Foo" - [*]
XTKRT6OQformat the codebase - [*]
QEFCNNVCchange: display offsets for given change file
Change contents
- edit in change.c at line 510
}voidprint_positionlist(Positionlist *plist){Position *p;int i;p = &plist->first;printf("P0.%lu", p->pos);if (plist->len > 1)for (i = 0; i < plist->len - 1; i++) {printf("P%d.%lu", i + 1, plist->entries[i].pos);} - edit in change.c at line 527[3.2599][13.4]
* TODO To properly print EDGE_MAP types we need access to referenced changes to pull deleted lines*/voidprint_atom(Atom *a, uint8_t *contents){Newvertex *v;Edgemap *m;char *c, x;int i, waseol;switch (a->atomtype) {case NEW_VERTEX:v = &a->newvertex;printf("up: ");print_positionlist(&v->upcontext);printf(", ");printf("new: %lu:%lu, down: ", v->start, v->end);print_positionlist(&v->downcontext);printf("\n");waseol = 1;for (i = v->start; i < v->end; i++) {if (waseol) {printf("+ ");waseol = 0;}x = contents[i];putchar(x);if (x == '\n')waseol = 1;}printf("\n");break;case EDGE_MAP:m = &a->edgemap;printf("EdgeMap... \n");break;default:abort();}}/** - edit in change.c at line 619
/*** Seek to the point in the file where contents begin. Keep in mind,* we've already read 56 bytes.*/if (lseek(fd, off.contents_off, SEEK_SET) == -1) {perror("lseek");goto out;}contents = change_read_contents(fd, &off);if (verbose)dump_buf("contents", contents, off.contents_len); - replacement in change.c at line 656
printf("\n");printf("\n#Hunks\n\n"); - replacement in change.c at line 658
/*** Seek to the point in the file where contents begin. Keep in mind,* we've already read 56 bytes.*/if (lseek(fd, off.contents_off, SEEK_SET) == -1) {perror("lseek");goto out;/* 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;} - edit in change.c at line 685
contents = change_read_contents(fd, &off);if (verbose)dump_buf("contents", contents, off.contents_len);