Show More
@@ -1042,7 +1042,7 b' def findoutgoing(ui, repo, remote=None, ' | |||||
1042 | if opts is None: |
|
1042 | if opts is None: | |
1043 | opts = {} |
|
1043 | opts = {} | |
1044 | dest = ui.expandpath(remote or b'default-push', remote or b'default') |
|
1044 | dest = ui.expandpath(remote or b'default-push', remote or b'default') | |
1045 |
dest, branches = |
|
1045 | dest, branches = urlutil.parseurl(dest, None)[:2] | |
1046 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest)) |
|
1046 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest)) | |
1047 |
|
1047 | |||
1048 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
1048 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
@@ -116,6 +116,7 b' from mercurial.pycompat import (' | |||||
116 | from mercurial.utils import ( |
|
116 | from mercurial.utils import ( | |
117 | procutil, |
|
117 | procutil, | |
118 | stringutil, |
|
118 | stringutil, | |
|
119 | urlutil, | |||
119 | ) |
|
120 | ) | |
120 |
|
121 | |||
121 | from mercurial import ( |
|
122 | from mercurial import ( | |
@@ -683,7 +684,9 b' def _lookupwrap(orig):' | |||||
683 | def _pull(orig, ui, repo, source=b"default", **opts): |
|
684 | def _pull(orig, ui, repo, source=b"default", **opts): | |
684 | opts = pycompat.byteskwargs(opts) |
|
685 | opts = pycompat.byteskwargs(opts) | |
685 | # Copy paste from `pull` command |
|
686 | # Copy paste from `pull` command | |
686 | source, branches = hg.parseurl(ui.expandpath(source), opts.get(b'branch')) |
|
687 | source, branches = urlutil.parseurl( | |
|
688 | ui.expandpath(source), opts.get(b'branch') | |||
|
689 | ) | |||
687 |
|
690 | |||
688 | scratchbookmarks = {} |
|
691 | scratchbookmarks = {} | |
689 | unfi = repo.unfiltered() |
|
692 | unfi = repo.unfiltered() |
@@ -43,12 +43,12 b' def openstore(repo=None, remote=None, pu' | |||||
43 | # meaning the current directory. |
|
43 | # meaning the current directory. | |
44 | if repo is None: |
|
44 | if repo is None: | |
45 | path = ui.expandpath(b'default') |
|
45 | path = ui.expandpath(b'default') | |
46 |
path, _branches = |
|
46 | path, _branches = urlutil.parseurl(path) | |
47 | remote = hg.peer(repo or ui, {}, path) |
|
47 | remote = hg.peer(repo or ui, {}, path) | |
48 | elif path == b'default-push' or path == b'default': |
|
48 | elif path == b'default-push' or path == b'default': | |
49 | remote = repo |
|
49 | remote = repo | |
50 | else: |
|
50 | else: | |
51 |
path, _branches = |
|
51 | path, _branches = urlutil.parseurl(path) | |
52 | remote = hg.peer(repo or ui, {}, path) |
|
52 | remote = hg.peer(repo or ui, {}, path) | |
53 |
|
53 | |||
54 | # The path could be a scheme so use Mercurial's normal functionality |
|
54 | # The path could be a scheme so use Mercurial's normal functionality |
@@ -594,7 +594,7 b' def trackedcmd(ui, repo, remotepath=None' | |||||
594 | # be used for finding local-only changes for narrowing. They will |
|
594 | # be used for finding local-only changes for narrowing. They will | |
595 | # also define the set of revisions to update for widening. |
|
595 | # also define the set of revisions to update for widening. | |
596 | remotepath = ui.expandpath(remotepath or b'default') |
|
596 | remotepath = ui.expandpath(remotepath or b'default') | |
597 |
url, branches = |
|
597 | url, branches = urlutil.parseurl(remotepath) | |
598 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(url)) |
|
598 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(url)) | |
599 | remote = hg.peer(repo, opts, url) |
|
599 | remote = hg.peer(repo, opts, url) | |
600 |
|
600 |
@@ -531,7 +531,7 b' def _getoutgoing(repo, dest, revs):' | |||||
531 | '''Return the revisions present locally but not in dest''' |
|
531 | '''Return the revisions present locally but not in dest''' | |
532 | ui = repo.ui |
|
532 | ui = repo.ui | |
533 | url = ui.expandpath(dest or b'default-push', dest or b'default') |
|
533 | url = ui.expandpath(dest or b'default-push', dest or b'default') | |
534 |
url = |
|
534 | url = urlutil.parseurl(url)[0] | |
535 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(url)) |
|
535 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(url)) | |
536 |
|
536 | |||
537 | revs = [r for r in revs if r >= 0] |
|
537 | revs = [r for r in revs if r >= 0] |
@@ -1614,7 +1614,7 b' def bundle(ui, repo, fname, dest=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 = |
|
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) | |
@@ -3841,7 +3841,7 b' def identify(' | |||||
3841 | peer = None |
|
3841 | peer = None | |
3842 | try: |
|
3842 | try: | |
3843 | if source: |
|
3843 | if source: | |
3844 |
source, branches = |
|
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() | |
@@ -4311,7 +4311,7 b' def incoming(ui, repo, source=b"default"' | |||||
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 = |
|
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) | |
@@ -5390,7 +5390,7 b' def pull(ui, repo, *sources, **opts):' | |||||
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 = |
|
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)) | |
@@ -7225,7 +7225,7 b' def summary(ui, repo, **opts):' | |||||
7225 | return |
|
7225 | return | |
7226 |
|
7226 | |||
7227 | def getincoming(): |
|
7227 | def getincoming(): | |
7228 |
source, branches = |
|
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) | |
@@ -7248,7 +7248,9 b' def summary(ui, repo, **opts):' | |||||
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: |
@@ -1060,7 +1060,7 b' def debugdiscovery(ui, repo, remoteurl=b' | |||||
1060 |
|
1060 | |||
1061 | if not remote_revs: |
|
1061 | if not remote_revs: | |
1062 |
|
1062 | |||
1063 |
remoteurl, branches = |
|
1063 | remoteurl, branches = urlutil.parseurl(ui.expandpath(remoteurl)) | |
1064 | remote = hg.peer(repo, opts, remoteurl) |
|
1064 | remote = hg.peer(repo, opts, remoteurl) | |
1065 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(remoteurl)) |
|
1065 | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(remoteurl)) | |
1066 | else: |
|
1066 | else: | |
@@ -3652,7 +3652,7 b' def debugssl(ui, repo, source=None, **op' | |||||
3652 | ) |
|
3652 | ) | |
3653 | source = b"default" |
|
3653 | source = b"default" | |
3654 |
|
3654 | |||
3655 |
source, branches = |
|
3655 | source, branches = urlutil.parseurl(ui.expandpath(source)) | |
3656 | url = urlutil.url(source) |
|
3656 | url = urlutil.url(source) | |
3657 |
|
3657 | |||
3658 | defaultport = {b'https': 443, b'ssh': 22} |
|
3658 | defaultport = {b'https': 443, b'ssh': 22} | |
@@ -3762,7 +3762,7 b' def debugbackupbundle(ui, repo, *pats, *' | |||||
3762 | for backup in backups: |
|
3762 | for backup in backups: | |
3763 | # Much of this is copied from the hg incoming logic |
|
3763 | # Much of this is copied from the hg incoming logic | |
3764 | source = ui.expandpath(os.path.relpath(backup, encoding.getcwd())) |
|
3764 | source = ui.expandpath(os.path.relpath(backup, encoding.getcwd())) | |
3765 |
source, branches = |
|
3765 | source, branches = urlutil.parseurl(source, opts.get(b"branch")) | |
3766 | try: |
|
3766 | try: | |
3767 | other = hg.peer(repo, opts, source) |
|
3767 | other = hg.peer(repo, opts, source) | |
3768 | except error.LookupError as ex: |
|
3768 | except error.LookupError as ex: |
@@ -132,13 +132,9 b' def addbranchrevs(lrepo, other, branches' | |||||
132 |
|
132 | |||
133 | def parseurl(path, branches=None): |
|
133 | def parseurl(path, branches=None): | |
134 | '''parse url#branch, returning (url, (branch, branches))''' |
|
134 | '''parse url#branch, returning (url, (branch, branches))''' | |
135 |
|
135 | msg = b'parseurl(...) moved to mercurial.utils.urlutil' | ||
136 | u = urlutil.url(path) |
|
136 | util.nouideprecwarn(msg, b'6.0', stacklevel=2) | |
137 | branch = None |
|
137 | return urlutil.parseurl(path, branches=branches) | |
138 | if u.fragment: |
|
|||
139 | branch = u.fragment |
|
|||
140 | u.fragment = None |
|
|||
141 | return bytes(u), (branch, branches or []) |
|
|||
142 |
|
138 | |||
143 |
|
139 | |||
144 | schemes = { |
|
140 | schemes = { | |
@@ -285,7 +281,7 b' def sharedreposource(repo):' | |||||
285 |
|
281 | |||
286 | # the sharedpath always ends in the .hg; we want the path to the repo |
|
282 | # the sharedpath always ends in the .hg; we want the path to the repo | |
287 | source = repo.vfs.split(repo.sharedpath)[0] |
|
283 | source = repo.vfs.split(repo.sharedpath)[0] | |
288 | srcurl, branches = parseurl(source) |
|
284 | srcurl, branches = urlutil.parseurl(source) | |
289 | srcrepo = repository(repo.ui, srcurl) |
|
285 | srcrepo = repository(repo.ui, srcurl) | |
290 | repo.srcrepo = srcrepo |
|
286 | repo.srcrepo = srcrepo | |
291 | return srcrepo |
|
287 | return srcrepo | |
@@ -312,7 +308,7 b' def share(' | |||||
312 |
|
308 | |||
313 | if isinstance(source, bytes): |
|
309 | if isinstance(source, bytes): | |
314 | origsource = ui.expandpath(source) |
|
310 | origsource = ui.expandpath(source) | |
315 | source, branches = parseurl(origsource) |
|
311 | source, branches = urlutil.parseurl(origsource) | |
316 | srcrepo = repository(ui, source) |
|
312 | srcrepo = repository(ui, source) | |
317 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) |
|
313 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) | |
318 | else: |
|
314 | else: | |
@@ -676,7 +672,7 b' def clone(' | |||||
676 |
|
672 | |||
677 | if isinstance(source, bytes): |
|
673 | if isinstance(source, bytes): | |
678 | origsource = ui.expandpath(source) |
|
674 | origsource = ui.expandpath(source) | |
679 | source, branches = parseurl(origsource, branch) |
|
675 | source, branches = urlutil.parseurl(origsource, branch) | |
680 | srcpeer = peer(ui, peeropts, source) |
|
676 | srcpeer = peer(ui, peeropts, source) | |
681 | else: |
|
677 | else: | |
682 | srcpeer = source.peer() # in case we were called with a localrepo |
|
678 | srcpeer = source.peer() # in case we were called with a localrepo | |
@@ -1266,7 +1262,9 b' def _incoming(' | |||||
1266 | (remoterepo, incomingchangesetlist, displayer) parameters, |
|
1262 | (remoterepo, incomingchangesetlist, displayer) parameters, | |
1267 | and is supposed to contain only code that can't be unified. |
|
1263 | and is supposed to contain only code that can't be unified. | |
1268 | """ |
|
1264 | """ | |
1269 | source, branches = parseurl(ui.expandpath(source), opts.get(b'branch')) |
|
1265 | source, branches = urlutil.parseurl( | |
|
1266 | ui.expandpath(source), opts.get(b'branch') | |||
|
1267 | ) | |||
1270 | other = peer(repo, opts, source) |
|
1268 | other = peer(repo, opts, source) | |
1271 | cleanupfn = other.close |
|
1269 | cleanupfn = other.close | |
1272 | try: |
|
1270 | try: |
@@ -41,6 +41,7 b' from . import (' | |||||
41 | from .utils import ( |
|
41 | from .utils import ( | |
42 | dateutil, |
|
42 | dateutil, | |
43 | stringutil, |
|
43 | stringutil, | |
|
44 | urlutil, | |||
44 | ) |
|
45 | ) | |
45 |
|
46 | |||
46 | # helpers for processing parsed tree |
|
47 | # helpers for processing parsed tree | |
@@ -2122,7 +2123,7 b' def remote(repo, subset, x):' | |||||
2122 | # i18n: "remote" is a keyword |
|
2123 | # i18n: "remote" is a keyword | |
2123 | dest = getstring(l[1], _(b"remote requires a repository path")) |
|
2124 | dest = getstring(l[1], _(b"remote requires a repository path")) | |
2124 | dest = repo.ui.expandpath(dest or b'default') |
|
2125 | dest = repo.ui.expandpath(dest or b'default') | |
2125 |
dest, branches = |
|
2126 | dest, branches = urlutil.parseurl(dest) | |
2126 |
|
2127 | |||
2127 | other = hg.peer(repo, {}, dest) |
|
2128 | other = hg.peer(repo, {}, dest) | |
2128 | n = other.lookup(q) |
|
2129 | n = other.lookup(q) |
@@ -445,6 +445,16 b' def removeauth(u):' | |||||
445 | return bytes(u) |
|
445 | return bytes(u) | |
446 |
|
446 | |||
447 |
|
447 | |||
|
448 | def parseurl(path, branches=None): | |||
|
449 | '''parse url#branch, returning (url, (branch, branches))''' | |||
|
450 | u = url(path) | |||
|
451 | branch = None | |||
|
452 | if u.fragment: | |||
|
453 | branch = u.fragment | |||
|
454 | u.fragment = None | |||
|
455 | return bytes(u), (branch, branches or []) | |||
|
456 | ||||
|
457 | ||||
448 | class paths(dict): |
|
458 | class paths(dict): | |
449 | """Represents a collection of paths and their configs. |
|
459 | """Represents a collection of paths and their configs. | |
450 |
|
460 |
@@ -2,44 +2,48 b' from __future__ import absolute_import, ' | |||||
2 |
|
2 | |||
3 | import unittest |
|
3 | import unittest | |
4 |
|
4 | |||
5 |
from mercurial import |
|
5 | from mercurial.utils import urlutil | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | class ParseRequestTests(unittest.TestCase): |
|
8 | class ParseRequestTests(unittest.TestCase): | |
9 | def testparse(self): |
|
9 | def testparse(self): | |
10 |
|
10 | |||
11 | self.assertEqual( |
|
11 | self.assertEqual( | |
12 |
|
|
12 | urlutil.parseurl(b'http://example.com/no/anchor'), | |
13 | (b'http://example.com/no/anchor', (None, [])), |
|
13 | (b'http://example.com/no/anchor', (None, [])), | |
14 | ) |
|
14 | ) | |
15 | self.assertEqual( |
|
15 | self.assertEqual( | |
16 |
|
|
16 | urlutil.parseurl(b'http://example.com/an/anchor#foo'), | |
17 | (b'http://example.com/an/anchor', (b'foo', [])), |
|
17 | (b'http://example.com/an/anchor', (b'foo', [])), | |
18 | ) |
|
18 | ) | |
19 | self.assertEqual( |
|
19 | self.assertEqual( | |
20 | hg.parseurl(b'http://example.com/no/anchor/branches', [b'foo']), |
|
20 | urlutil.parseurl( | |
|
21 | b'http://example.com/no/anchor/branches', [b'foo'] | |||
|
22 | ), | |||
21 | (b'http://example.com/no/anchor/branches', (None, [b'foo'])), |
|
23 | (b'http://example.com/no/anchor/branches', (None, [b'foo'])), | |
22 | ) |
|
24 | ) | |
23 | self.assertEqual( |
|
25 | self.assertEqual( | |
24 | hg.parseurl(b'http://example.com/an/anchor/branches#bar', [b'foo']), |
|
26 | urlutil.parseurl( | |
|
27 | b'http://example.com/an/anchor/branches#bar', [b'foo'] | |||
|
28 | ), | |||
25 | (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])), |
|
29 | (b'http://example.com/an/anchor/branches', (b'bar', [b'foo'])), | |
26 | ) |
|
30 | ) | |
27 | self.assertEqual( |
|
31 | self.assertEqual( | |
28 |
|
|
32 | urlutil.parseurl( | |
29 | b'http://example.com/an/anchor/branches-None#foo', None |
|
33 | b'http://example.com/an/anchor/branches-None#foo', None | |
30 | ), |
|
34 | ), | |
31 | (b'http://example.com/an/anchor/branches-None', (b'foo', [])), |
|
35 | (b'http://example.com/an/anchor/branches-None', (b'foo', [])), | |
32 | ) |
|
36 | ) | |
33 | self.assertEqual( |
|
37 | self.assertEqual( | |
34 |
|
|
38 | urlutil.parseurl(b'http://example.com/'), | |
35 | (b'http://example.com/', (None, [])), |
|
39 | (b'http://example.com/', (None, [])), | |
36 | ) |
|
40 | ) | |
37 | self.assertEqual( |
|
41 | self.assertEqual( | |
38 |
|
|
42 | urlutil.parseurl(b'http://example.com'), | |
39 | (b'http://example.com/', (None, [])), |
|
43 | (b'http://example.com/', (None, [])), | |
40 | ) |
|
44 | ) | |
41 | self.assertEqual( |
|
45 | self.assertEqual( | |
42 |
|
|
46 | urlutil.parseurl(b'http://example.com#foo'), | |
43 | (b'http://example.com/', (b'foo', [])), |
|
47 | (b'http://example.com/', (b'foo', [])), | |
44 | ) |
|
48 | ) | |
45 |
|
49 |
General Comments 0
You need to be logged in to leave comments.
Login now