mercurial/compat.h
author Martin von Zweigbergk <martinvonz@google.com>
Thu, 05 Apr 2018 14:03:33 -0700
changeset 37386 167b22a906f3
parent 33926 f4433f2713d0
child 39610 11ed2eadf937
permissions -rw-r--r--
context: make repo[<filtered binary nodeid>] match node If you pass in a binary nodeid of a filtered node to repo.__getitem__, it would run through this code: try: self._node = changeid self._rev = repo.changelog.rev(changeid) return except error.FilteredLookupError: raise except LookupError: pass However, repo.changelog.rev() would raise a FilteredLookupError, not FilteredRepoLookupError. Instead, we would hit the "except LookupError" and continue, trying to interpret the nodeid as a bookmark etc. The end result would be an error like this: abort: unknown revision 'ddadbd7c40ef8b8ad6d0d01a7a842092fc431798'! After this patch, it would instead be: abort: 00changelog.i@ddadbd7c40ef8b8ad6d0d01a7a842092fc431798: filtered node! This only happens when we get a binary nodeid, which means it's not string directly from the user, so it would be a programming error if it happened. It's therefore a little hard to test (I checked test-context.py, but it doesn't use obsmarkers). It looks like this has been wrong ever since dc25ed84bee8 (changectx: issue a FilteredRepoLookupError when applicable, 2014-10-15). Differential Revision: https://phab.mercurial-scm.org/D3144
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29444
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     1
#ifndef _HG_COMPAT_H_
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     2
#define _HG_COMPAT_H_
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     3
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     4
#ifdef _WIN32
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     5
#ifdef _MSC_VER
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     6
/* msvc 6.0 has problems */
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
     7
#define inline __inline
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
     8
#if defined(_WIN64)
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
     9
typedef __int64 ssize_t;
33926
f4433f2713d0 encoding: add function to test if a str consists of ASCII characters
Yuya Nishihara <yuya@tcha.org>
parents: 29549
diff changeset
    10
typedef unsigned __int64 uintptr_t;
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
    11
#else
29549
7b22599dcb85 compat: define ssize_t as int on 32bit Windows, silences C4142 warning
Yuya Nishihara <yuya@tcha.org>
parents: 29521
diff changeset
    12
typedef int ssize_t;
33926
f4433f2713d0 encoding: add function to test if a str consists of ASCII characters
Yuya Nishihara <yuya@tcha.org>
parents: 29549
diff changeset
    13
typedef unsigned int uintptr_t;
29521
83147ff53112 compat: provide a declaration of ssize_t, for MS windows
Maciej Fijalkowski <fijall@gmail.com>
parents: 29444
diff changeset
    14
#endif
29444
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    15
typedef signed char int8_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    16
typedef short int16_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    17
typedef long int32_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    18
typedef __int64 int64_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    19
typedef unsigned char uint8_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    20
typedef unsigned short uint16_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    21
typedef unsigned long uint32_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    22
typedef unsigned __int64 uint64_t;
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    23
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    24
#include <stdint.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    25
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    26
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    27
/* not windows */
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    28
#include <sys/types.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    29
#if defined __BEOS__ && !defined __HAIKU__
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    30
#include <ByteOrder.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    31
#else
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    32
#include <arpa/inet.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    33
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    34
#include <inttypes.h>
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    35
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    36
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    37
#if defined __hpux || defined __SUNPRO_C || defined _AIX
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    38
#define inline
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    39
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    40
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    41
#ifdef __linux
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    42
#define inline __inline
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    43
#endif
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    44
284d742e5611 internals: move the bitmanipulation routines into its own file
Maciej Fijalkowski <fijall@gmail.com>
parents:
diff changeset
    45
#endif