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