Mercurial > hg
annotate mercurial/help/subrepos.txt @ 13411:d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
The default behaviour is to commit subrepositories with uncommitted changes. In
my experience this is usually undesirable:
- Changes to dependencies are often debugging leftovers
- Real changes should generally be applied on the source project directly,
tested then committed. This is not always possible, subversion subrepos may
include only a small part of the source project, without the tests.
Setting ui.commitsubrepos=no will now abort commits containing such modified
subrepositories like:
$ hg --config ui.commitsubrepos=no ci -m msg
abort: uncommitted changes in subrepo sub
I ruled out the hook solution because it does not easily take --include/exclude
options in account. Also, my main concern is whether this flag could cause
problems with extensions. If there are legitimate reasons for callers to
override this behaviour (I could not find any), they might either override at ui
level, or we could add an argument to localrepo.commit() later.
v2:
- Renamed ui.commitsubs to ui.commitsubrepos
- Mention the configuration entry in hg help subrepos
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Tue, 15 Feb 2011 22:25:48 +0100 |
parents | db2ff771204d |
children | 15f15f3b405d |
rev | line source |
---|---|
12828 | 1 Subrepositories let you nest external repositories or projects into a |
2 parent Mercurial repository, and make commands operate on them as a | |
3 group. External Mercurial and Subversion projects are currently | |
4 supported. | |
5 | |
6 Subrepositories are made of three components: | |
7 | |
8 1. Nested repository checkouts. They can appear anywhere in the | |
9 parent working directory, and are Mercurial clones or Subversion | |
10 checkouts. | |
11 | |
12 2. Nested repository references. They are defined in ``.hgsub`` and | |
13 tell where the subrepository checkouts come from. Mercurial | |
14 subrepositories are referenced like: | |
15 | |
16 path/to/nested = https://example.com/nested/repo/path | |
17 | |
18 where ``path/to/nested`` is the checkout location relatively to the | |
19 parent Mercurial root, and ``https://example.com/nested/repo/path`` | |
20 is the source repository path. The source can also reference a | |
21 filesystem path. Subversion repositories are defined with: | |
22 | |
23 path/to/nested = [svn]https://example.com/nested/trunk/path | |
24 | |
25 Note that ``.hgsub`` does not exist by default in Mercurial | |
26 repositories, you have to create and add it to the parent | |
27 repository before using subrepositories. | |
28 | |
29 3. Nested repository states. They are defined in ``.hgsubstate`` and | |
30 capture whatever information is required to restore the | |
31 subrepositories to the state they were committed in a parent | |
32 repository changeset. Mercurial automatically record the nested | |
33 repositories states when committing in the parent repository. | |
34 | |
35 .. note:: | |
36 The ``.hgsubstate`` file should not be edited manually. | |
37 | |
38 | |
39 Adding a Subrepository | |
40 ---------------------- | |
41 | |
42 If ``.hgsub`` does not exist, create it and add it to the parent | |
43 repository. Clone or checkout the external projects where you want it | |
44 to live in the parent repository. Edit ``.hgsub`` and add the | |
45 subrepository entry as described above. At this point, the | |
46 subrepository is tracked and the next commit will record its state in | |
47 ``.hgsubstate`` and bind it to the committed changeset. | |
48 | |
49 Synchronizing a Subrepository | |
50 ----------------------------- | |
51 | |
52 Subrepos do not automatically track the latest changeset of their | |
53 sources. Instead, they are updated to the changeset that corresponds | |
54 with the changeset checked out in the top-level changeset. This is so | |
55 developers always get a consistent set of compatible code and | |
56 libraries when they update. | |
57 | |
58 Thus, updating subrepos is a manual process. Simply check out target | |
59 subrepo at the desired revision, test in the top-level repo, then | |
60 commit in the parent repository to record the new combination. | |
61 | |
62 Deleting a Subrepository | |
63 ------------------------ | |
64 | |
12860
db2ff771204d
help: correct tip about deleting a subrepository
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
12828
diff
changeset
|
65 To remove a subrepository from the parent repository, delete its |
db2ff771204d
help: correct tip about deleting a subrepository
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
12828
diff
changeset
|
66 reference from ``.hgsub``, then remove its files. |
12828 | 67 |
68 Interaction with Mercurial Commands | |
69 ----------------------------------- | |
70 | |
71 :add: add does not recurse in subrepos unless -S/--subrepos is | |
72 specified. Subversion subrepositories are currently silently | |
73 ignored. | |
74 | |
75 :archive: archive does not recurse in subrepositories unless | |
76 -S/--subrepos is specified. | |
77 | |
78 :commit: commit creates a consistent snapshot of the state of the | |
79 entire project and its subrepositories. It does this by first | |
80 attempting to commit all modified subrepositories, then recording | |
13411
d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
Patrick Mezard <pmezard@gmail.com>
parents:
12860
diff
changeset
|
81 their state and finally committing it in the parent |
d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
Patrick Mezard <pmezard@gmail.com>
parents:
12860
diff
changeset
|
82 repository. Mercurial can be made to abort if any subrepository |
d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
Patrick Mezard <pmezard@gmail.com>
parents:
12860
diff
changeset
|
83 content is modified by setting "ui.commitsubrepos=no" in a |
d4de90a612f7
commit: abort if a subrepo is modified and ui.commitsubrepos=no
Patrick Mezard <pmezard@gmail.com>
parents:
12860
diff
changeset
|
84 configuration file (see :hg:`help config`). |
12828 | 85 |
86 :diff: diff does not recurse in subrepos unless -S/--subrepos is | |
87 specified. Changes are displayed as usual, on the subrepositories | |
88 elements. Subversion subrepositories are currently silently | |
89 ignored. | |
90 | |
91 :incoming: incoming does not recurse in subrepos unless -S/--subrepos | |
92 is specified. Subversion subrepositories are currently silently | |
93 ignored. | |
94 | |
95 :outgoing: outgoing does not recurse in subrepos unless -S/--subrepos | |
96 is specified. Subversion subrepositories are currently silently | |
97 ignored. | |
98 | |
99 :pull: pull is not recursive since it is not clear what to pull prior | |
100 to running :hg:`update`. Listing and retrieving all | |
101 subrepositories changes referenced by the parent repository pulled | |
102 changesets is expensive at best, impossible in the Subversion | |
103 case. | |
104 | |
105 :push: Mercurial will automatically push all subrepositories first | |
106 when the parent repository is being pushed. This ensures new | |
107 subrepository changes are available when referenced by top-level | |
108 repositories. | |
109 | |
110 :status: status does not recurse into subrepositories unless | |
111 -S/--subrepos is specified. Subrepository changes are displayed as | |
112 regular Mercurial changes on the subrepository | |
113 elements. Subversion subrepositories are currently silently | |
114 ignored. | |
115 | |
116 :update: update restores the subrepos in the state they were | |
117 originally committed in target changeset. If the recorded | |
118 changeset is not available in the current subrepository, Mercurial | |
119 will pull it in first before updating. This means that updating | |
120 can require network access when using subrepositories. | |
121 | |
122 Remapping Subrepositories Sources | |
123 --------------------------------- | |
124 | |
125 A subrepository source location may change during a project life, | |
126 invalidating references stored in the parent repository history. To | |
127 fix this, rewriting rules can be defined in parent repository ``hgrc`` | |
128 file or in Mercurial configuration. See the ``[subpaths]`` section in | |
129 hgrc(5) for more details. | |
130 |