##// END OF EJS Templates
hgweb: use patch.diffhunks in webutil.diffs to simplify the algorithm...
hgweb: use patch.diffhunks in webutil.diffs to simplify the algorithm Function patch.diffhunks yields items for a "block" (i.e. a file) as a whole so take advantage of this to simplify the algorithm and avoid parsing diff lines to determine whether we're starting a new "block" or not. Thus we drop to external block counter and rely on diffhunks iterations instead. We also take advantage of the fact that patch.diffhunks() yields *lines* of hunks (instead of a string) to avoid building a list that is ''.join-ed into a string that is then split. As lines in 'header' returned by patch.diffhunks() have no trailing new line, we need to insert it ourselves to match template expectations.

File last commit:

r29541:9631ff5e default
r31276:cd29673c default
Show More
bdiff.h
21 lines | 432 B | text/x-c | CLexer
#ifndef _HG_BDIFF_H_
#define _HG_BDIFF_H_
struct bdiff_line {
int hash, n, e;
ssize_t len;
const char *l;
};
struct bdiff_hunk;
struct bdiff_hunk {
int a1, a2, b1, b2;
struct bdiff_hunk *next;
};
int bdiff_splitlines(const char *a, ssize_t len, struct bdiff_line **lr);
int bdiff_diff(struct bdiff_line *a, int an, struct bdiff_line *b, int bn,
struct bdiff_hunk *base);
void bdiff_freehunks(struct bdiff_hunk *l);
#endif