annotate mercurial/thirdparty/xdiff/xtypes.h @ 42172:71d8b4d91616 stable

setup: properly package distutils in py2exe virtualenv builds Our in-repo py2exe packaging code uses virtualenvs for managing dependencies. An advantage of this is that packaging is more deterministic and reproducible. Without virtualenvs, we need to install packages in the system Python install. Packages installed by other consumers of the system Python could leak into the Mercurial package. A regression from this change was that py2exe packages contained the virtualenv's hacked distutils modules instead of the original distutils modules. (virtualenv installs a hacked distutils module because distutils uses relative path lookups that fail when running from a virtualenv.) This commit introduces a workaround so py2exe packaging uses the original distutils modules when running from a virtualenv. With this change, `import distutils` no longer fails from py2exe builds produced from a virtualenv. This fixes the regression. Furthermore, we now include all distutils modules. Before, py2exe's module finding would only find modules there were explicitly referenced in code. So, we now package a complete copy of distutils instead of a partial one. This is even better than before. # no-check-commit foo_bar function name
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 20 Apr 2019 07:29:07 -0700
parents 882657a9f768
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
1 /*
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
2 * LibXDiff by Davide Libenzi ( File Differential Library )
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
3 * Copyright (C) 2003 Davide Libenzi
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
4 *
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
9 *
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
14 *
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
16 * License along with this library; if not, see
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
17 * <http://www.gnu.org/licenses/>.
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
18 *
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
19 * Davide Libenzi <davidel@xmailserver.org>
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
20 *
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
21 */
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
22
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
23 #if !defined(XTYPES_H)
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
24 #define XTYPES_H
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
25
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
26
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
27
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
28 typedef struct s_chanode {
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
29 struct s_chanode *next;
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
30 int64_t icurr;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
31 } chanode_t;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
32
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
33 typedef struct s_chastore {
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
34 chanode_t *head, *tail;
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
35 int64_t isize, nsize;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
36 chanode_t *ancur;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
37 chanode_t *sncur;
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
38 int64_t scurr;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
39 } chastore_t;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
40
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
41 typedef struct s_xrecord {
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
42 struct s_xrecord *next;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
43 char const *ptr;
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
44 int64_t size;
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
45 uint64_t ha;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
46 } xrecord_t;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
47
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
48 typedef struct s_xdfile {
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
49 /* manual memory management */
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
50 chastore_t rcha;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
51
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
52 /* number of records (lines) */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
53 int64_t nrec;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
54
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
55 /* hash table size
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
56 * the maximum hash value in the table is (1 << hbits) */
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
57 unsigned int hbits;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
58
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
59 /* hash table, hash value => xrecord_t
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
60 * note: xrecord_t is a linked list. */
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
61 xrecord_t **rhash;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
62
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
63 /* range excluding common prefix and suffix
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
64 * [recs[i] for i in range(0, dstart)] are common prefix.
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
65 * [recs[i] for i in range(dstart, dend + 1 - dstart)] are interesting
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
66 * lines */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
67 int64_t dstart, dend;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
68
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
69 /* pointer to records (lines) */
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
70 xrecord_t **recs;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
71
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
72 /* record changed, use original "recs" index
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
73 * rchag[i] can be either 0 or 1. 1 means recs[i] (line i) is marked
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
74 * "changed". */
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
75 char *rchg;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
76
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
77 /* cleaned-up record index => original "recs" index
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
78 * clean-up means:
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
79 * rule 1. remove common prefix and suffix
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
80 * rule 2. remove records that are only on one side, since they can
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
81 * not match the other side
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
82 * rindex[0] is likely dstart, if not removed up by rule 2.
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
83 * rindex[nreff - 1] is likely dend, if not removed by rule 2.
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
84 */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
85 int64_t *rindex;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
86
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
87 /* rindex size */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
88 int64_t nreff;
36821
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
89
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
90 /* cleaned-up record index => hash value
0c7350656f93 xdiff: add comments for fields in xdfile_t
Jun Wu <quark@fb.com>
parents: 36820
diff changeset
91 * ha[i] = recs[rindex[i]]->ha */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
92 uint64_t *ha;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
93 } xdfile_t;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
94
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
95 typedef struct s_xdfenv {
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
96 xdfile_t xdf1, xdf2;
36820
f33a87cf60cc xdiff: add a preprocessing step that trims files
Jun Wu <quark@fb.com>
parents: 36671
diff changeset
97
f33a87cf60cc xdiff: add a preprocessing step that trims files
Jun Wu <quark@fb.com>
parents: 36671
diff changeset
98 /* number of lines for common prefix and suffix that are removed
f33a87cf60cc xdiff: add a preprocessing step that trims files
Jun Wu <quark@fb.com>
parents: 36671
diff changeset
99 * from xdf1 and xdf2 as a preprocessing step */
36822
882657a9f768 xdiff: replace {unsigned ,}long with {u,}int64_t
Jun Wu <quark@fb.com>
parents: 36821
diff changeset
100 int64_t nprefix, nsuffix;
36671
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
101 } xdfenv_t;
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
102
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
103
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
104
34e2ff1f9cd8 xdiff: vendor xdiff library from git
Jun Wu <quark@fb.com>
parents:
diff changeset
105 #endif /* #if !defined(XTYPES_H) */