Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hg.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 | 627bb1875fee |
line wrap: on
line diff
--- a/mercurial/hg.py Mon Apr 12 03:01:04 2021 +0200 +++ b/mercurial/hg.py Mon Apr 12 06:34:54 2021 +0200 @@ -132,13 +132,9 @@ def parseurl(path, branches=None): '''parse url#branch, returning (url, (branch, branches))''' - - u = urlutil.url(path) - branch = None - if u.fragment: - branch = u.fragment - u.fragment = None - return bytes(u), (branch, branches or []) + msg = b'parseurl(...) moved to mercurial.utils.urlutil' + util.nouideprecwarn(msg, b'6.0', stacklevel=2) + return urlutil.parseurl(path, branches=branches) schemes = { @@ -285,7 +281,7 @@ # the sharedpath always ends in the .hg; we want the path to the repo source = repo.vfs.split(repo.sharedpath)[0] - srcurl, branches = parseurl(source) + srcurl, branches = urlutil.parseurl(source) srcrepo = repository(repo.ui, srcurl) repo.srcrepo = srcrepo return srcrepo @@ -312,7 +308,7 @@ if isinstance(source, bytes): origsource = ui.expandpath(source) - source, branches = parseurl(origsource) + source, branches = urlutil.parseurl(origsource) srcrepo = repository(ui, source) rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) else: @@ -676,7 +672,7 @@ if isinstance(source, bytes): origsource = ui.expandpath(source) - source, branches = parseurl(origsource, branch) + source, branches = urlutil.parseurl(origsource, branch) srcpeer = peer(ui, peeropts, source) else: srcpeer = source.peer() # in case we were called with a localrepo @@ -1266,7 +1262,9 @@ (remoterepo, incomingchangesetlist, displayer) parameters, and is supposed to contain only code that can't be unified. """ - source, branches = parseurl(ui.expandpath(source), opts.get(b'branch')) + source, branches = urlutil.parseurl( + ui.expandpath(source), opts.get(b'branch') + ) other = peer(repo, opts, source) cleanupfn = other.close try: