29 if not remote: |
29 if not remote: |
30 lfpullsource = getattr(repo, 'lfpullsource', None) |
30 lfpullsource = getattr(repo, 'lfpullsource', None) |
31 if lfpullsource: |
31 if lfpullsource: |
32 path = ui.expandpath(lfpullsource) |
32 path = ui.expandpath(lfpullsource) |
33 elif put: |
33 elif put: |
34 path = ui.expandpath('default-push', 'default') |
34 path = ui.expandpath(b'default-push', b'default') |
35 else: |
35 else: |
36 path = ui.expandpath('default') |
36 path = ui.expandpath(b'default') |
37 |
37 |
38 # ui.expandpath() leaves 'default-push' and 'default' alone if |
38 # ui.expandpath() leaves 'default-push' and 'default' alone if |
39 # they cannot be expanded: fallback to the empty string, |
39 # they cannot be expanded: fallback to the empty string, |
40 # meaning the current directory. |
40 # meaning the current directory. |
41 if repo is None: |
41 if repo is None: |
42 path = ui.expandpath('default') |
42 path = ui.expandpath(b'default') |
43 path, _branches = hg.parseurl(path) |
43 path, _branches = hg.parseurl(path) |
44 remote = hg.peer(repo or ui, {}, path) |
44 remote = hg.peer(repo or ui, {}, path) |
45 elif path == 'default-push' or path == 'default': |
45 elif path == b'default-push' or path == b'default': |
46 remote = repo |
46 remote = repo |
47 else: |
47 else: |
48 path, _branches = hg.parseurl(path) |
48 path, _branches = hg.parseurl(path) |
49 remote = hg.peer(repo or ui, {}, path) |
49 remote = hg.peer(repo or ui, {}, path) |
50 |
50 |
51 # The path could be a scheme so use Mercurial's normal functionality |
51 # The path could be a scheme so use Mercurial's normal functionality |
52 # to resolve the scheme to a repository and use its path |
52 # to resolve the scheme to a repository and use its path |
53 path = util.safehasattr(remote, 'url') and remote.url() or remote.path |
53 path = util.safehasattr(remote, b'url') and remote.url() or remote.path |
54 |
54 |
55 match = _scheme_re.match(path) |
55 match = _scheme_re.match(path) |
56 if not match: # regular filesystem path |
56 if not match: # regular filesystem path |
57 scheme = 'file' |
57 scheme = b'file' |
58 else: |
58 else: |
59 scheme = match.group(1) |
59 scheme = match.group(1) |
60 |
60 |
61 try: |
61 try: |
62 storeproviders = _storeprovider[scheme] |
62 storeproviders = _storeprovider[scheme] |
63 except KeyError: |
63 except KeyError: |
64 raise error.Abort(_('unsupported URL scheme %r') % scheme) |
64 raise error.Abort(_(b'unsupported URL scheme %r') % scheme) |
65 |
65 |
66 for classobj in storeproviders: |
66 for classobj in storeproviders: |
67 try: |
67 try: |
68 return classobj(ui, repo, remote) |
68 return classobj(ui, repo, remote) |
69 except lfutil.storeprotonotcapable: |
69 except lfutil.storeprotonotcapable: |
70 pass |
70 pass |
71 |
71 |
72 raise error.Abort( |
72 raise error.Abort( |
73 _('%s does not appear to be a largefile store') |
73 _(b'%s does not appear to be a largefile store') |
74 % util.hidepassword(path) |
74 % util.hidepassword(path) |
75 ) |
75 ) |
76 |
76 |
77 |
77 |
78 _storeprovider = { |
78 _storeprovider = { |
79 'file': [localstore.localstore], |
79 b'file': [localstore.localstore], |
80 'http': [wirestore.wirestore], |
80 b'http': [wirestore.wirestore], |
81 'https': [wirestore.wirestore], |
81 b'https': [wirestore.wirestore], |
82 'ssh': [wirestore.wirestore], |
82 b'ssh': [wirestore.wirestore], |
83 } |
83 } |
84 |
84 |
85 _scheme_re = re.compile(br'^([a-zA-Z0-9+-.]+)://') |
85 _scheme_re = re.compile(br'^([a-zA-Z0-9+-.]+)://') |
86 |
86 |
87 |
87 |