[PATCH 01 of 13] rust-chg: add project skeleton

Yuya Nishihara yuya at tcha.org
Tue Oct 2 14:25:40 UTC 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1537772058 -32400
#      Mon Sep 24 15:54:18 2018 +0900
# Node ID 4cb12a1e78262428caec486fde361e562a205f63
# Parent  1a7d901a0a0c6c93e738595b6b3ea59d3d04fdf2
rust-chg: add project skeleton

This directory will host the reimplementation of cHg in Rust. It will use
Tokio [1], and tokio-hglib [2] which I wrote for an oxidized CHg, no idea
if there's such carbon bonding in nature btw.

 [1]: https://tokio.rs/
 [2]: https://bitbucket.org/yuja/tokio-hglib/

The reasoning for depending on Tokio is that it will allow us to handle Unix
signals in a safer way. Well, I believed that until I found a weird function,
handlestopsignal(), in cHg codebase. It resends the same signal to the same
process by temporarily masking the handler, which can't be inherently async.
So the signal handlers will stay in C, which means there isn't actually much
reason to write async code right now, other than I've already done most of
the async stuff, and slightly easier pager handling.

The reasoning for the rewrite is that it will eventually be possible to port
server-side config validation back to the client side, which will reduce
the complexity of the current daemon management. It will also encourage us
to write frontend library (e.g. command line and config parsers) in Rust.

The license is GPL2+ because it's likely to include derived work from the
cHg of C. The rust/chg crate is excluded from the root workspace as it's
unclear how the whole rust packages should be laid out. That can be revisited
later.

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -56,6 +56,7 @@ locale/*/LC_MESSAGES/hg.mo
 hgext/__index__.py
 
 rust/target/
+rust/*/target/
 
 # Generated wheels
 wheelhouse/
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -1,2 +1,3 @@
 [workspace]
 members = ["hgcli"]
+exclude = ["chg"]
diff --git a/rust/chg/Cargo.toml b/rust/chg/Cargo.toml
new file mode 100644
--- /dev/null
+++ b/rust/chg/Cargo.toml
@@ -0,0 +1,18 @@
+[package]
+name = "chg"
+version = "0.1.0"
+authors = ["Yuya Nishihara <yuya at tcha.org>"]
+description = "Client for Mercurial command server with cHg extension"
+license = "GPL-2.0+"
+
+[dependencies]
+bytes = "0.4"
+futures = "0.1"
+libc = "0.2"
+tokio = "0.1"
+tokio-hglib = "0.2"
+# TODO: "^0.2.3" once released. we need AsRawFd support.
+tokio-process = { git = "https://github.com/alexcrichton/tokio-process" }
+
+[build-dependencies]
+cc = "1.0"
diff --git a/rust/chg/src/lib.rs b/rust/chg/src/lib.rs
new file mode 100644
diff --git a/rust/chg/src/main.rs b/rust/chg/src/main.rs
new file mode 100644
--- /dev/null
+++ b/rust/chg/src/main.rs
@@ -0,0 +1,7 @@
+// Copyright 2018 Yuya Nishihara <yuya at tcha.org>
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+fn main() {
+}


More information about the Mercurial-devel mailing list