Show More
@@ -0,0 +1,41 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | # test branch selection options | |||
|
4 | hg init branch | |||
|
5 | cd branch | |||
|
6 | hg branch a | |||
|
7 | echo a > foo | |||
|
8 | hg ci -d '0 0' -Ama | |||
|
9 | echo a2 > foo | |||
|
10 | hg ci -d '0 0' -ma2 | |||
|
11 | hg up 0 | |||
|
12 | hg branch c | |||
|
13 | echo c > foo | |||
|
14 | hg ci -d '0 0' -mc | |||
|
15 | cd .. | |||
|
16 | hg clone -r 0 branch branch2 | |||
|
17 | cd branch2 | |||
|
18 | hg up 0 | |||
|
19 | hg branch b | |||
|
20 | echo b > foo | |||
|
21 | hg ci -d '0 0' -mb | |||
|
22 | hg up 0 | |||
|
23 | hg branch -f b | |||
|
24 | echo b2 > foo | |||
|
25 | hg ci -d '0 0' -mb2 | |||
|
26 | ||||
|
27 | echo in rev c branch a | |||
|
28 | hg in -qr c ../branch#a | |||
|
29 | echo out branch . | |||
|
30 | hg out -q ../branch#. | |||
|
31 | echo clone branch b | |||
|
32 | cd .. | |||
|
33 | hg clone branch2#b branch3 | |||
|
34 | hg -q -R branch3 heads b | |||
|
35 | hg -q -R branch3 parents | |||
|
36 | rm -rf branch3 | |||
|
37 | echo clone rev a branch b | |||
|
38 | hg clone -r a branch2#b branch3 | |||
|
39 | hg -q -R branch3 heads b | |||
|
40 | hg -q -R branch3 parents | |||
|
41 | rm -rf branch3 |
@@ -0,0 +1,44 b'' | |||||
|
1 | marked working directory as branch a | |||
|
2 | adding foo | |||
|
3 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
4 | marked working directory as branch c | |||
|
5 | created new head | |||
|
6 | requesting all changes | |||
|
7 | adding changesets | |||
|
8 | adding manifests | |||
|
9 | adding file changes | |||
|
10 | added 1 changesets with 1 changes to 1 files | |||
|
11 | updating to branch a | |||
|
12 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
13 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
14 | marked working directory as branch b | |||
|
15 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
16 | marked working directory as branch b | |||
|
17 | created new head | |||
|
18 | in rev c branch a | |||
|
19 | 1:dd6e60a716c6 | |||
|
20 | 2:f25d57ab0566 | |||
|
21 | out branch . | |||
|
22 | 2:65511d0e2b55 | |||
|
23 | clone branch b | |||
|
24 | requesting all changes | |||
|
25 | adding changesets | |||
|
26 | adding manifests | |||
|
27 | adding file changes | |||
|
28 | added 3 changesets with 3 changes to 1 files (+1 heads) | |||
|
29 | updating to branch b | |||
|
30 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
31 | 2:65511d0e2b55 | |||
|
32 | 1:b84708d77ab7 | |||
|
33 | 2:65511d0e2b55 | |||
|
34 | clone rev a branch b | |||
|
35 | requesting all changes | |||
|
36 | adding changesets | |||
|
37 | adding manifests | |||
|
38 | adding file changes | |||
|
39 | added 3 changesets with 3 changes to 1 files (+1 heads) | |||
|
40 | updating to branch a | |||
|
41 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
42 | 2:65511d0e2b55 | |||
|
43 | 1:b84708d77ab7 | |||
|
44 | 0:5b65ba7c951d |
@@ -276,12 +276,12 b' def goutgoing(ui, repo, dest=None, **opt' | |||||
276 | """ |
|
276 | """ | |
277 |
|
277 | |||
278 | check_unsupported_flags(opts) |
|
278 | check_unsupported_flags(opts) | |
279 | dest, revs, checkout = hg.parseurl( |
|
279 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
280 | ui.expandpath(dest or 'default-push', dest or 'default'), |
|
280 | dest, branches = hg.parseurl(dest) | |
281 | opts.get('rev')) |
|
281 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
|
282 | other = hg.repository(cmdutil.remoteui(ui, opts), dest) | |||
282 | if revs: |
|
283 | if revs: | |
283 | revs = [repo.lookup(rev) for rev in revs] |
|
284 | revs = [repo.lookup(rev) for rev in revs] | |
284 | other = hg.repository(cmdutil.remoteui(ui, opts), dest) |
|
|||
285 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
|
285 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) | |
286 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
286 | o = repo.findoutgoing(other, force=opts.get('force')) | |
287 | if not o: |
|
287 | if not o: | |
@@ -305,8 +305,9 b' def gincoming(ui, repo, source="default"' | |||||
305 | """ |
|
305 | """ | |
306 |
|
306 | |||
307 | check_unsupported_flags(opts) |
|
307 | check_unsupported_flags(opts) | |
308 |
source, |
|
308 | source, branches = hg.parseurl(ui.expandpath(source)) | |
309 | other = hg.repository(cmdutil.remoteui(repo, opts), source) |
|
309 | other = hg.repository(cmdutil.remoteui(repo, opts), source) | |
|
310 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |||
310 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
311 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
311 | if revs: |
|
312 | if revs: | |
312 | revs = [other.lookup(rev) for rev in revs] |
|
313 | revs = [other.lookup(rev) for rev in revs] |
@@ -233,7 +233,8 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
233 | def outgoing(dest, revs): |
|
233 | def outgoing(dest, revs): | |
234 | '''Return the revisions present locally but not in dest''' |
|
234 | '''Return the revisions present locally but not in dest''' | |
235 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
235 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
236 |
dest, |
|
236 | dest, branches = hg.parseurl(dest) | |
|
237 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) | |||
237 | if revs: |
|
238 | if revs: | |
238 | revs = [repo.lookup(rev) for rev in revs] |
|
239 | revs = [repo.lookup(rev) for rev in revs] | |
239 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
|
240 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
@@ -538,9 +538,10 b' def bundle(ui, repo, fname, dest=None, *' | |||||
538 | seen[p] = 1 |
|
538 | seen[p] = 1 | |
539 | visit.append(p) |
|
539 | visit.append(p) | |
540 | else: |
|
540 | else: | |
541 | dest, revs, checkout = hg.parseurl( |
|
541 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
542 | ui.expandpath(dest or 'default-push', dest or 'default'), revs) |
|
542 | dest, branches = hg.parseurl(dest) | |
543 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
|
543 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) | |
|
544 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) | |||
544 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
545 | o = repo.findoutgoing(other, force=opts.get('force')) | |
545 |
|
546 | |||
546 | if revs: |
|
547 | if revs: | |
@@ -607,7 +608,8 b' def clone(ui, source, dest=None, **opts)' | |||||
607 |
|
608 | |||
608 | a) the changeset, tag or branch specified with -u/--updaterev |
|
609 | a) the changeset, tag or branch specified with -u/--updaterev | |
609 | b) the changeset, tag or branch given with the first -r/--rev |
|
610 | b) the changeset, tag or branch given with the first -r/--rev | |
610 | c) the head of the default branch |
|
611 | c) the branch given with the url#branch source syntax | |
|
612 | d) the head of the default branch | |||
611 |
|
613 | |||
612 | Use 'hg clone -u . src dst' to checkout the source repository's |
|
614 | Use 'hg clone -u . src dst' to checkout the source repository's | |
613 | parent changeset (applicable for local source repositories only). |
|
615 | parent changeset (applicable for local source repositories only). | |
@@ -1727,8 +1729,9 b' def identify(ui, repo, source=None,' | |||||
1727 |
|
1729 | |||
1728 | revs = [] |
|
1730 | revs = [] | |
1729 | if source: |
|
1731 | if source: | |
1730 |
source, |
|
1732 | source, branches = hg.parseurl(ui.expandpath(source)) | |
1731 | repo = hg.repository(ui, source) |
|
1733 | repo = hg.repository(ui, source) | |
|
1734 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |||
1732 |
|
1735 | |||
1733 | if not repo.local(): |
|
1736 | if not repo.local(): | |
1734 | if not rev and revs: |
|
1737 | if not rev and revs: | |
@@ -1919,9 +1922,10 b' def incoming(ui, repo, source="default",' | |||||
1919 | See pull for valid source format details. |
|
1922 | See pull for valid source format details. | |
1920 | """ |
|
1923 | """ | |
1921 | limit = cmdutil.loglimit(opts) |
|
1924 | limit = cmdutil.loglimit(opts) | |
1922 |
source, |
|
1925 | source, branches = hg.parseurl(ui.expandpath(source)) | |
1923 | other = hg.repository(cmdutil.remoteui(repo, opts), source) |
|
1926 | other = hg.repository(cmdutil.remoteui(repo, opts), source) | |
1924 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
1927 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
|
1928 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |||
1925 | if revs: |
|
1929 | if revs: | |
1926 | revs = [other.lookup(rev) for rev in revs] |
|
1930 | revs = [other.lookup(rev) for rev in revs] | |
1927 | common, incoming, rheads = repo.findcommonincoming(other, heads=revs, |
|
1931 | common, incoming, rheads = repo.findcommonincoming(other, heads=revs, | |
@@ -2206,9 +2210,9 b' def outgoing(ui, repo, dest=None, **opts' | |||||
2206 | See pull for valid destination format details. |
|
2210 | See pull for valid destination format details. | |
2207 | """ |
|
2211 | """ | |
2208 | limit = cmdutil.loglimit(opts) |
|
2212 | limit = cmdutil.loglimit(opts) | |
2209 | dest, revs, checkout = hg.parseurl( |
|
2213 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
2210 | ui.expandpath(dest or 'default-push', dest or 'default'), |
|
2214 | dest, branches = hg.parseurl(dest) | |
2211 | opts.get('rev')) |
|
2215 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
2212 | if revs: |
|
2216 | if revs: | |
2213 | revs = [repo.lookup(rev) for rev in revs] |
|
2217 | revs = [repo.lookup(rev) for rev in revs] | |
2214 |
|
2218 | |||
@@ -2327,9 +2331,10 b' def pull(ui, repo, source="default", **o' | |||||
2327 | If SOURCE is omitted, the 'default' path will be used. |
|
2331 | If SOURCE is omitted, the 'default' path will be used. | |
2328 | See 'hg help urls' for more information. |
|
2332 | See 'hg help urls' for more information. | |
2329 | """ |
|
2333 | """ | |
2330 |
source, |
|
2334 | source, branches = hg.parseurl(ui.expandpath(source)) | |
2331 | other = hg.repository(cmdutil.remoteui(repo, opts), source) |
|
2335 | other = hg.repository(cmdutil.remoteui(repo, opts), source) | |
2332 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) |
|
2336 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) | |
|
2337 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |||
2333 | if revs: |
|
2338 | if revs: | |
2334 | try: |
|
2339 | try: | |
2335 | revs = [other.lookup(rev) for rev in revs] |
|
2340 | revs = [other.lookup(rev) for rev in revs] | |
@@ -2363,9 +2368,9 b' def push(ui, repo, dest=None, **opts):' | |||||
2363 | Please see 'hg help urls' for important details about ``ssh://`` |
|
2368 | Please see 'hg help urls' for important details about ``ssh://`` | |
2364 | URLs. If DESTINATION is omitted, a default path will be used. |
|
2369 | URLs. If DESTINATION is omitted, a default path will be used. | |
2365 | """ |
|
2370 | """ | |
2366 | dest, revs, checkout = hg.parseurl( |
|
2371 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
2367 | ui.expandpath(dest or 'default-push', dest or 'default'), |
|
2372 | dest, branches = hg.parseurl(dest) | |
2368 | opts.get('rev')) |
|
2373 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
2369 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) |
|
2374 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) | |
2370 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
|
2375 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) | |
2371 | if revs: |
|
2376 | if revs: |
@@ -9,7 +9,7 b'' | |||||
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | from lock import release |
|
10 | from lock import release | |
11 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo |
|
11 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo | |
12 | import lock, util, extensions, error, encoding |
|
12 | import lock, util, extensions, error, encoding, node | |
13 | import merge as _merge |
|
13 | import merge as _merge | |
14 | import verify as _verify |
|
14 | import verify as _verify | |
15 | import errno, os, shutil |
|
15 | import errno, os, shutil | |
@@ -18,15 +18,31 b' def _local(path):' | |||||
18 | return (os.path.isfile(util.drop_scheme('file', path)) and |
|
18 | return (os.path.isfile(util.drop_scheme('file', path)) and | |
19 | bundlerepo or localrepo) |
|
19 | bundlerepo or localrepo) | |
20 |
|
20 | |||
21 | def parseurl(url, revs=[]): |
|
21 | def addbranchrevs(lrepo, repo, branches, revs): | |
22 | '''parse url#branch, returning url, branch + revs''' |
|
22 | if not branches: | |
|
23 | return revs or None, revs and revs[0] or None | |||
|
24 | branchmap = repo.branchmap() | |||
|
25 | revs = revs and list(revs) or [] | |||
|
26 | for branch in branches: | |||
|
27 | if branch == '.': | |||
|
28 | if not lrepo or not lrepo.local(): | |||
|
29 | raise util.Abort(_("dirstate branch not accessible")) | |||
|
30 | revs.append(lrepo.dirstate.branch()) | |||
|
31 | else: | |||
|
32 | butf8 = encoding.fromlocal(branch) | |||
|
33 | if butf8 in branchmap: | |||
|
34 | revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) | |||
|
35 | else: | |||
|
36 | revs.append(branch) | |||
|
37 | return revs, revs[0] | |||
|
38 | ||||
|
39 | def parseurl(url, branches=None): | |||
|
40 | '''parse url#branch, returning url, branches+[branch]''' | |||
23 |
|
41 | |||
24 | if '#' not in url: |
|
42 | if '#' not in url: | |
25 |
return url, |
|
43 | return url, branches or [] | |
26 |
|
||||
27 | url, branch = url.split('#', 1) |
|
44 | url, branch = url.split('#', 1) | |
28 | checkout = revs and revs[0] or branch |
|
45 | return url, (branches or []) + [branch] | |
29 | return url, (revs or []) + [branch], checkout |
|
|||
30 |
|
46 | |||
31 | schemes = { |
|
47 | schemes = { | |
32 | 'bundle': bundlerepo, |
|
48 | 'bundle': bundlerepo, | |
@@ -94,8 +110,9 b' def share(ui, source, dest=None, update=' | |||||
94 |
|
110 | |||
95 | if isinstance(source, str): |
|
111 | if isinstance(source, str): | |
96 | origsource = ui.expandpath(source) |
|
112 | origsource = ui.expandpath(source) | |
97 |
source, |
|
113 | source, branches = parseurl(origsource) | |
98 | srcrepo = repository(ui, source) |
|
114 | srcrepo = repository(ui, source) | |
|
115 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) | |||
99 | else: |
|
116 | else: | |
100 | srcrepo = source |
|
117 | srcrepo = source | |
101 | origsource = source = srcrepo.url() |
|
118 | origsource = source = srcrepo.url() | |
@@ -183,12 +200,12 b' def clone(ui, source, dest=None, pull=Fa' | |||||
183 |
|
200 | |||
184 | if isinstance(source, str): |
|
201 | if isinstance(source, str): | |
185 | origsource = ui.expandpath(source) |
|
202 | origsource = ui.expandpath(source) | |
186 |
source, |
|
203 | source, branch = parseurl(origsource) | |
187 | src_repo = repository(ui, source) |
|
204 | src_repo = repository(ui, source) | |
188 | else: |
|
205 | else: | |
189 | src_repo = source |
|
206 | src_repo = source | |
190 | origsource = source = src_repo.url() |
|
207 | origsource = source = src_repo.url() | |
191 | checkout = rev and rev[0] or None |
|
208 | rev, checkout = addbranchrevs(src_repo, src_repo, branch, rev) | |
192 |
|
209 | |||
193 | if dest is None: |
|
210 | if dest is None: | |
194 | dest = defaultdest(source) |
|
211 | dest = defaultdest(source) |
@@ -2,11 +2,11 b'' | |||||
2 |
|
2 | |||
3 | from mercurial.hg import parseurl |
|
3 | from mercurial.hg import parseurl | |
4 |
|
4 | |||
5 |
def testparse(url, |
|
5 | def testparse(url, branch=[]): | |
6 |
print '%s, |
|
6 | print '%s, branches: %r' % parseurl(url, branch) | |
7 |
|
7 | |||
8 | testparse('http://example.com/no/anchor') |
|
8 | testparse('http://example.com/no/anchor') | |
9 | testparse('http://example.com/an/anchor#foo') |
|
9 | testparse('http://example.com/an/anchor#foo') | |
10 |
testparse('http://example.com/no/anchor/re |
|
10 | testparse('http://example.com/no/anchor/branches', branch=['foo']) | |
11 |
testparse('http://example.com/an/anchor/re |
|
11 | testparse('http://example.com/an/anchor/branches#bar', branch=['foo']) | |
12 |
testparse('http://example.com/an/anchor/ |
|
12 | testparse('http://example.com/an/anchor/branches-None#foo', branch=None) |
@@ -1,5 +1,5 b'' | |||||
1 |
http://example.com/no/anchor, |
|
1 | http://example.com/no/anchor, branches: [] | |
2 |
http://example.com/an/anchor, re |
|
2 | http://example.com/an/anchor, branches: ['foo'] | |
3 |
http://example.com/no/anchor/re |
|
3 | http://example.com/no/anchor/branches, branches: ['foo'] | |
4 |
http://example.com/an/anchor/re |
|
4 | http://example.com/an/anchor/branches, branches: ['foo', 'bar'] | |
5 |
http://example.com/an/anchor/ |
|
5 | http://example.com/an/anchor/branches-None, branches: ['foo'] |
General Comments 0
You need to be logged in to leave comments.
Login now