Mercurial > hg
annotate mercurial/cffi/osutilbuild.py @ 50411:841b13e6e84c
rust-changelog: introducing an intermediate `ChangelogEntry`
Before this change, client code needing to extract, e.g, the Node ID and the
description from a changeset had no other choice than calling both
`entry_for_rev()` and `data_for_rev()`. This duplicates some (limited) computation, and
more importantly imposes bad hygiene for client code: at some point of developement,
the client code would have to pass over both entry and data in its internal layers,
which at some point of development would raise the question whether they are consistent.
We introduce the intermediate `ChangelogEntry` from which both conversion to the generic
`RevlogEntry` and extraction of `ChangelogRevisionData` are possible.
It might grow some convenience methods in the future.
We keep the `data_for_rev()` method of `Changelog` for compatibility, pointing users at the more
powerful alternative.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Wed, 29 Mar 2023 20:50:42 +0200 |
parents | 6000f5b25c9b |
children | f4733654f144 |
rev | line source |
---|---|
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
1 import cffi |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
2 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
3 ffi = cffi.FFI() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
4 ffi.set_source( |
43668
53607fd3ec6c
cffi: fix build on Python 3
Manuel Jacob <me@manueljacob.de>
parents:
43077
diff
changeset
|
5 "mercurial.cffi._osutil", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
6 """ |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
7 #include <sys/attr.h> |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
8 #include <sys/vnode.h> |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
9 #include <unistd.h> |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
10 #include <fcntl.h> |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
11 #include <time.h> |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
12 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
13 typedef struct val_attrs { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
14 uint32_t length; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
15 attribute_set_t returned; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
16 attrreference_t name_info; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
17 fsobj_type_t obj_type; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
18 struct timespec mtime; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
19 uint32_t accessmask; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
20 off_t datalength; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
21 } __attribute__((aligned(4), packed)) val_attrs_t; |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
22 """, |
43668
53607fd3ec6c
cffi: fix build on Python 3
Manuel Jacob <me@manueljacob.de>
parents:
43077
diff
changeset
|
23 include_dirs=['mercurial'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
24 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
25 ffi.cdef( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
26 ''' |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
27 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
28 typedef uint32_t attrgroup_t; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
29 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
30 typedef struct attrlist { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
31 uint16_t bitmapcount; /* number of attr. bit sets in list */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
32 uint16_t reserved; /* (to maintain 4-byte alignment) */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
33 attrgroup_t commonattr; /* common attribute group */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
34 attrgroup_t volattr; /* volume attribute group */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
35 attrgroup_t dirattr; /* directory attribute group */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
36 attrgroup_t fileattr; /* file attribute group */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
37 attrgroup_t forkattr; /* fork attribute group */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
38 ...; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
39 }; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
40 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
41 typedef struct attribute_set { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
42 ...; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
43 } attribute_set_t; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
44 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
45 typedef struct attrreference { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
46 int attr_dataoffset; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
47 int attr_length; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
48 ...; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
49 } attrreference_t; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
50 |
29910
a043c6d372db
osutil: fix the declaration to work on different sizes of off_t
Maciej Fijalkowski <fijall@gmail.com>
parents:
29600
diff
changeset
|
51 typedef int ... off_t; |
a043c6d372db
osutil: fix the declaration to work on different sizes of off_t
Maciej Fijalkowski <fijall@gmail.com>
parents:
29600
diff
changeset
|
52 |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
53 typedef struct val_attrs { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
54 uint32_t length; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
55 attribute_set_t returned; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
56 attrreference_t name_info; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
57 uint32_t obj_type; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
58 struct timespec mtime; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
59 uint32_t accessmask; |
29910
a043c6d372db
osutil: fix the declaration to work on different sizes of off_t
Maciej Fijalkowski <fijall@gmail.com>
parents:
29600
diff
changeset
|
60 off_t datalength; |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
61 ...; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
62 } val_attrs_t; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
63 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
64 /* the exact layout of the above struct will be figured out during build time */ |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
65 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
66 typedef int ... time_t; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
67 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
68 typedef struct timespec { |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
69 time_t tv_sec; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
70 ...; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
71 }; |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
72 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
73 int getattrlist(const char* path, struct attrlist * attrList, void * attrBuf, |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
74 size_t attrBufSize, unsigned int options); |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
75 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
76 int getattrlistbulk(int dirfd, struct attrlist * attrList, void * attrBuf, |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
77 size_t attrBufSize, uint64_t options); |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
78 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
79 #define ATTR_BIT_MAP_COUNT ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
80 #define ATTR_CMN_NAME ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
81 #define ATTR_CMN_OBJTYPE ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
82 #define ATTR_CMN_MODTIME ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
83 #define ATTR_CMN_ACCESSMASK ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
84 #define ATTR_CMN_ERROR ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
85 #define ATTR_CMN_RETURNED_ATTRS ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
86 #define ATTR_FILE_DATALENGTH ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
87 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
88 #define VREG ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
89 #define VDIR ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
90 #define VLNK ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
91 #define VBLK ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
92 #define VCHR ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
93 #define VFIFO ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
94 #define VSOCK ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
95 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
96 #define S_IFMT ... |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
97 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
98 int open(const char *path, int oflag, int perm); |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
99 int close(int); |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
100 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
101 #define O_RDONLY ... |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
102 ''' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
32506
diff
changeset
|
103 ) |
29600
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
104 |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
105 if __name__ == '__main__': |
7a157639b8f2
osutil: add darwin-only version of os.listdir using cffi
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff
changeset
|
106 ffi.compile() |