comparison mercurial/commands.py @ 46908:4452cb788404

urlutil: extract `parseurl` from `hg` into the new module The new module is well fitting for this new code. And this will be useful to make the gathered code collaborate more later. Differential Revision: https://phab.mercurial-scm.org/D10375
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 12 Apr 2021 06:34:54 +0200
parents ffd3e823a7e5
children 067840864f37
comparison
equal deleted inserted replaced
46907:ffd3e823a7e5 46908:4452cb788404
1612 common = [repo[rev].node() for rev in base] 1612 common = [repo[rev].node() for rev in base]
1613 heads = [repo[r].node() for r in revs] if revs else None 1613 heads = [repo[r].node() for r in revs] if revs else None
1614 outgoing = discovery.outgoing(repo, common, heads) 1614 outgoing = discovery.outgoing(repo, common, heads)
1615 else: 1615 else:
1616 dest = ui.expandpath(dest or b'default-push', dest or b'default') 1616 dest = ui.expandpath(dest or b'default-push', dest or b'default')
1617 dest, branches = hg.parseurl(dest, opts.get(b'branch')) 1617 dest, branches = urlutil.parseurl(dest, opts.get(b'branch'))
1618 other = hg.peer(repo, opts, dest) 1618 other = hg.peer(repo, opts, dest)
1619 revs = [repo[r].hex() for r in revs] 1619 revs = [repo[r].hex() for r in revs]
1620 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) 1620 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1621 heads = revs and pycompat.maplist(repo.lookup, revs) or revs 1621 heads = revs and pycompat.maplist(repo.lookup, revs) or revs
1622 outgoing = discovery.findcommonoutgoing( 1622 outgoing = discovery.findcommonoutgoing(
3839 revs = [] 3839 revs = []
3840 3840
3841 peer = None 3841 peer = None
3842 try: 3842 try:
3843 if source: 3843 if source:
3844 source, branches = hg.parseurl(ui.expandpath(source)) 3844 source, branches = urlutil.parseurl(ui.expandpath(source))
3845 # only pass ui when no repo 3845 # only pass ui when no repo
3846 peer = hg.peer(repo or ui, opts, source) 3846 peer = hg.peer(repo or ui, opts, source)
3847 repo = peer.local() 3847 repo = peer.local()
3848 revs, checkout = hg.addbranchrevs(repo, peer, branches, None) 3848 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3849 3849
4309 return 0 4309 return 0
4310 4310
4311 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle']) 4311 cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
4312 4312
4313 if opts.get(b'bookmarks'): 4313 if opts.get(b'bookmarks'):
4314 source, branches = hg.parseurl( 4314 source, branches = urlutil.parseurl(
4315 ui.expandpath(source), opts.get(b'branch') 4315 ui.expandpath(source), opts.get(b'branch')
4316 ) 4316 )
4317 other = hg.peer(repo, opts, source) 4317 other = hg.peer(repo, opts, source)
4318 try: 4318 try:
4319 if b'bookmarks' not in other.listkeys(b'namespaces'): 4319 if b'bookmarks' not in other.listkeys(b'namespaces'):
5388 raise error.InputError(msg, hint=hint) 5388 raise error.InputError(msg, hint=hint)
5389 5389
5390 if not sources: 5390 if not sources:
5391 sources = [b'default'] 5391 sources = [b'default']
5392 for source in sources: 5392 for source in sources:
5393 source, branches = hg.parseurl( 5393 source, branches = urlutil.parseurl(
5394 ui.expandpath(source), opts.get(b'branch') 5394 ui.expandpath(source), opts.get(b'branch')
5395 ) 5395 )
5396 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(source)) 5396 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(source))
5397 ui.flush() 5397 ui.flush()
5398 other = hg.peer(repo, opts, source) 5398 other = hg.peer(repo, opts, source)
7223 needsoutgoing = True 7223 needsoutgoing = True
7224 if not needsincoming and not needsoutgoing: 7224 if not needsincoming and not needsoutgoing:
7225 return 7225 return
7226 7226
7227 def getincoming(): 7227 def getincoming():
7228 source, branches = hg.parseurl(ui.expandpath(b'default')) 7228 source, branches = urlutil.parseurl(ui.expandpath(b'default'))
7229 sbranch = branches[0] 7229 sbranch = branches[0]
7230 try: 7230 try:
7231 other = hg.peer(repo, {}, source) 7231 other = hg.peer(repo, {}, source)
7232 except error.RepoError: 7232 except error.RepoError:
7233 if opts.get(b'remote'): 7233 if opts.get(b'remote'):
7246 source, sbranch, sother, commoninc, incoming = getincoming() 7246 source, sbranch, sother, commoninc, incoming = getincoming()
7247 else: 7247 else:
7248 source = sbranch = sother = commoninc = incoming = None 7248 source = sbranch = sother = commoninc = incoming = None
7249 7249
7250 def getoutgoing(): 7250 def getoutgoing():
7251 dest, branches = hg.parseurl(ui.expandpath(b'default-push', b'default')) 7251 dest, branches = urlutil.parseurl(
7252 ui.expandpath(b'default-push', b'default')
7253 )
7252 dbranch = branches[0] 7254 dbranch = branches[0]
7253 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) 7255 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
7254 if source != dest: 7256 if source != dest:
7255 try: 7257 try:
7256 dother = hg.peer(repo, {}, dest) 7258 dother = hg.peer(repo, {}, dest)