40d11cea3f
lazily close revlog files and keep up to 8 revlogs arround. also cache the latest extracted file descriptor of a revision in the revlog. this avoids the quite expensive reextracting/patching when we reopen the same file revision. dont use the racy mktemp()/create, instead create a uniqueue name and create with OEXCL. this also avoids a bunch of access() calls. fix eof case and use pread() in fcopy() to avoid the seeks. dont modify changelog temp file but simulate trailing newline instead.
103 lines
1 KiB
C
103 lines
1 KiB
C
enum {
|
|
MAXPATH = 1024,
|
|
BUFSZ = 1024,
|
|
HASHSZ = 20,
|
|
};
|
|
|
|
typedef struct Revlog Revlog;
|
|
typedef struct Revmap Revmap;
|
|
typedef struct Revinfo Revinfo;
|
|
typedef struct Revtree Revtree;
|
|
typedef struct Revnode Revnode;
|
|
typedef struct Revfile Revfile;
|
|
|
|
struct Revmap
|
|
{
|
|
int rev;
|
|
int p1rev;
|
|
int p2rev;
|
|
int baserev;
|
|
int linkrev;
|
|
|
|
uchar hash[HASHSZ];
|
|
|
|
int flags;
|
|
|
|
vlong hoff;
|
|
vlong hlen;
|
|
|
|
vlong flen;
|
|
|
|
void *aux;
|
|
};
|
|
|
|
struct Revlog
|
|
{
|
|
Ref;
|
|
|
|
Revlog *next;
|
|
|
|
char *path;
|
|
|
|
int ifd;
|
|
int dfd;
|
|
|
|
vlong ioff;
|
|
|
|
int nmap;
|
|
Revmap *map;
|
|
|
|
int tfd;
|
|
int tid;
|
|
};
|
|
|
|
struct Revnode
|
|
{
|
|
char *name;
|
|
uchar *hash;
|
|
uvlong path;
|
|
|
|
Revnode *up;
|
|
Revnode *next;
|
|
Revnode *down;
|
|
Revnode *before;
|
|
|
|
char mode;
|
|
};
|
|
|
|
struct Revinfo
|
|
{
|
|
uchar chash[HASHSZ];
|
|
uchar mhash[HASHSZ];
|
|
|
|
char *who;
|
|
char *why;
|
|
ulong when;
|
|
|
|
vlong logoff;
|
|
vlong loglen;
|
|
};
|
|
|
|
struct Revtree
|
|
{
|
|
Ref;
|
|
int level;
|
|
Revnode *root;
|
|
};
|
|
|
|
struct Revfile
|
|
{
|
|
int level;
|
|
|
|
Revinfo *info;
|
|
Revtree *tree;
|
|
Revnode *node;
|
|
Revlog *rlog;
|
|
|
|
char *buf;
|
|
int fd;
|
|
int doff; /* length of metadata to skip */
|
|
};
|
|
|
|
uchar nullid[HASHSZ];
|