Show More
@@ -590,22 +590,36 def clone(ui, source, dest=None, **opts) | |||
|
590 | 590 | The location of the source is added to the new repository's |
|
591 | 591 | .hg/hgrc file, as the default to be used for future pulls. |
|
592 | 592 | |
|
593 | If you use the -r/--rev option to clone up to a specific revision, | |
|
594 | no subsequent revisions (including subsequent tags) will be | |
|
595 | present in the cloned repository. This option implies --pull, even | |
|
596 | on local repositories. | |
|
597 | ||
|
598 | By default, clone will check out the head of the 'default' branch. | |
|
599 | If the -U/--noupdate option is used, the new clone will contain | |
|
600 | only a repository (.hg) and no working copy (the working copy | |
|
601 | parent is the null revision). | |
|
602 | ||
|
603 | 593 | See 'hg help urls' for valid source format details. |
|
604 | 594 | |
|
605 | 595 | It is possible to specify an ssh:// URL as the destination, but no |
|
606 | 596 | .hg/hgrc and working directory will be created on the remote side. |
|
607 | 597 | Please see 'hg help urls' for important details about ssh:// URLs. |
|
608 | 598 | |
|
599 | If the -U/--noupdate option is specified, the new clone will contain | |
|
600 | only a repository (.hg) and no working copy (the working copy parent | |
|
601 | will be the null changeset). Otherwise, clone will initially check | |
|
602 | out (in order of precedence): :: | |
|
603 | ||
|
604 | a) the changeset, tag or branch specified with -u/--updaterev | |
|
605 | b) the changeset, tag or branch given with the first -r/--rev | |
|
606 | c) the head of the default branch | |
|
607 | ||
|
608 | Use 'hg clone -u . src dst' to checkout the source repository's | |
|
609 | parent changeset (applicable for local source repositories only). | |
|
610 | ||
|
611 | A set of changesets (tags, or branch names) to pull may be specified | |
|
612 | by listing each changeset (tag, or branch name) with -r/--rev. | |
|
613 | If -r/--rev is used, the cloned repository will contain only a subset | |
|
614 | of the changesets of the source repository. Only the set of changesets | |
|
615 | defined by all -r/--rev options (including their direct and indirect | |
|
616 | parent changesets) will be pulled into the destination repository. | |
|
617 | No subsequent changesets (including subsequent tags) will be present | |
|
618 | in the destination. | |
|
619 | ||
|
620 | Using -r/--rev (or 'clone src#rev dest') implies --pull, even for | |
|
621 | local source repositories. | |
|
622 | ||
|
609 | 623 | For efficiency, hardlinks are used for cloning whenever the source |
|
610 | 624 | and destination are on the same filesystem (note this applies only |
|
611 | 625 | to the repository data, not to the checked out files). Some |
@@ -625,11 +639,14 def clone(ui, source, dest=None, **opts) | |||
|
625 | 639 | this is not compatible with certain extensions that place their |
|
626 | 640 | metadata under the .hg directory, such as mq. |
|
627 | 641 | """ |
|
642 | if opts.get('noupdate') and opts.get('updaterev'): | |
|
643 | raise util.Abort(_("cannot specify both --noupdate and --updaterev")) | |
|
644 | ||
|
628 | 645 | hg.clone(cmdutil.remoteui(ui, opts), source, dest, |
|
629 | 646 | pull=opts.get('pull'), |
|
630 | 647 | stream=opts.get('uncompressed'), |
|
631 | 648 | rev=opts.get('rev'), |
|
632 | update=not opts.get('noupdate')) | |
|
649 | update=opts.get('updaterev') or not opts.get('noupdate')) | |
|
633 | 650 | |
|
634 | 651 | def commit(ui, repo, *pats, **opts): |
|
635 | 652 | """commit the specified files or all outstanding changes |
@@ -3355,6 +3372,8 table = { | |||
|
3355 | 3372 | (clone, |
|
3356 | 3373 | [('U', 'noupdate', None, |
|
3357 | 3374 | _('the clone will only contain a repository (no working copy)')), |
|
3375 | ('u', 'updaterev', '', | |
|
3376 | _('revision, tag or branch to check out')), | |
|
3358 | 3377 | ('r', 'rev', [], |
|
3359 | 3378 | _('a changeset you would like to have after cloning')), |
|
3360 | 3379 | ('', 'pull', None, _('use pull protocol to copy metadata')), |
@@ -309,6 +309,8 def clone(ui, source, dest=None, pull=Fa | |||
|
309 | 309 | if update: |
|
310 | 310 | if update is not True: |
|
311 | 311 | checkout = update |
|
312 | if src_repo.local(): | |
|
313 | checkout = src_repo.lookup(update) | |
|
312 | 314 | for test in (checkout, 'default', 'tip'): |
|
313 | 315 | if test is None: |
|
314 | 316 | continue |
@@ -67,4 +67,136 cd h | |||
|
67 | 67 | hg clone ../a . |
|
68 | 68 | cd .. |
|
69 | 69 | |
|
70 | echo | |
|
71 | echo | |
|
72 | echo % "*** tests for option -u ***" | |
|
73 | echo | |
|
74 | ||
|
75 | ||
|
76 | echo | |
|
77 | echo % "adding some more history to repo a" | |
|
78 | cd a | |
|
79 | echo % "tag ref1" | |
|
80 | hg tag ref1 | |
|
81 | echo the quick brown fox >a | |
|
82 | hg ci -m "hacked default" | |
|
83 | echo % "updating back to ref1" | |
|
84 | hg up ref1 | |
|
85 | echo | |
|
86 | echo % "add branch 'stable' to repo a for later tests" | |
|
87 | hg branch stable | |
|
88 | echo some text >a | |
|
89 | hg ci -m "starting branch stable" | |
|
90 | echo % "tag ref2" | |
|
91 | hg tag ref2 | |
|
92 | echo some more text >a | |
|
93 | hg ci -m "another change for branch stable" | |
|
94 | echo | |
|
95 | echo % "updating back to ref2" | |
|
96 | hg up ref2 | |
|
97 | echo | |
|
98 | echo % "parents of repo a" | |
|
99 | hg parents | |
|
100 | echo | |
|
101 | echo % "repo a has two heads" | |
|
102 | hg heads | |
|
103 | cd .. | |
|
104 | ||
|
105 | echo | |
|
106 | echo % "testing clone -U -u 1 a ua (must abort)" | |
|
107 | hg clone -U -u 1 a ua | |
|
108 | ||
|
109 | echo | |
|
110 | echo % "testing clone -u . a ua" | |
|
111 | hg clone -u . a ua | |
|
112 | echo | |
|
113 | echo % "repo ua has both heads" | |
|
114 | hg -R ua heads | |
|
115 | echo | |
|
116 | echo % "same revision checked out in repo a and ua" | |
|
117 | hg -R a parents --template "{node|short}\n" | |
|
118 | hg -R ua parents --template "{node|short}\n" | |
|
119 | rm -r ua | |
|
120 | ||
|
121 | echo | |
|
122 | echo % "testing clone --pull -u . a ua" | |
|
123 | hg clone --pull -u . a ua | |
|
124 | echo | |
|
125 | echo % "repo ua has both heads" | |
|
126 | hg -R ua heads | |
|
127 | echo | |
|
128 | echo % "same revision checked out in repo a and ua" | |
|
129 | hg -R a parents --template "{node|short}\n" | |
|
130 | hg -R ua parents --template "{node|short}\n" | |
|
131 | rm -r ua | |
|
132 | ||
|
133 | echo | |
|
134 | echo % "testing clone -u stable a ua" | |
|
135 | hg clone -u stable a ua | |
|
136 | echo | |
|
137 | echo % "repo ua has both heads" | |
|
138 | hg -R ua heads | |
|
139 | echo | |
|
140 | echo % "branch stable is checked out" | |
|
141 | hg -R ua parents | |
|
142 | rm -r ua | |
|
143 | ||
|
144 | echo | |
|
145 | echo % "testing clone a ua" | |
|
146 | hg clone a ua | |
|
147 | echo | |
|
148 | echo % "repo ua has both heads" | |
|
149 | hg -R ua heads | |
|
150 | echo | |
|
151 | echo % "branch default is checked out" | |
|
152 | hg -R ua parents | |
|
153 | rm -r ua | |
|
154 | ||
|
155 | echo | |
|
156 | echo % "testing clone -u . a#stable ua" | |
|
157 | hg clone -u . a#stable ua | |
|
158 | echo | |
|
159 | echo % "repo ua has only branch stable" | |
|
160 | hg -R ua heads | |
|
161 | echo | |
|
162 | echo % "same revision checked out in repo a and ua" | |
|
163 | hg -R a parents --template "{node|short}\n" | |
|
164 | hg -R ua parents --template "{node|short}\n" | |
|
165 | rm -r ua | |
|
166 | ||
|
167 | echo | |
|
168 | echo % "testing clone -u . -r stable a ua" | |
|
169 | hg clone -u . -r stable a ua | |
|
170 | echo | |
|
171 | echo % "repo ua has only branch stable" | |
|
172 | hg -R ua heads | |
|
173 | echo | |
|
174 | echo % "same revision checked out in repo a and ua" | |
|
175 | hg -R a parents --template "{node|short}\n" | |
|
176 | hg -R ua parents --template "{node|short}\n" | |
|
177 | rm -r ua | |
|
178 | ||
|
179 | echo | |
|
180 | echo % "testing clone -r stable a ua" | |
|
181 | hg clone -r stable a ua | |
|
182 | echo | |
|
183 | echo % "repo ua has only branch stable" | |
|
184 | hg -R ua heads | |
|
185 | echo | |
|
186 | echo % "branch stable is checked out" | |
|
187 | hg -R ua parents | |
|
188 | rm -r ua | |
|
189 | ||
|
190 | echo | |
|
191 | echo % "testing clone -u . -r stable -r default a ua" | |
|
192 | hg clone -u . -r stable -r default a ua | |
|
193 | echo | |
|
194 | echo % "repo ua has two heads" | |
|
195 | hg -R ua heads | |
|
196 | echo | |
|
197 | echo % "same revision checked out in repo a and ua" | |
|
198 | hg -R a parents --template "{node|short}\n" | |
|
199 | hg -R ua parents --template "{node|short}\n" | |
|
200 | rm -r ua | |
|
201 | ||
|
70 | 202 | exit 0 |
@@ -54,3 +54,246 2 files, 11 changesets, 11 total revisio | |||
|
54 | 54 | % clone to . |
|
55 | 55 | updating to branch default |
|
56 | 56 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
57 | ||
|
58 | ||
|
59 | % *** tests for option -u *** | |
|
60 | ||
|
61 | ||
|
62 | % adding some more history to repo a | |
|
63 | % tag ref1 | |
|
64 | % updating back to ref1 | |
|
65 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
66 | ||
|
67 | % add branch 'stable' to repo a for later tests | |
|
68 | marked working directory as branch stable | |
|
69 | created new head | |
|
70 | % tag ref2 | |
|
71 | ||
|
72 | % updating back to ref2 | |
|
73 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
|
74 | ||
|
75 | % parents of repo a | |
|
76 | changeset: 13:e8ece76546a6 | |
|
77 | branch: stable | |
|
78 | tag: ref2 | |
|
79 | parent: 10:a7949464abda | |
|
80 | user: test | |
|
81 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
82 | summary: starting branch stable | |
|
83 | ||
|
84 | ||
|
85 | % repo a has two heads | |
|
86 | changeset: 15:0aae7cf88f0d | |
|
87 | branch: stable | |
|
88 | tag: tip | |
|
89 | user: test | |
|
90 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
91 | summary: another change for branch stable | |
|
92 | ||
|
93 | changeset: 12:f21241060d6a | |
|
94 | user: test | |
|
95 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
96 | summary: hacked default | |
|
97 | ||
|
98 | ||
|
99 | % testing clone -U -u 1 a ua (must abort) | |
|
100 | abort: cannot specify both --noupdate and --updaterev | |
|
101 | ||
|
102 | % testing clone -u . a ua | |
|
103 | updating to branch stable | |
|
104 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
105 | ||
|
106 | % repo ua has both heads | |
|
107 | changeset: 15:0aae7cf88f0d | |
|
108 | branch: stable | |
|
109 | tag: tip | |
|
110 | user: test | |
|
111 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
112 | summary: another change for branch stable | |
|
113 | ||
|
114 | changeset: 12:f21241060d6a | |
|
115 | user: test | |
|
116 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
117 | summary: hacked default | |
|
118 | ||
|
119 | ||
|
120 | % same revision checked out in repo a and ua | |
|
121 | e8ece76546a6 | |
|
122 | e8ece76546a6 | |
|
123 | ||
|
124 | % testing clone --pull -u . a ua | |
|
125 | requesting all changes | |
|
126 | adding changesets | |
|
127 | adding manifests | |
|
128 | adding file changes | |
|
129 | added 16 changesets with 16 changes to 3 files (+1 heads) | |
|
130 | updating to branch stable | |
|
131 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
132 | ||
|
133 | % repo ua has both heads | |
|
134 | changeset: 15:0aae7cf88f0d | |
|
135 | branch: stable | |
|
136 | tag: tip | |
|
137 | user: test | |
|
138 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
139 | summary: another change for branch stable | |
|
140 | ||
|
141 | changeset: 12:f21241060d6a | |
|
142 | user: test | |
|
143 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
144 | summary: hacked default | |
|
145 | ||
|
146 | ||
|
147 | % same revision checked out in repo a and ua | |
|
148 | e8ece76546a6 | |
|
149 | e8ece76546a6 | |
|
150 | ||
|
151 | % testing clone -u stable a ua | |
|
152 | updating to branch stable | |
|
153 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
154 | ||
|
155 | % repo ua has both heads | |
|
156 | changeset: 15:0aae7cf88f0d | |
|
157 | branch: stable | |
|
158 | tag: tip | |
|
159 | user: test | |
|
160 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
161 | summary: another change for branch stable | |
|
162 | ||
|
163 | changeset: 12:f21241060d6a | |
|
164 | user: test | |
|
165 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
166 | summary: hacked default | |
|
167 | ||
|
168 | ||
|
169 | % branch stable is checked out | |
|
170 | changeset: 15:0aae7cf88f0d | |
|
171 | branch: stable | |
|
172 | tag: tip | |
|
173 | user: test | |
|
174 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
175 | summary: another change for branch stable | |
|
176 | ||
|
177 | ||
|
178 | % testing clone a ua | |
|
179 | updating to branch default | |
|
180 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
181 | ||
|
182 | % repo ua has both heads | |
|
183 | changeset: 15:0aae7cf88f0d | |
|
184 | branch: stable | |
|
185 | tag: tip | |
|
186 | user: test | |
|
187 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
188 | summary: another change for branch stable | |
|
189 | ||
|
190 | changeset: 12:f21241060d6a | |
|
191 | user: test | |
|
192 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
193 | summary: hacked default | |
|
194 | ||
|
195 | ||
|
196 | % branch default is checked out | |
|
197 | changeset: 12:f21241060d6a | |
|
198 | user: test | |
|
199 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
200 | summary: hacked default | |
|
201 | ||
|
202 | ||
|
203 | % testing clone -u . a#stable ua | |
|
204 | requesting all changes | |
|
205 | adding changesets | |
|
206 | adding manifests | |
|
207 | adding file changes | |
|
208 | added 14 changesets with 14 changes to 3 files | |
|
209 | updating to branch stable | |
|
210 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
211 | ||
|
212 | % repo ua has only branch stable | |
|
213 | changeset: 13:0aae7cf88f0d | |
|
214 | branch: stable | |
|
215 | tag: tip | |
|
216 | user: test | |
|
217 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
218 | summary: another change for branch stable | |
|
219 | ||
|
220 | ||
|
221 | % same revision checked out in repo a and ua | |
|
222 | e8ece76546a6 | |
|
223 | e8ece76546a6 | |
|
224 | ||
|
225 | % testing clone -u . -r stable a ua | |
|
226 | requesting all changes | |
|
227 | adding changesets | |
|
228 | adding manifests | |
|
229 | adding file changes | |
|
230 | added 14 changesets with 14 changes to 3 files | |
|
231 | updating to branch stable | |
|
232 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
233 | ||
|
234 | % repo ua has only branch stable | |
|
235 | changeset: 13:0aae7cf88f0d | |
|
236 | branch: stable | |
|
237 | tag: tip | |
|
238 | user: test | |
|
239 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
240 | summary: another change for branch stable | |
|
241 | ||
|
242 | ||
|
243 | % same revision checked out in repo a and ua | |
|
244 | e8ece76546a6 | |
|
245 | e8ece76546a6 | |
|
246 | ||
|
247 | % testing clone -r stable a ua | |
|
248 | requesting all changes | |
|
249 | adding changesets | |
|
250 | adding manifests | |
|
251 | adding file changes | |
|
252 | added 14 changesets with 14 changes to 3 files | |
|
253 | updating to branch stable | |
|
254 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
255 | ||
|
256 | % repo ua has only branch stable | |
|
257 | changeset: 13:0aae7cf88f0d | |
|
258 | branch: stable | |
|
259 | tag: tip | |
|
260 | user: test | |
|
261 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
262 | summary: another change for branch stable | |
|
263 | ||
|
264 | ||
|
265 | % branch stable is checked out | |
|
266 | changeset: 13:0aae7cf88f0d | |
|
267 | branch: stable | |
|
268 | tag: tip | |
|
269 | user: test | |
|
270 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
271 | summary: another change for branch stable | |
|
272 | ||
|
273 | ||
|
274 | % testing clone -u . -r stable -r default a ua | |
|
275 | requesting all changes | |
|
276 | adding changesets | |
|
277 | adding manifests | |
|
278 | adding file changes | |
|
279 | added 16 changesets with 16 changes to 3 files (+1 heads) | |
|
280 | updating to branch stable | |
|
281 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
282 | ||
|
283 | % repo ua has two heads | |
|
284 | changeset: 15:0aae7cf88f0d | |
|
285 | branch: stable | |
|
286 | tag: tip | |
|
287 | user: test | |
|
288 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
289 | summary: another change for branch stable | |
|
290 | ||
|
291 | changeset: 12:f21241060d6a | |
|
292 | user: test | |
|
293 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
294 | summary: hacked default | |
|
295 | ||
|
296 | ||
|
297 | % same revision checked out in repo a and ua | |
|
298 | e8ece76546a6 | |
|
299 | e8ece76546a6 |
@@ -165,7 +165,7 hg: command 's' is ambiguous: | |||
|
165 | 165 | % Show all commands + options |
|
166 | 166 | add: include, exclude, dry-run |
|
167 | 167 | annotate: rev, follow, text, user, date, number, changeset, line-number, include, exclude |
|
168 | clone: noupdate, rev, pull, uncompressed, ssh, remotecmd | |
|
168 | clone: noupdate, updaterev, rev, pull, uncompressed, ssh, remotecmd | |
|
169 | 169 | commit: addremove, close-branch, include, exclude, message, logfile, date, user |
|
170 | 170 | diff: rev, change, text, git, nodates, show-function, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude |
|
171 | 171 | export: output, switch-parent, text, git, nodates |
General Comments 0
You need to be logged in to leave comments.
Login now