Debian Codegraph @

doc/html/topic-rust.html

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" />
7 <title>Rust in Mercurial</title>
8 <link rel="stylesheet" href="../style.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="rust-in-mercurial">
12 <span id="topic-rust"></span>
13 <h1 class="title">Rust in Mercurial</h1>
14
15 <div class="contents htmlonly topic" id="contents">
16 <p class="topic-title"><a class="reference internal" href="#top">Contents</a></p>
17 <ul class="simple">
18 <li><a class="reference internal" href="#word-of-caution" id="toc-entry-1">Word of Caution</a></li>
19 <li><a class="reference internal" href="#compatibility" id="toc-entry-2">Compatibility</a></li>
20 <li><a class="reference internal" href="#features" id="toc-entry-3">Features</a></li>
21 <li><a class="reference internal" href="#checking-for-rust" id="toc-entry-4">Checking for Rust</a></li>
22 <li><a class="reference internal" href="#installing" id="toc-entry-5">Installing</a><ul>
23 <li><a class="reference internal" href="#using-pip" id="toc-entry-6">Using pip</a></li>
24 <li><a class="reference internal" href="#using-pipx" id="toc-entry-7">Using pipx</a></li>
25 <li><a class="reference internal" href="#using-uv-tool" id="toc-entry-8">Using uv tool</a></li>
26 <li><a class="reference internal" href="#from-your-distribution" id="toc-entry-9">From your distribution</a></li>
27 <li><a class="reference internal" href="#from-source" id="toc-entry-10">From source</a></li>
28 </ul>
29 </li>
30 <li><a class="reference internal" href="#msrv" id="toc-entry-11">MSRV</a></li>
31 <li><a class="reference internal" href="#rhg-1" id="toc-entry-12">rhg</a></li>
32 <li><a class="reference internal" href="#contributing" id="toc-entry-13">Contributing</a></li>
33 </ul>
34 </div>
35 <p id="rhg"><span id="rustext"></span><span id="rust"></span>Mercurial can be augmented with Rust extensions for speeding up certain
36 operations.</p>
37 <div class="section" id="word-of-caution">
38 <h1><a class="toc-backref" href="#contents">Word of Caution</a></h1>
39 <p>Using the Rust extension might result in the use of various repository formats
40 that are not supported by non-Rust mercurial. When using a Mercurial
41 without Rust support on the same repositories, you might need to downgrade your
42 repository formats and/or activate cripplingly slow paths for compatibility.
43 For details, see:</p>
44 <blockquote>
45 <ul class="simple">
46 <li><a class="reference external" href="hgrc.5.html#format"><tt class="docutils literal">hg help <span class="pre">config.format.use-persistent-nodemap</span></tt></a></li>
47 <li><a class="reference external" href="hgrc.5.html#format"><tt class="docutils literal">hg help <span class="pre">config.format.use-dirstate-v2</span></tt></a></li>
48 </ul>
49 </blockquote>
50 <p>In addition, while the tests are run with the Rust code, there might be
51 subtle undetected divergences from the historical non-Rust code. So keep
52 your eyes open and report any oddity. Rust is not considered a first class
53 citizen to the project yet.</p>
54 </div>
55 <div class="section" id="compatibility">
56 <h1><a class="toc-backref" href="#contents">Compatibility</a></h1>
57 <p>Though the Rust extensions are only tested by the project under Linux, users of
58 MacOS, FreeBSD and other UNIX-likes have been using the Rust extensions. Your
59 mileage may vary, but by all means do give us feedback or signal your interest
60 for better support.</p>
61 <p>For compatibility with non-Rust version of Mercurial check the previous &quot;Word of
62 Caution&quot; section.</p>
63 <p>No Rust extensions are available for Windows at this time.</p>
64 </div>
65 <div class="section" id="features">
66 <h1><a class="toc-backref" href="#contents">Features</a></h1>
67 <p>The following operations are sped up when using Rust:</p>
68 <blockquote>
69 <ul class="simple">
70 <li>discovery of differences between repositories (pull/push)</li>
71 <li>nodemap (see <a class="reference external" href="hgrc.5.html#format"><tt class="docutils literal">hg help <span class="pre">config.format.use-persistent-nodemap</span></tt></a>)</li>
72 <li>all commands using the dirstate (status, commit, diff, add, update, etc.)</li>
73 <li>dirstate-v2 (see <a class="reference external" href="hgrc.5.html#format"><tt class="docutils literal">hg help <span class="pre">config.format.use-dirstate-v2</span></tt></a>)</li>
74 <li>iteration over ancestors in a graph</li>
75 </ul>
76 </blockquote>
77 <p>More features are in the works, and improvements on the above listed are still
78 in progress. For more experimental work see the &quot;rhg&quot; section.</p>
79 </div>
80 <div class="section" id="checking-for-rust">
81 <h1><a class="toc-backref" href="#contents">Checking for Rust</a></h1>
82 <p>You may already have the Rust extensions depending on how you install
83 Mercurial:</p>
84 <pre class="literal-block">
85 $ hg debuginstall | grep -i rust
86 checking Rust extensions (installed)
87 checking module policy (rust+c-allow)
88 </pre>
89 <p>If those lines don't even exist, you're using an old version of <cite>hg</cite> which does
90 not have any Rust extensions yet.</p>
91 </div>
92 <div class="section" id="installing">
93 <h1><a class="toc-backref" href="#contents">Installing</a></h1>
94 <p>You will need <cite>cargo</cite> to be in your <cite>$PATH</cite>. See the &quot;MSRV&quot; section for which
95 version to use.</p>
96 <div class="section" id="using-pip">
97 <h2><a class="toc-backref" href="#contents">Using pip</a></h2>
98 <p>Users of <cite>pip</cite> can install the Rust extensions with the following commands:</p>
99 <pre class="literal-block">
100 $ pip cache remove mercurial
101 $ pip install mercurial -v \
102 --config-settings --global-option=--rust \
103 --no-binary mercurial --force
104 </pre>
105 <p><cite>pip cache remove</cite> and <cite>--no-binary</cite> are there to tell pip to not use the
106 pre-compiled wheels that are missing rust support. This might take a couple
107 of minutes because you're compiling everything.</p>
108 <p>See the &quot;Checking for Rust&quot; section to see if the install succeeded.</p>
109 </div>
110 <div class="section" id="using-pipx">
111 <h2><a class="toc-backref" href="#contents">Using pipx</a></h2>
112 <p>Using pipx is an efficient way to get an isolated installation of mercurial
113 available for a user or globally.</p>
114 <blockquote>
115 <dl class="docutils">
116 <dt>$ pipx install mercurial </dt>
117 <dd>--pip-args '--no-cache-dir --config-settings --global-option=--rust --no-binary=mercurial'</dd>
118 </dl>
119 </blockquote>
120 <p>You can then add extensions to that install using</p>
121 <blockquote>
122 $ pipx inject mercurial hg-foo</blockquote>
123 </div>
124 <div class="section" id="using-uv-tool">
125 <h2><a class="toc-backref" href="#contents">Using uv tool</a></h2>
126 <p>Using <cite>uv tool</cite> is another efficient way to get an isolated installation of
127 mercurial available for a user or globally.</p>
128 <blockquote>
129 <dl class="docutils">
130 <dt>$ uv tool install mercurial </dt>
131 <dd>--no-binary=mercurial --no-cache --config-setting=--build-option=--rust</dd>
132 </dl>
133 </blockquote>
134 <p>You can bring extensions along using the <cite>--with</cite> flag. For example</p>
135 <blockquote>
136 $ uv tool install mercurial --with hg-evolve [...]</blockquote>
137 </div>
138 <div class="section" id="from-your-distribution">
139 <h2><a class="toc-backref" href="#contents">From your distribution</a></h2>
140 <p>Some distributions are shipping Mercurial with Rust extensions enabled and
141 pre-compiled (meaning you won't have to install <cite>cargo</cite>), or allow you to
142 specify an install flag. Check with your specific distribution for how to do
143 that, or ask their team to add support for hg+Rust!</p>
144 </div>
145 <div class="section" id="from-source">
146 <h2><a class="toc-backref" href="#contents">From source</a></h2>
147 <p>Please refer to the <cite>rust/README.md</cite> file in the Mercurial repository for
148 instructions on how to install from source.</p>
149 </div>
150 </div>
151 <div class="section" id="msrv">
152 <h1><a class="toc-backref" href="#contents">MSRV</a></h1>
153 <p>The minimum supported Rust version is defined in <cite>rust/clippy.toml</cite>.
154 The project's policy is to keep it at or below the version from Debian testing,
155 to make the distributions' job easier.</p>
156 </div>
157 <div class="section" id="rhg-1">
158 <h1><a class="toc-backref" href="#contents">rhg</a></h1>
159 <p>There exists an experimental pure-Rust version of Mercurial called <cite>rhg</cite> with a
160 fallback mechanism for unsupported invocations. It allows for much faster
161 execution of certain commands while adding no discernable overhead for the rest.</p>
162 <p>The only way of trying it out is by building it from source. Please refer to
163 <cite>rust/README.md</cite> in the Mercurial repository.</p>
164 <p>See <cite>hg help config.rhg</cite> for configuration options.</p>
165 </div>
166 <div class="section" id="contributing">
167 <h1><a class="toc-backref" href="#contents">Contributing</a></h1>
168 <p>If you would like to help the Rust endeavor, please refer to <cite>rust/README.md</cite>
169 in the Mercurial repository.</p>
170 </div>
171 </div>
172 </body>
173 </html>