mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 14:58:03 +03:00
xdiff: renamed third-party xdiff functions
Summary:
Follow up on this diff: D22432330 (b7817ffbd8
)
Renamed xdiff functions to avoid linking issues when using both libgit2-sys and xdiff.
Reviewed By: farnz
Differential Revision: D22511368
fbshipit-source-id: e4be20e3112a8e8829298d5748657e9bdbde8588
This commit is contained in:
parent
e4fed9c5b8
commit
78e3864869
@ -5,6 +5,7 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#![type_length_limit = "4522397"]
|
||||
use anyhow::Error;
|
||||
use blobrepo::{save_bonsai_changesets, BlobRepo};
|
||||
use clap::Arg;
|
||||
|
16
eden/scm/lib/third-party/xdiff/xdiffi.c
vendored
16
eden/scm/lib/third-party/xdiff/xdiffi.c
vendored
@ -332,7 +332,7 @@ int xdl_do_diff_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
xdalgoenv_t xenv;
|
||||
diffdata_t dd1, dd2;
|
||||
|
||||
if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {
|
||||
if (xdl_prepare_env_vendored(mf1, mf2, xpp, xe) < 0) {
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -344,7 +344,7 @@ int xdl_do_diff_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
|
||||
if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) * sizeof(int64_t)))) {
|
||||
|
||||
xdl_free_env(xe);
|
||||
xdl_free_env_vendored(xe);
|
||||
return -1;
|
||||
}
|
||||
kvdf = kvd;
|
||||
@ -352,7 +352,7 @@ int xdl_do_diff_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
kvdf += xe->xdf2.nreff + 1;
|
||||
kvdb += xe->xdf2.nreff + 1;
|
||||
|
||||
xenv.mxcost = xdl_bogosqrt(ndiags);
|
||||
xenv.mxcost = xdl_bogosqrt_vendored(ndiags);
|
||||
if (xenv.mxcost < XDL_MAX_COST_MIN)
|
||||
xenv.mxcost = XDL_MAX_COST_MIN;
|
||||
xenv.snake_cnt = XDL_SNAKE_CNT;
|
||||
@ -371,7 +371,7 @@ int xdl_do_diff_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, &xenv) < 0) {
|
||||
|
||||
xdl_free(kvd);
|
||||
xdl_free_env(xe);
|
||||
xdl_free_env_vendored(xe);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -401,7 +401,7 @@ static xdchange_t *xdl_add_change(xdchange_t *xscr, int64_t i1, int64_t i2, int6
|
||||
static int recs_match(xrecord_t *rec1, xrecord_t *rec2)
|
||||
{
|
||||
return (rec1->ha == rec2->ha &&
|
||||
xdl_recmatch(rec1->ptr, rec1->size,
|
||||
xdl_recmatch_vendored(rec1->ptr, rec1->size,
|
||||
rec2->ptr, rec2->size));
|
||||
}
|
||||
|
||||
@ -1114,17 +1114,17 @@ int xdl_diff_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
xdl_change_compact_vendored(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 ||
|
||||
xdl_build_script_vendored(&xe, &xscr) < 0) {
|
||||
|
||||
xdl_free_env(&xe);
|
||||
xdl_free_env_vendored(&xe);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xdl_call_hunk_func(&xe, xscr, ecb, xecfg) < 0) {
|
||||
xdl_free_script_vendored(xscr);
|
||||
xdl_free_env(&xe);
|
||||
xdl_free_env_vendored(&xe);
|
||||
return -1;
|
||||
}
|
||||
xdl_free_script_vendored(xscr);
|
||||
xdl_free_env(&xe);
|
||||
xdl_free_env_vendored(&xe);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
38
eden/scm/lib/third-party/xdiff/xprepare.c
vendored
38
eden/scm/lib/third-party/xdiff/xprepare.c
vendored
@ -70,16 +70,16 @@ static int xdl_optimize_ctxs(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2
|
||||
static int xdl_init_classifier(xdlclassifier_t *cf, int64_t size, int64_t flags) {
|
||||
cf->flags = flags;
|
||||
|
||||
cf->hbits = xdl_hashbits(size);
|
||||
cf->hbits = xdl_hashbits_vendored(size);
|
||||
cf->hsize = ((uint64_t)1) << cf->hbits;
|
||||
|
||||
if (xdl_cha_init(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) {
|
||||
if (xdl_cha_init_vendored(&cf->ncha, sizeof(xdlclass_t), size / 4 + 1) < 0) {
|
||||
|
||||
return -1;
|
||||
}
|
||||
if (!(cf->rchash = (xdlclass_t **) xdl_malloc(cf->hsize * sizeof(xdlclass_t *)))) {
|
||||
|
||||
xdl_cha_free(&cf->ncha);
|
||||
xdl_cha_free_vendored(&cf->ncha);
|
||||
return -1;
|
||||
}
|
||||
memset(cf->rchash, 0, cf->hsize * sizeof(xdlclass_t *));
|
||||
@ -88,7 +88,7 @@ static int xdl_init_classifier(xdlclassifier_t *cf, int64_t size, int64_t flags)
|
||||
if (!(cf->rcrecs = (xdlclass_t **) xdl_malloc(cf->alloc * sizeof(xdlclass_t *)))) {
|
||||
|
||||
xdl_free(cf->rchash);
|
||||
xdl_cha_free(&cf->ncha);
|
||||
xdl_cha_free_vendored(&cf->ncha);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
|
||||
|
||||
xdl_free(cf->rcrecs);
|
||||
xdl_free(cf->rchash);
|
||||
xdl_cha_free(&cf->ncha);
|
||||
xdl_cha_free_vendored(&cf->ncha);
|
||||
}
|
||||
|
||||
|
||||
@ -117,12 +117,12 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
|
||||
hi = (long) XDL_HASHLONG(rec->ha, cf->hbits);
|
||||
for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
|
||||
if (rcrec->ha == rec->ha &&
|
||||
xdl_recmatch(rcrec->line, rcrec->size,
|
||||
xdl_recmatch_vendored(rcrec->line, rcrec->size,
|
||||
rec->ptr, rec->size))
|
||||
break;
|
||||
|
||||
if (!rcrec) {
|
||||
if (!(rcrec = xdl_cha_alloc(&cf->ncha))) {
|
||||
if (!(rcrec = xdl_cha_alloc_vendored(&cf->ncha))) {
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -256,13 +256,13 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, int64_t narec,
|
||||
rhash = NULL;
|
||||
recs = NULL;
|
||||
|
||||
if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0)
|
||||
if (xdl_cha_init_vendored(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0)
|
||||
goto abort;
|
||||
if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
|
||||
{
|
||||
hbits = xdl_hashbits(narec);
|
||||
hbits = xdl_hashbits_vendored(narec);
|
||||
hsize = ((uint64_t)1) << hbits;
|
||||
if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
@ -273,14 +273,14 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, int64_t narec,
|
||||
if ((cur = blk = xdl_mmfile_first_vendored(mf, &bsize)) != NULL) {
|
||||
for (top = blk + bsize; cur < top; ) {
|
||||
prev = cur;
|
||||
hav = xdl_hash_record(&cur, top);
|
||||
hav = xdl_hash_record_vendored(&cur, top);
|
||||
if (nrec >= narec) {
|
||||
narec *= 2;
|
||||
if (!(rrecs = (xrecord_t **) xdl_realloc(recs, narec * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
recs = rrecs;
|
||||
}
|
||||
if (!(crec = xdl_cha_alloc(&xdf->rcha)))
|
||||
if (!(crec = xdl_cha_alloc_vendored(&xdf->rcha)))
|
||||
goto abort;
|
||||
crec->ptr = prev;
|
||||
crec->size = (long) (cur - prev);
|
||||
@ -320,7 +320,7 @@ abort:
|
||||
xdl_free(rchg);
|
||||
xdl_free(rhash);
|
||||
xdl_free(recs);
|
||||
xdl_cha_free(&xdf->rcha);
|
||||
xdl_cha_free_vendored(&xdf->rcha);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -332,13 +332,13 @@ static void xdl_free_ctx(xdfile_t *xdf) {
|
||||
xdl_free(xdf->rchg - 1);
|
||||
xdl_free(xdf->ha);
|
||||
xdl_free(xdf->recs);
|
||||
xdl_cha_free(&xdf->rcha);
|
||||
xdl_cha_free_vendored(&xdf->rcha);
|
||||
}
|
||||
|
||||
/* Reserved lines for trimming, to leave room for shifting */
|
||||
#define TRIM_RESERVED_LINES 100
|
||||
|
||||
int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
int xdl_prepare_env_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
xdfenv_t *xe) {
|
||||
int64_t enl1, enl2, sample;
|
||||
mmfile_t tmf1, tmf2;
|
||||
@ -348,8 +348,8 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
|
||||
sample = XDL_GUESS_NLINES1;
|
||||
|
||||
enl1 = xdl_guess_lines(mf1, sample) + 1;
|
||||
enl2 = xdl_guess_lines(mf2, sample) + 1;
|
||||
enl1 = xdl_guess_lines_vendored(mf1, sample) + 1;
|
||||
enl2 = xdl_guess_lines_vendored(mf2, sample) + 1;
|
||||
|
||||
if (xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
|
||||
return -1;
|
||||
@ -381,7 +381,7 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
}
|
||||
|
||||
|
||||
void xdl_free_env(xdfenv_t *xe) {
|
||||
void xdl_free_env_vendored(xdfenv_t *xe) {
|
||||
|
||||
xdl_free_ctx(&xe->xdf2);
|
||||
xdl_free_ctx(&xe->xdf1);
|
||||
@ -465,7 +465,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
|
||||
dis1 = dis;
|
||||
dis2 = dis1 + xdf1->nrec + 1;
|
||||
|
||||
if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT)
|
||||
if ((mlim = xdl_bogosqrt_vendored(xdf1->nrec)) > XDL_MAX_EQLIMIT)
|
||||
mlim = XDL_MAX_EQLIMIT;
|
||||
for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) {
|
||||
rcrec = cf->rcrecs[(*recs)->ha];
|
||||
@ -473,7 +473,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
|
||||
dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
|
||||
}
|
||||
|
||||
if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT)
|
||||
if ((mlim = xdl_bogosqrt_vendored(xdf2->nrec)) > XDL_MAX_EQLIMIT)
|
||||
mlim = XDL_MAX_EQLIMIT;
|
||||
for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) {
|
||||
rcrec = cf->rcrecs[(*recs)->ha];
|
||||
|
4
eden/scm/lib/third-party/xdiff/xprepare.h
vendored
4
eden/scm/lib/third-party/xdiff/xprepare.h
vendored
@ -25,9 +25,9 @@
|
||||
|
||||
|
||||
|
||||
int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
int xdl_prepare_env_vendored(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
xdfenv_t *xe);
|
||||
void xdl_free_env(xdfenv_t *xe);
|
||||
void xdl_free_env_vendored(xdfenv_t *xe);
|
||||
|
||||
|
||||
|
||||
|
16
eden/scm/lib/third-party/xdiff/xutils.c
vendored
16
eden/scm/lib/third-party/xdiff/xutils.c
vendored
@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
|
||||
int64_t xdl_bogosqrt(int64_t n) {
|
||||
int64_t xdl_bogosqrt_vendored(int64_t n) {
|
||||
int64_t i;
|
||||
|
||||
/*
|
||||
@ -53,7 +53,7 @@ int64_t xdl_mmfile_size_vendored(mmfile_t *mmf)
|
||||
}
|
||||
|
||||
|
||||
int xdl_cha_init(chastore_t *cha, int64_t isize, int64_t icount) {
|
||||
int xdl_cha_init_vendored(chastore_t *cha, int64_t isize, int64_t icount) {
|
||||
|
||||
cha->head = cha->tail = NULL;
|
||||
cha->isize = isize;
|
||||
@ -65,7 +65,7 @@ int xdl_cha_init(chastore_t *cha, int64_t isize, int64_t icount) {
|
||||
}
|
||||
|
||||
|
||||
void xdl_cha_free(chastore_t *cha) {
|
||||
void xdl_cha_free_vendored(chastore_t *cha) {
|
||||
chanode_t *cur, *tmp;
|
||||
|
||||
for (cur = cha->head; (tmp = cur) != NULL;) {
|
||||
@ -75,7 +75,7 @@ void xdl_cha_free(chastore_t *cha) {
|
||||
}
|
||||
|
||||
|
||||
void *xdl_cha_alloc(chastore_t *cha) {
|
||||
void *xdl_cha_alloc_vendored(chastore_t *cha) {
|
||||
chanode_t *ancur;
|
||||
void *data;
|
||||
|
||||
@ -100,7 +100,7 @@ void *xdl_cha_alloc(chastore_t *cha) {
|
||||
return data;
|
||||
}
|
||||
|
||||
int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample) {
|
||||
int64_t xdl_guess_lines_vendored(mmfile_t *mf, int64_t sample) {
|
||||
int64_t nl = 0, size, tsize = 0;
|
||||
char const *data, *cur, *top;
|
||||
|
||||
@ -121,14 +121,14 @@ int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample) {
|
||||
return nl + 1;
|
||||
}
|
||||
|
||||
int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2)
|
||||
int xdl_recmatch_vendored(const char *l1, int64_t s1, const char *l2, int64_t s2)
|
||||
{
|
||||
if (s1 == s2 && !memcmp(l1, l2, s1))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t xdl_hash_record(char const **data, char const *top) {
|
||||
uint64_t xdl_hash_record_vendored(char const **data, char const *top) {
|
||||
uint64_t ha = 5381;
|
||||
char const *ptr = *data;
|
||||
|
||||
@ -141,7 +141,7 @@ uint64_t xdl_hash_record(char const **data, char const *top) {
|
||||
return ha;
|
||||
}
|
||||
|
||||
unsigned int xdl_hashbits(int64_t size) {
|
||||
unsigned int xdl_hashbits_vendored(int64_t size) {
|
||||
int64_t val = 1;
|
||||
unsigned int bits = 0;
|
||||
|
||||
|
16
eden/scm/lib/third-party/xdiff/xutils.h
vendored
16
eden/scm/lib/third-party/xdiff/xutils.h
vendored
@ -25,14 +25,14 @@
|
||||
|
||||
|
||||
|
||||
int64_t xdl_bogosqrt(int64_t n);
|
||||
int xdl_cha_init(chastore_t *cha, int64_t isize, int64_t icount);
|
||||
void xdl_cha_free(chastore_t *cha);
|
||||
void *xdl_cha_alloc(chastore_t *cha);
|
||||
int64_t xdl_guess_lines(mmfile_t *mf, int64_t sample);
|
||||
int xdl_recmatch(const char *l1, int64_t s1, const char *l2, int64_t s2);
|
||||
uint64_t xdl_hash_record(char const **data, char const *top);
|
||||
unsigned int xdl_hashbits(int64_t size);
|
||||
int64_t xdl_bogosqrt_vendored(int64_t n);
|
||||
int xdl_cha_init_vendored(chastore_t *cha, int64_t isize, int64_t icount);
|
||||
void xdl_cha_free_vendored(chastore_t *cha);
|
||||
void *xdl_cha_alloc_vendored(chastore_t *cha);
|
||||
int64_t xdl_guess_lines_vendored(mmfile_t *mf, int64_t sample);
|
||||
int xdl_recmatch_vendored(const char *l1, int64_t s1, const char *l2, int64_t s2);
|
||||
uint64_t xdl_hash_record_vendored(char const **data, char const *top);
|
||||
unsigned int xdl_hashbits_vendored(int64_t size);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user