66# Summary
77[ summary ] : #summary
88
9- This RFC proposes the concept of * augmenting sources* for Cargo. Sources can be
9+ This RFC proposes the concept of * patching sources* for Cargo. Sources can be
1010have their existing versions of crates replaced with different copies, and
1111sources can also have "prepublished" crates by adding versions of a crate which
1212do not currently exist in the source. Dependency resolution will work * as if*
@@ -75,32 +75,32 @@ publication to crates.io.
7575[ design ] : #detailed-design
7676
7777The design itself is relatively straightforward. The Cargo.toml file will
78- support a new section for augmenting a source of crates:
78+ support a new section for patching a source of crates:
7979
8080``` toml
81- [augment .crates-io ]
81+ [patch .crates-io ]
8282xml-rs = { path = " path/to/fork" }
8383```
8484
8585The listed dependencies have the same syntax as the normal ` [dependencies] `
8686section, but they must all come form a different source than the source being
87- augmented . For example you can't augment crates.io with other crates from
87+ patched . For example you can't patch crates.io with other crates from
8888crates.io! Cargo will load the crates and extract the version information for
8989each dependency's name, supplementing the source specified with the version it
9090finds. If the same name/version pair * already* exists in the source being
91- augmented , then this will act just like ` [replace] ` , replacing its source with
92- the one specified in the ` [augment ] ` section.
91+ patched , then this will act just like ` [replace] ` , replacing its source with
92+ the one specified in the ` [patch ] ` section.
9393
94- Like ` [replace] ` , the ` [augment ] ` section is only taken into account for the
94+ Like ` [replace] ` , the ` [patch ] ` section is only taken into account for the
9595root crate (or workspace root); allowing it to accumulate anywhere in the crate
9696dependency graph creates intractable problems for dependency resolution.
9797
98- The sub-table of ` [augment ] ` (where ` crates-io ` is used above) is used to
99- specify the source that's being augmented . Cargo will know ahead of time one
98+ The sub-table of ` [patch ] ` (where ` crates-io ` is used above) is used to
99+ specify the source that's being patched . Cargo will know ahead of time one
100100identifier, literally ` crates-io ` , but otherwise this field will currently be
101101interpreted as a URL of a source. The name ` crates-io ` will correspond to the
102102crates.io index, and other urls, such as git repositories, may also be specified
103- for augmentation . Eventually it's intended we'll grow support for multiple
103+ for patching . Eventually it's intended we'll grow support for multiple
104104registries here with their own identifiers, but for now just literally
105105` crates-io ` and other URLs are allowed.
106106
@@ -121,7 +121,7 @@ With this setup, the dependency graph for Servo will contain *two* versions of
121121` 0.9.1 ` is considered a minor release against ` 0.9.0 ` , while ` 0.9.0 ` and ` 0.8.0 `
122122are incompatible.
123123
124- ### Scenario: augmenting with a bugfix
124+ ### Scenario: patching with a bugfix
125125
126126Let's say that while developing ` foo ` we've got a lock file pointing to ` xml-rs `
127127` 0.9.0 ` , and we found the ` 0.9.0 ` branch of ` xml-rs ` that hasn't been touched
@@ -132,7 +132,7 @@ First we'll check out `foo` locally and implement what we believe is a fix for
132132this bug, and next, we change ` Cargo.toml ` for ` foo ` :
133133
134134``` toml
135- [augment .crates-io ]
135+ [patch .crates-io ]
136136xml-rs = { path = " ../xml-rs" }
137137```
138138
@@ -153,7 +153,7 @@ that all of Servo compiles before pushing the changes through.
153153First, we change ` Cargo.toml ` for ` foo ` :
154154
155155``` toml
156- [augment .crates-io ]
156+ [patch .crates-io ]
157157xml-rs = { git = " https://github.com/aturon/xml-rs" , branch = " 0.9.2" }
158158
159159[dependencies ]
@@ -165,15 +165,15 @@ or introduce any `xml-rs` dependencies; it's enough to be using the fork of
165165` foo ` , which we would be anyway:
166166
167167``` toml
168- [augment .crates-io ]
168+ [patch .crates-io ]
169169xml-rs = { git = " https://github.com/aturon/xml-rs" , branch = " 0.9.2" }
170170foo = { git = " https://github.com/aturon/foo" , branch = " fix-xml" }
171171```
172172
173173Note that if Servo depended directly on ` foo ` it would also be valid to do:
174174
175175``` toml
176- [augment .crates-io ]
176+ [patch .crates-io ]
177177xml-rs = { git = " https://github.com/aturon/xml-rs" , branch = " 0.9.2" }
178178
179179[dependencies ]
@@ -195,7 +195,7 @@ want to do integration testing for (`servo`); no sibling crates needed to be
195195changed.
196196
197197Once ` xml-rs ` version ` 0.9.2 ` is actually published, we will likely be able to
198- remove the ` [augment ] ` sections. This is a discrete step that must be taken by
198+ remove the ` [patch ] ` sections. This is a discrete step that must be taken by
199199crate authors, however (e.g. doesn't happen automatically) because the actual
200200published 0.9.2 may not be precisely what we thought it was going to be. For
201201example more changes could have been merged, it may not actually fix the bug,
@@ -207,7 +207,7 @@ What happens if `foo` instead needs to make a breaking change to `xml-rs`? The
207207workflow is identical. For ` foo ` :
208208
209209``` toml
210- [augment .crates-io ]
210+ [patch .crates-io ]
211211xml-rs = { git = " https://github.com/aturon/xml-rs" , branch = " 0.10.0" }
212212
213213[dependencies ]
@@ -217,7 +217,7 @@ xml-rs = "0.10.0"
217217For ` servo ` :
218218
219219``` toml
220- [augment .crates-io ]
220+ [patch .crates-io ]
221221xml-rs = { git = " https://github.com/aturon/xml-rs" , branch = " 0.10.0" }
222222
223223[dependencies ]
@@ -238,13 +238,13 @@ error message).
238238
239239## Impact on ` Cargo.lock `
240240
241- Usage of ` [augment ] ` will perform backwards-incompatible modifications to
242- ` Cargo.lock ` , meaning that usage of ` [augment ] ` will prevent previous versions
241+ Usage of ` [patch ] ` will perform backwards-incompatible modifications to
242+ ` Cargo.lock ` , meaning that usage of ` [patch ] ` will prevent previous versions
243243of Cargo from interpreting the lock file. Cargo will unconditionally resolve all
244- entries in the ` [augment ] ` section to precise dependencies, encoding them all in
244+ entries in the ` [patch ] ` section to precise dependencies, encoding them all in
245245the lock file whether they're used or not.
246246
247- Dependencies formed on crates listed in ` [augment ] ` will then be listed directly
247+ Dependencies formed on crates listed in ` [patch ] ` will then be listed directly
248248in Cargo.lock, and the original listed crate will not be listed. In our example
249249above we had:
250250
@@ -260,7 +260,7 @@ Note, however, that the lock file will still mention `xml-rs-0.8.0` and
260260` xml-rs-0.9.1 ` because ` bar ` and ` baz ` depend on it.
261261
262262To help put some TOML where our mouth is let's say we depend on ` env_logger ` but
263- we're using ` [augment ] ` to depend on a git version of the ` log ` crate, a
263+ we're using ` [patch ] ` to depend on a git version of the ` log ` crate, a
264264dependency of ` env_logger ` . First we'll have our ` Cargo.toml ` including:
265265
266266``` toml
@@ -288,11 +288,11 @@ version = "0.3.7"
288288source = " registry+https://github.com/rust-lang/crates.io-index"
289289```
290290
291- Next up we'll add our ` [augment ] ` section to crates.io:
291+ Next up we'll add our ` [patch ] ` section to crates.io:
292292
293293``` toml
294294# Cargo.toml
295- [augment .crates-io ]
295+ [patch .crates-io ]
296296log = { git = ' https://github.com/rust-lang-nursery/log' }
297297```
298298
@@ -315,17 +315,17 @@ source = "git+https://github.com/rust-lang-nursery/log#cb9fa28812ac27c9cadc4e7b1
315315```
316316
317317Notably ` log ` from crates.io * is not mentioned at all here* , and crucially so!
318- Additionally Cargo has the fully resolved version of the ` log ` augmentation
318+ Additionally Cargo has the fully resolved version of the ` log ` patch
319319available to it, down to the sha of what to check out.
320320
321321When Cargo rebuilds from this ` Cargo.lock ` it will not query the registry for
322322versions of ` log ` , instead seeing that there's an exact dependency on the git
323- repository (from the ` Cargo.lock ` ) and the repository is listed as an
324- augmentation , so it'll follow that pointer.
323+ repository (from the ` Cargo.lock ` ) and the repository is listed as a
324+ patch , so it'll follow that pointer.
325325
326326## Impact on ` [replace] `
327327
328- The ` [augment ] ` section in the manifest can in many ways be seen as a "replace
328+ The ` [patch ] ` section in the manifest can in many ways be seen as a "replace
3293292.0". It is, in fact, strictly more expressive than the current ` [replace] `
330330section! For example these two sections are equivalent:
331331
@@ -335,30 +335,30 @@ section! For example these two sections are equivalent:
335335
336336# is the same as...
337337
338- [augment .crates-io ]
338+ [patch .crates-io ]
339339log = { git = ' https://github.com/rust-lang-nursery/log' }
340340```
341341
342- This is not accidental! The intial development of the ` [augment ] ` feature was
342+ This is not accidental! The intial development of the ` [patch ] ` feature was
343343actually focused on prepublishing dependencies and was called ` [prepublish] ` ,
344344but while discussing it a conclusion was reached that ` [prepublish] ` already
345345allowed replacing existing versions in a registry, but issued a warning when
346346doing so. It turned out that without a warning we ended up having a full-on
347347` [replace] ` replacement!
348348
349349At this time, though, it is not planned to deprecate the ` [replace] ` section,
350- nor remove it. After the ` [augment ] ` section is implemented, if it ends up
351- working out this may change. If after a few cycles on stable the ` [augment ] `
350+ nor remove it. After the ` [patch ] ` section is implemented, if it ends up
351+ working out this may change. If after a few cycles on stable the ` [patch ] `
352352section seems to be working well we can issue an official deprecation for
353353` [replace] ` , printing a warning if it's still used.
354354
355- Documentation, however, will immediately begin to recommend ` [augment ] ` over
355+ Documentation, however, will immediately begin to recommend ` [patch ] ` over
356356` [replace] ` .
357357
358358# How We Teach This
359359[ how-we-teach-this ] : #how-we-teach-this
360360
361- Augmentation is a feature intended for large-scale projects spanning many repos
361+ Patching is a feature intended for large-scale projects spanning many repos
362362and crates, where you want to make something like an atomic change across the
363363repos. As such, it should likely be explained in a dedicated section for
364364large-scale Cargo usage, which would also include build system integration and
@@ -369,8 +369,8 @@ this RFC) is generally enough to explain it. In the docs, these examples should
369369be spelled out in greater detail.
370370
371371Most notably, however, the [ overriding dependenices] [ over ] section of Cargo's
372- documentation will be rewritten to primarily mention ` [augment ] ` , but
373- ` [replace] ` will be mentioned still with a recommendation to use ` [augment ] `
372+ documentation will be rewritten to primarily mention ` [patch ] ` , but
373+ ` [replace] ` will be mentioned still with a recommendation to use ` [patch ] `
374374instead if possible.
375375
376376[ over ] : http://doc.crates.io/specifying-dependencies.html#overriding-dependencies
0 commit comments