##// END OF EJS Templates
diff: use fctx.isbinary() to test binary...
diff: use fctx.isbinary() to test binary The end goal is to avoid calling fctx.data() when unnecessary. For example, if diff.nobinary=1 and files are binary, the expected behavior is to print "Binary file has changed". That could avoid reading fctx.data() sometimes. This is mainly to enable an external LFS extension to skip expensive binary file loading sometimes (read: most of the time with diff.nobinary=1 and diff.text=0), without any behavior changes to mercurial (i.e. whether a file is LFS or not does not change any behavior, LFS could be 100% transparent to users).

File last commit:

r29444:284d742e default
r32187:e62cf13e default
Show More
bitmanipulation.h
53 lines | 933 B | text/x-c | CLexer
#ifndef _HG_BITMANIPULATION_H_
#define _HG_BITMANIPULATION_H_
#include "compat.h"
static inline uint32_t getbe32(const char *c)
{
const unsigned char *d = (const unsigned char *)c;
return ((d[0] << 24) |
(d[1] << 16) |
(d[2] << 8) |
(d[3]));
}
static inline int16_t getbeint16(const char *c)
{
const unsigned char *d = (const unsigned char *)c;
return ((d[0] << 8) |
(d[1]));
}
static inline uint16_t getbeuint16(const char *c)
{
const unsigned char *d = (const unsigned char *)c;
return ((d[0] << 8) |
(d[1]));
}
static inline void putbe32(uint32_t x, char *c)
{
c[0] = (x >> 24) & 0xff;
c[1] = (x >> 16) & 0xff;
c[2] = (x >> 8) & 0xff;
c[3] = (x) & 0xff;
}
static inline double getbefloat64(const char *c)
{
const unsigned char *d = (const unsigned char *)c;
double ret;
int i;
uint64_t t = 0;
for (i = 0; i < 8; i++) {
t = (t<<8) + d[i];
}
memcpy(&ret, &t, sizeof(t));
return ret;
}
#endif