rust-node: binary Node ID and conversion utilities
The choice of type makes sure that a `Node` has the exact
wanted size. We'll use a different type for prefixes.
Added dependency: hexadecimal conversion relies on the
`hex` crate.
The fact that sooner or later Mercurial is going to need
to change its hash sizes has been taken strongly in
consideration:
- the hash length is a constant, but that is not directly
exposed to callers. Changing the value of that constant
is the only thing to do to change the hash length (even
in unit tests)
- the code could be adapted to support several sizes of hashes,
if that turned out to be useful. To that effect, only the
size of a given `Node` is exposed in the public API.
- callers not involved in initial computation, I/O and FFI
are able to operate without a priori assumptions on the hash
size. The traits `FromHex` and `ToHex` have not been directly
implemented, so that the doc-comments explaining these
restrictions would stay really visible in `cargo doc`
Differential Revision: https://phab.mercurial-scm.org/D7788
TARGET = chg
SRCS = chg.c hgclient.c procutil.c util.c
OBJS = $(SRCS:.c=.o)
CFLAGS ?= -O2 -Wall -Wextra -pedantic -g
CPPFLAGS ?= -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
override CFLAGS += -std=gnu99
ifdef HGPATH
override CPPFLAGS += -DHGPATH=\"$(HGPATH)\"
endif
DESTDIR =
PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man/man1
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
chg.o: hgclient.h procutil.h util.h
hgclient.o: hgclient.h procutil.h util.h
procutil.o: procutil.h util.h
util.o: util.h
.PHONY: install
install: $(TARGET)
install -d "$(DESTDIR)$(PREFIX)"/bin
install -m 755 "$(TARGET)" "$(DESTDIR)$(PREFIX)"/bin
install -d "$(DESTDIR)$(MANDIR)"
install -m 644 chg.1 "$(DESTDIR)$(MANDIR)"
.PHONY: clean
clean:
$(RM) $(OBJS)
.PHONY: distclean
distclean:
$(RM) $(OBJS) $(TARGET)