##// END OF EJS Templates
rebase: move actual rebase into a single transaction...
rebase: move actual rebase into a single transaction Previously, rebasing would open several transaction over the course of rebasing several commits. Opening a transaction can have notable overhead (like copying the dirstate) which can add up when rebasing many commits. This patch adds a single large transaction around the actual commit rebase operation, with a catch for intervention which serializes the current state if we need to drop back to the terminal for user intervention. Amazingly, almost all the tests seem to pass. On large repos with large working copies, this can speed up rebasing 7 commits by 25%. I'd expect the percentage to be a bit larger for rebasing even more commits. There are minor test changes because we're rolling back the entire transaction during unexpected exceptions instead of just stopping mid-rebase, so there's no more backup bundle. It also leave an unknown file in the working copy, since our clean up 'hg update' doesn't delete unknown files.

File last commit:

r30895:c32454d6 default
r31226:cf8ad0e6 default
Show More
python-zstandard.h
190 lines | 4.0 KiB | text/x-c | CLexer
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 /**
* Copyright (c) 2016-present, Gregory Szorc
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 #include "structmember.h"
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
#define ZSTD_STATIC_LINKING_ONLY
#define ZDICT_STATIC_LINKING_ONLY
#include "mem.h"
#include "zstd.h"
#include "zdict.h"
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 #define PYTHON_ZSTANDARD_VERSION "0.7.0"
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
typedef enum {
compressorobj_flush_finish,
compressorobj_flush_block,
} CompressorObj_Flush;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
typedef struct {
PyObject_HEAD
unsigned windowLog;
unsigned chainLog;
unsigned hashLog;
unsigned searchLog;
unsigned searchLength;
unsigned targetLength;
ZSTD_strategy strategy;
} CompressionParametersObject;
extern PyTypeObject CompressionParametersType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 unsigned long long frameContentSize;
unsigned windowSize;
unsigned dictID;
char checksumFlag;
} FrameParametersObject;
extern PyTypeObject FrameParametersType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 unsigned selectivityLevel;
int compressionLevel;
unsigned notificationLevel;
unsigned dictID;
} DictParametersObject;
extern PyTypeObject DictParametersType;
typedef struct {
PyObject_HEAD
void* dictData;
size_t dictSize;
} ZstdCompressionDict;
extern PyTypeObject ZstdCompressionDictType;
typedef struct {
PyObject_HEAD
int compressionLevel;
ZstdCompressionDict* dict;
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 ZSTD_CCtx* cctx;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZSTD_CDict* cdict;
CompressionParametersObject* cparams;
ZSTD_frameParameters fparams;
} ZstdCompressor;
extern PyTypeObject ZstdCompressorType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
ZSTD_CStream* cstream;
ZSTD_outBuffer output;
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 int finished;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionObj;
extern PyTypeObject ZstdCompressionObjType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* writer;
Py_ssize_t sourceSize;
size_t outSize;
ZSTD_CStream* cstream;
int entered;
} ZstdCompressionWriter;
extern PyTypeObject ZstdCompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* reader;
Py_buffer* buffer;
Py_ssize_t bufferOffset;
Py_ssize_t sourceSize;
size_t inSize;
size_t outSize;
ZSTD_CStream* cstream;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
int finishedOutput;
int finishedInput;
PyObject* readResult;
} ZstdCompressorIterator;
extern PyTypeObject ZstdCompressorIteratorType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 ZSTD_DCtx* dctx;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
ZstdCompressionDict* dict;
ZSTD_DDict* ddict;
} ZstdDecompressor;
extern PyTypeObject ZstdDecompressorType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
ZSTD_DStream* dstream;
int finished;
} ZstdDecompressionObj;
extern PyTypeObject ZstdDecompressionObjType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
PyObject* writer;
size_t outSize;
ZSTD_DStream* dstream;
int entered;
} ZstdDecompressionWriter;
extern PyTypeObject ZstdDecompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
PyObject* reader;
Py_buffer* buffer;
Py_ssize_t bufferOffset;
size_t inSize;
size_t outSize;
size_t skipBytes;
ZSTD_DStream* dstream;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
Py_ssize_t readCount;
int finishedInput;
int finishedOutput;
} ZstdDecompressorIterator;
extern PyTypeObject ZstdDecompressorIteratorType;
typedef struct {
int errored;
PyObject* chunk;
} DecompressorIteratorResult;
void ztopy_compression_parameters(CompressionParametersObject* params, ZSTD_compressionParameters* zparams);
CompressionParametersObject* get_compression_parameters(PyObject* self, PyObject* args);
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 FrameParametersObject* get_frame_parameters(PyObject* self, PyObject* args);
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 PyObject* estimate_compression_context_size(PyObject* self, PyObject* args);
ZSTD_CStream* CStream_from_ZstdCompressor(ZstdCompressor* compressor, Py_ssize_t sourceSize);
ZSTD_DStream* DStream_from_ZstdDecompressor(ZstdDecompressor* decompressor);
ZstdCompressionDict* train_dictionary(PyObject* self, PyObject* args, PyObject* kwargs);