##// END OF EJS Templates
subrepo: add git to the help topic
Matt Mackall -
r15213:15f15f3b default
parent child Browse files
Show More
@@ -1,130 +1,134 b''
1 Subrepositories let you nest external repositories or projects into a
1 Subrepositories let you nest external repositories or projects into a
2 parent Mercurial repository, and make commands operate on them as a
2 parent Mercurial repository, and make commands operate on them as a
3 group. External Mercurial and Subversion projects are currently
3 group.
4 supported.
4
5 Mercurial currently supports Mercurial, Git, and Subversion
6 subrepositories.
5
7
6 Subrepositories are made of three components:
8 Subrepositories are made of three components:
7
9
8 1. Nested repository checkouts. They can appear anywhere in the
10 1. Nested repository checkouts. They can appear anywhere in the
9 parent working directory, and are Mercurial clones or Subversion
11 parent working directory.
10 checkouts.
11
12
12 2. Nested repository references. They are defined in ``.hgsub`` and
13 2. Nested repository references. They are defined in ``.hgsub`` and
13 tell where the subrepository checkouts come from. Mercurial
14 tell where the subrepository checkouts come from. Mercurial
14 subrepositories are referenced like:
15 subrepositories are referenced like:
15
16
16 path/to/nested = https://example.com/nested/repo/path
17 path/to/nested = https://example.com/nested/repo/path
17
18
19 Git and Subversion subrepos are also supported:
20
21 path/to/nested = [git]git://example.com/nested/repo/path
22 path/to/nested = [svn]https://example.com/nested/trunk/path
23
18 where ``path/to/nested`` is the checkout location relatively to the
24 where ``path/to/nested`` is the checkout location relatively to the
19 parent Mercurial root, and ``https://example.com/nested/repo/path``
25 parent Mercurial root, and ``https://example.com/nested/repo/path``
20 is the source repository path. The source can also reference a
26 is the source repository path. The source can also reference a
21 filesystem path. Subversion repositories are defined with:
27 filesystem path.
22
23 path/to/nested = [svn]https://example.com/nested/trunk/path
24
28
25 Note that ``.hgsub`` does not exist by default in Mercurial
29 Note that ``.hgsub`` does not exist by default in Mercurial
26 repositories, you have to create and add it to the parent
30 repositories, you have to create and add it to the parent
27 repository before using subrepositories.
31 repository before using subrepositories.
28
32
29 3. Nested repository states. They are defined in ``.hgsubstate`` and
33 3. Nested repository states. They are defined in ``.hgsubstate`` and
30 capture whatever information is required to restore the
34 capture whatever information is required to restore the
31 subrepositories to the state they were committed in a parent
35 subrepositories to the state they were committed in a parent
32 repository changeset. Mercurial automatically record the nested
36 repository changeset. Mercurial automatically record the nested
33 repositories states when committing in the parent repository.
37 repositories states when committing in the parent repository.
34
38
35 .. note::
39 .. note::
36 The ``.hgsubstate`` file should not be edited manually.
40 The ``.hgsubstate`` file should not be edited manually.
37
41
38
42
39 Adding a Subrepository
43 Adding a Subrepository
40 ----------------------
44 ----------------------
41
45
42 If ``.hgsub`` does not exist, create it and add it to the parent
46 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
47 repository. Clone or checkout the external projects where you want it
44 to live in the parent repository. Edit ``.hgsub`` and add the
48 to live in the parent repository. Edit ``.hgsub`` and add the
45 subrepository entry as described above. At this point, the
49 subrepository entry as described above. At this point, the
46 subrepository is tracked and the next commit will record its state in
50 subrepository is tracked and the next commit will record its state in
47 ``.hgsubstate`` and bind it to the committed changeset.
51 ``.hgsubstate`` and bind it to the committed changeset.
48
52
49 Synchronizing a Subrepository
53 Synchronizing a Subrepository
50 -----------------------------
54 -----------------------------
51
55
52 Subrepos do not automatically track the latest changeset of their
56 Subrepos do not automatically track the latest changeset of their
53 sources. Instead, they are updated to the changeset that corresponds
57 sources. Instead, they are updated to the changeset that corresponds
54 with the changeset checked out in the top-level changeset. This is so
58 with the changeset checked out in the top-level changeset. This is so
55 developers always get a consistent set of compatible code and
59 developers always get a consistent set of compatible code and
56 libraries when they update.
60 libraries when they update.
57
61
58 Thus, updating subrepos is a manual process. Simply check out target
62 Thus, updating subrepos is a manual process. Simply check out target
59 subrepo at the desired revision, test in the top-level repo, then
63 subrepo at the desired revision, test in the top-level repo, then
60 commit in the parent repository to record the new combination.
64 commit in the parent repository to record the new combination.
61
65
62 Deleting a Subrepository
66 Deleting a Subrepository
63 ------------------------
67 ------------------------
64
68
65 To remove a subrepository from the parent repository, delete its
69 To remove a subrepository from the parent repository, delete its
66 reference from ``.hgsub``, then remove its files.
70 reference from ``.hgsub``, then remove its files.
67
71
68 Interaction with Mercurial Commands
72 Interaction with Mercurial Commands
69 -----------------------------------
73 -----------------------------------
70
74
71 :add: add does not recurse in subrepos unless -S/--subrepos is
75 :add: add does not recurse in subrepos unless -S/--subrepos is
72 specified. Subversion subrepositories are currently silently
76 specified. Subversion subrepositories are currently silently
73 ignored.
77 ignored.
74
78
75 :archive: archive does not recurse in subrepositories unless
79 :archive: archive does not recurse in subrepositories unless
76 -S/--subrepos is specified.
80 -S/--subrepos is specified.
77
81
78 :commit: commit creates a consistent snapshot of the state of the
82 :commit: commit creates a consistent snapshot of the state of the
79 entire project and its subrepositories. It does this by first
83 entire project and its subrepositories. It does this by first
80 attempting to commit all modified subrepositories, then recording
84 attempting to commit all modified subrepositories, then recording
81 their state and finally committing it in the parent
85 their state and finally committing it in the parent
82 repository. Mercurial can be made to abort if any subrepository
86 repository. Mercurial can be made to abort if any subrepository
83 content is modified by setting "ui.commitsubrepos=no" in a
87 content is modified by setting "ui.commitsubrepos=no" in a
84 configuration file (see :hg:`help config`).
88 configuration file (see :hg:`help config`).
85
89
86 :diff: diff does not recurse in subrepos unless -S/--subrepos is
90 :diff: diff does not recurse in subrepos unless -S/--subrepos is
87 specified. Changes are displayed as usual, on the subrepositories
91 specified. Changes are displayed as usual, on the subrepositories
88 elements. Subversion subrepositories are currently silently
92 elements. Subversion subrepositories are currently silently
89 ignored.
93 ignored.
90
94
91 :incoming: incoming does not recurse in subrepos unless -S/--subrepos
95 :incoming: incoming does not recurse in subrepos unless -S/--subrepos
92 is specified. Subversion subrepositories are currently silently
96 is specified. Subversion subrepositories are currently silently
93 ignored.
97 ignored.
94
98
95 :outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
99 :outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
96 is specified. Subversion subrepositories are currently silently
100 is specified. Subversion subrepositories are currently silently
97 ignored.
101 ignored.
98
102
99 :pull: pull is not recursive since it is not clear what to pull prior
103 :pull: pull is not recursive since it is not clear what to pull prior
100 to running :hg:`update`. Listing and retrieving all
104 to running :hg:`update`. Listing and retrieving all
101 subrepositories changes referenced by the parent repository pulled
105 subrepositories changes referenced by the parent repository pulled
102 changesets is expensive at best, impossible in the Subversion
106 changesets is expensive at best, impossible in the Subversion
103 case.
107 case.
104
108
105 :push: Mercurial will automatically push all subrepositories first
109 :push: Mercurial will automatically push all subrepositories first
106 when the parent repository is being pushed. This ensures new
110 when the parent repository is being pushed. This ensures new
107 subrepository changes are available when referenced by top-level
111 subrepository changes are available when referenced by top-level
108 repositories.
112 repositories.
109
113
110 :status: status does not recurse into subrepositories unless
114 :status: status does not recurse into subrepositories unless
111 -S/--subrepos is specified. Subrepository changes are displayed as
115 -S/--subrepos is specified. Subrepository changes are displayed as
112 regular Mercurial changes on the subrepository
116 regular Mercurial changes on the subrepository
113 elements. Subversion subrepositories are currently silently
117 elements. Subversion subrepositories are currently silently
114 ignored.
118 ignored.
115
119
116 :update: update restores the subrepos in the state they were
120 :update: update restores the subrepos in the state they were
117 originally committed in target changeset. If the recorded
121 originally committed in target changeset. If the recorded
118 changeset is not available in the current subrepository, Mercurial
122 changeset is not available in the current subrepository, Mercurial
119 will pull it in first before updating. This means that updating
123 will pull it in first before updating. This means that updating
120 can require network access when using subrepositories.
124 can require network access when using subrepositories.
121
125
122 Remapping Subrepositories Sources
126 Remapping Subrepositories Sources
123 ---------------------------------
127 ---------------------------------
124
128
125 A subrepository source location may change during a project life,
129 A subrepository source location may change during a project life,
126 invalidating references stored in the parent repository history. To
130 invalidating references stored in the parent repository history. To
127 fix this, rewriting rules can be defined in parent repository ``hgrc``
131 fix this, rewriting rules can be defined in parent repository ``hgrc``
128 file or in Mercurial configuration. See the ``[subpaths]`` section in
132 file or in Mercurial configuration. See the ``[subpaths]`` section in
129 hgrc(5) for more details.
133 hgrc(5) for more details.
130
134
General Comments 0
You need to be logged in to leave comments. Login now