mercurial/mpatch.h
author Boris Feld <boris.feld@octobus.net>
Wed, 17 Jan 2018 17:07:55 +0100
changeset 35726 45b678bf3a78
parent 34800 761355833867
child 48274 d86908050375
permissions -rw-r--r--
atomicupdate: add an experimental option to use atomictemp when updating In some cases Mercurial truncating files when updating causes problems. It can happens when processes are currently reading the file or with big file or on NFS mounts. We add an experimental option to use the atomictemp option of vfs.__call__ in order to avoid the problem. The localrepository.wwrite seems to assume the files are created without the `x` flag; with atomictempfile, the new file might inherit the `x` flag from the destination. We force remove it afterward. This code could be refactored and the flag processing could be moved inside vfs. This patch should be tested with `--extra-config-opt experimental.update.atomic-file=True` as we disabled the option by default. Differential Revision: https://phab.mercurial-scm.org/D1882

#ifndef _HG_MPATCH_H_
#define _HG_MPATCH_H_

#define MPATCH_ERR_NO_MEM -3
#define MPATCH_ERR_CANNOT_BE_DECODED -2
#define MPATCH_ERR_INVALID_PATCH -1

struct mpatch_frag {
	int start, end, len;
	const char *data;
};

struct mpatch_flist {
	struct mpatch_frag *base, *head, *tail;
};

int mpatch_decode(const char *bin, ssize_t len, struct mpatch_flist **res);
ssize_t mpatch_calcsize(ssize_t len, struct mpatch_flist *l);
void mpatch_lfree(struct mpatch_flist *a);
int mpatch_apply(char *buf, const char *orig, ssize_t len,
                 struct mpatch_flist *l);
struct mpatch_flist *
mpatch_fold(void *bins, struct mpatch_flist *(*get_next_item)(void *, ssize_t),
            ssize_t start, ssize_t end);

#endif