comparison mercurial/commands.py @ 10365:d757bc0c7865

interpret repo#name url syntax as branch instead of revision Previously, the name part of an repo#name url was interpreted as a revision, similar to using the --rev option. Now it is instead looked up as a branch first, and if that succeeds all the heads of the branch will be processed instead of just its tip-most head. If the branch lookup fails, it will be assumed to be an revision as before (e.g. for tags).
author Sune Foldager <cryo@cyanite.org>
date Sun, 07 Feb 2010 14:29:07 +0100
parents de1e7099d100
children 98a0421b9e52
comparison
equal deleted inserted replaced
10364:de1e7099d100 10365:d757bc0c7865
536 for p in parents: 536 for p in parents:
537 if p not in seen: 537 if p not in seen:
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:
547 cg = repo.changegroupsubset(o, revs, 'bundle') 548 cg = repo.changegroupsubset(o, revs, 'bundle')
548 else: 549 else:
605 will be the null changeset). Otherwise, clone will initially check 606 will be the null changeset). Otherwise, clone will initially check
606 out (in order of precedence): 607 out (in order of precedence):
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).
614 616
615 A set of changesets (tags, or branch names) to pull may be specified 617 A set of changesets (tags, or branch names) to pull may be specified
1725 default = not (num or id or branch or tags) 1727 default = not (num or id or branch or tags)
1726 output = [] 1728 output = []
1727 1729
1728 revs = [] 1730 revs = []
1729 if source: 1731 if source:
1730 source, revs, checkout = hg.parseurl(ui.expandpath(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:
1735 rev = revs[0] 1738 rev = revs[0]
1736 if not rev: 1739 if not rev:
1917 changesets twice if the incoming is followed by a pull. 1920 changesets twice if the incoming is followed by a pull.
1918 1921
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, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) 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,
1928 force=opts["force"]) 1932 force=opts["force"])
1929 if not incoming: 1933 if not incoming:
2204 be pushed if a push was requested. 2208 be pushed if a push was requested.
2205 2209
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
2215 other = hg.repository(cmdutil.remoteui(repo, opts), dest) 2219 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2216 ui.status(_('comparing with %s\n') % url.hidepassword(dest)) 2220 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2325 where X is the last changeset listed by hg incoming. 2329 where X is the last changeset listed by hg incoming.
2326 2330
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, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) 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]
2336 except error.CapabilityError: 2341 except error.CapabilityError:
2337 err = _("Other repository doesn't support revision lookup, " 2342 err = _("Other repository doesn't support revision lookup, "
2361 be pushed to the remote repository. 2366 be pushed to the remote repository.
2362 2367
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:
2372 revs = [repo.lookup(rev) for rev in revs] 2377 revs = [repo.lookup(rev) for rev in revs]
2373 2378