Show More
@@ -667,11 +667,16 b' def showpeerurls(context, mapping):' | |||||
667 | urls = util.sortdict((k, p.rawloc) for k, p in all_paths) |
|
667 | urls = util.sortdict((k, p.rawloc) for k, p in all_paths) | |
668 |
|
668 | |||
669 | def makemap(k): |
|
669 | def makemap(k): | |
670 | p = paths[k] |
|
670 | ps = paths[k] | |
671 |
d = {b'name': k |
|
671 | d = {b'name': k} | |
672 | sub_opts = util.sortdict(sorted(pycompat.iteritems(p.suboptions))) |
|
672 | if len(ps) == 1: | |
|
673 | d[b'url'] = ps[0].rawloc | |||
|
674 | sub_opts = pycompat.iteritems(ps[0].suboptions) | |||
|
675 | sub_opts = util.sortdict(sorted(sub_opts)) | |||
673 | d.update(sub_opts) |
|
676 | d.update(sub_opts) | |
674 | path_dict = util.sortdict() |
|
677 | path_dict = util.sortdict() | |
|
678 | for p in ps: | |||
|
679 | sub_opts = util.sortdict(sorted(pycompat.iteritems(p.suboptions))) | |||
675 | path_dict[b'url'] = p.rawloc |
|
680 | path_dict[b'url'] = p.rawloc | |
676 | path_dict.update(sub_opts) |
|
681 | path_dict.update(sub_opts) | |
677 | d[b'urls'] = [path_dict] |
|
682 | d[b'urls'] = [path_dict] |
@@ -447,14 +447,16 b' def removeauth(u):' | |||||
447 |
|
447 | |||
448 | def list_paths(ui, target_path=None): |
|
448 | def list_paths(ui, target_path=None): | |
449 | """list all the (name, paths) in the passed ui""" |
|
449 | """list all the (name, paths) in the passed ui""" | |
|
450 | result = [] | |||
450 | if target_path is None: |
|
451 | if target_path is None: | |
451 |
|
|
452 | for name, paths in sorted(pycompat.iteritems(ui.paths)): | |
|
453 | for p in paths: | |||
|
454 | result.append((name, p)) | |||
|
455 | ||||
452 | else: |
|
456 | else: | |
453 |
path |
|
457 | for path in ui.paths.get(target_path, []): | |
454 | if path is None: |
|
458 | result.append((target_path, path)) | |
455 | return [] |
|
459 | return result | |
456 | else: |
|
|||
457 | return [(target_path, path)] |
|
|||
458 |
|
460 | |||
459 |
|
461 | |||
460 | def try_path(ui, url): |
|
462 | def try_path(ui, url): | |
@@ -473,9 +475,11 b' def get_push_paths(repo, ui, dests):' | |||||
473 | """yields all the `path` selected as push destination by `dests`""" |
|
475 | """yields all the `path` selected as push destination by `dests`""" | |
474 | if not dests: |
|
476 | if not dests: | |
475 | if b'default-push' in ui.paths: |
|
477 | if b'default-push' in ui.paths: | |
476 |
|
|
478 | for p in ui.paths[b'default-push']: | |
|
479 | yield p | |||
477 | elif b'default' in ui.paths: |
|
480 | elif b'default' in ui.paths: | |
478 |
|
|
481 | for p in ui.paths[b'default']: | |
|
482 | yield p | |||
479 | else: |
|
483 | else: | |
480 | raise error.ConfigError( |
|
484 | raise error.ConfigError( | |
481 | _(b'default repository not configured!'), |
|
485 | _(b'default repository not configured!'), | |
@@ -484,7 +488,8 b' def get_push_paths(repo, ui, dests):' | |||||
484 | else: |
|
488 | else: | |
485 | for dest in dests: |
|
489 | for dest in dests: | |
486 | if dest in ui.paths: |
|
490 | if dest in ui.paths: | |
487 |
|
|
491 | for p in ui.paths[dest]: | |
|
492 | yield p | |||
488 | else: |
|
493 | else: | |
489 | path = try_path(ui, dest) |
|
494 | path = try_path(ui, dest) | |
490 | if path is None: |
|
495 | if path is None: | |
@@ -500,7 +505,8 b' def get_pull_paths(repo, ui, sources, de' | |||||
500 | sources = [b'default'] |
|
505 | sources = [b'default'] | |
501 | for source in sources: |
|
506 | for source in sources: | |
502 | if source in ui.paths: |
|
507 | if source in ui.paths: | |
503 |
|
|
508 | for p in ui.paths[source]: | |
|
509 | yield parseurl(p.rawloc, default_branches) | |||
504 | else: |
|
510 | else: | |
505 | # Try to resolve as a local path or URI. |
|
511 | # Try to resolve as a local path or URI. | |
506 | path = try_path(ui, source) |
|
512 | path = try_path(ui, source) | |
@@ -526,7 +532,14 b' def get_unique_push_path(action, repo, u' | |||||
526 | else: |
|
532 | else: | |
527 | dests = [dest] |
|
533 | dests = [dest] | |
528 | dests = list(get_push_paths(repo, ui, dests)) |
|
534 | dests = list(get_push_paths(repo, ui, dests)) | |
529 |
|
|
535 | if len(dests) != 1: | |
|
536 | if dest is None: | |||
|
537 | msg = _("default path points to %d urls while %s only supports one") | |||
|
538 | msg %= (len(dests), action) | |||
|
539 | else: | |||
|
540 | msg = _("path points to %d urls while %s only supports one: %s") | |||
|
541 | msg %= (len(dests), action, dest) | |||
|
542 | raise error.Abort(msg) | |||
530 | return dests[0] |
|
543 | return dests[0] | |
531 |
|
544 | |||
532 |
|
545 | |||
@@ -540,45 +553,66 b' def get_unique_pull_path(action, repo, u' | |||||
540 |
|
553 | |||
541 | The `action` parameter will be used for the error message. |
|
554 | The `action` parameter will be used for the error message. | |
542 | """ |
|
555 | """ | |
|
556 | urls = [] | |||
543 | if source is None: |
|
557 | if source is None: | |
544 | if b'default' in ui.paths: |
|
558 | if b'default' in ui.paths: | |
545 |
url |
|
559 | urls.extend(p.rawloc for p in ui.paths[b'default']) | |
546 | else: |
|
560 | else: | |
547 | # XXX this is the historical default behavior, but that is not |
|
561 | # XXX this is the historical default behavior, but that is not | |
548 | # great, consider breaking BC on this. |
|
562 | # great, consider breaking BC on this. | |
549 |
url |
|
563 | urls.append(b'default') | |
550 | else: |
|
564 | else: | |
551 | if source in ui.paths: |
|
565 | if source in ui.paths: | |
552 |
url |
|
566 | urls.extend(p.rawloc for p in ui.paths[source]) | |
553 | else: |
|
567 | else: | |
554 | # Try to resolve as a local path or URI. |
|
568 | # Try to resolve as a local path or URI. | |
555 | path = try_path(ui, source) |
|
569 | path = try_path(ui, source) | |
556 | if path is not None: |
|
570 | if path is not None: | |
557 |
url |
|
571 | urls.append(path.rawloc) | |
558 | else: |
|
572 | else: | |
559 |
url |
|
573 | urls.append(source) | |
560 | return parseurl(url, default_branches) |
|
574 | if len(urls) != 1: | |
|
575 | if source is None: | |||
|
576 | msg = _("default path points to %d urls while %s only supports one") | |||
|
577 | msg %= (len(urls), action) | |||
|
578 | else: | |||
|
579 | msg = _("path points to %d urls while %s only supports one: %s") | |||
|
580 | msg %= (len(urls), action, source) | |||
|
581 | raise error.Abort(msg) | |||
|
582 | return parseurl(urls[0], default_branches) | |||
561 |
|
583 | |||
562 |
|
584 | |||
563 | def get_clone_path(ui, source, default_branches=()): |
|
585 | def get_clone_path(ui, source, default_branches=()): | |
564 | """return the `(origsource, path, branch)` selected as clone source""" |
|
586 | """return the `(origsource, path, branch)` selected as clone source""" | |
|
587 | urls = [] | |||
565 | if source is None: |
|
588 | if source is None: | |
566 | if b'default' in ui.paths: |
|
589 | if b'default' in ui.paths: | |
567 |
url |
|
590 | urls.extend(p.rawloc for p in ui.paths[b'default']) | |
568 | else: |
|
591 | else: | |
569 | # XXX this is the historical default behavior, but that is not |
|
592 | # XXX this is the historical default behavior, but that is not | |
570 | # great, consider breaking BC on this. |
|
593 | # great, consider breaking BC on this. | |
571 |
url |
|
594 | urls.append(b'default') | |
572 | else: |
|
595 | else: | |
573 | if source in ui.paths: |
|
596 | if source in ui.paths: | |
574 |
url |
|
597 | urls.extend(p.rawloc for p in ui.paths[source]) | |
575 | else: |
|
598 | else: | |
576 | # Try to resolve as a local path or URI. |
|
599 | # Try to resolve as a local path or URI. | |
577 | path = try_path(ui, source) |
|
600 | path = try_path(ui, source) | |
578 | if path is not None: |
|
601 | if path is not None: | |
579 |
url |
|
602 | urls.append(path.rawloc) | |
580 | else: |
|
603 | else: | |
581 |
url |
|
604 | urls.append(source) | |
|
605 | if len(urls) != 1: | |||
|
606 | if source is None: | |||
|
607 | msg = _( | |||
|
608 | "default path points to %d urls while only one is supported" | |||
|
609 | ) | |||
|
610 | msg %= len(urls) | |||
|
611 | else: | |||
|
612 | msg = _("path points to %d urls while only one is supported: %s") | |||
|
613 | msg %= (len(urls), source) | |||
|
614 | raise error.Abort(msg) | |||
|
615 | url = urls[0] | |||
582 | clone_path, branch = parseurl(url, default_branches) |
|
616 | clone_path, branch = parseurl(url, default_branches) | |
583 | return url, clone_path, branch |
|
617 | return url, clone_path, branch | |
584 |
|
618 | |||
@@ -608,10 +642,13 b' class paths(dict):' | |||||
608 | if not loc: |
|
642 | if not loc: | |
609 | continue |
|
643 | continue | |
610 | loc, sub_opts = ui.configsuboptions(b'paths', name) |
|
644 | loc, sub_opts = ui.configsuboptions(b'paths', name) | |
611 | self[name] = path(ui, name, rawloc=loc, suboptions=sub_opts) |
|
645 | self[name] = [path(ui, name, rawloc=loc, suboptions=sub_opts)] | |
612 |
|
646 | |||
613 | for name, p in sorted(self.items()): |
|
647 | for name, old_paths in sorted(self.items()): | |
614 | self[name] = _chain_path(p, ui, self) |
|
648 | new_paths = [] | |
|
649 | for p in old_paths: | |||
|
650 | new_paths.extend(_chain_path(p, ui, self)) | |||
|
651 | self[name] = new_paths | |||
615 |
|
652 | |||
616 | def getpath(self, ui, name, default=None): |
|
653 | def getpath(self, ui, name, default=None): | |
617 | """Return a ``path`` from a string, falling back to default. |
|
654 | """Return a ``path`` from a string, falling back to default. | |
@@ -632,7 +669,7 b' class paths(dict):' | |||||
632 | default = (default,) |
|
669 | default = (default,) | |
633 | for k in default: |
|
670 | for k in default: | |
634 | try: |
|
671 | try: | |
635 | return self[k] |
|
672 | return self[k][0] | |
636 | except KeyError: |
|
673 | except KeyError: | |
637 | continue |
|
674 | continue | |
638 | return None |
|
675 | return None | |
@@ -642,7 +679,7 b' class paths(dict):' | |||||
642 | if not name: |
|
679 | if not name: | |
643 | return None |
|
680 | return None | |
644 | if name in self: |
|
681 | if name in self: | |
645 | return self[name] |
|
682 | return self[name][0] | |
646 | else: |
|
683 | else: | |
647 | # Try to resolve as a local path or URI. |
|
684 | # Try to resolve as a local path or URI. | |
648 | path = try_path(ui, name) |
|
685 | path = try_path(ui, name) | |
@@ -704,15 +741,20 b' def pushrevpathoption(ui, path, value):' | |||||
704 | return value |
|
741 | return value | |
705 |
|
742 | |||
706 |
|
743 | |||
707 | def _chain_path(path, ui, paths): |
|
744 | def _chain_path(base_path, ui, paths): | |
708 | """return the result of "path://" logic applied on a given path""" |
|
745 | """return the result of "path://" logic applied on a given path""" | |
709 | if path.url.scheme == b'path': |
|
746 | new_paths = [] | |
710 | assert path.url.path is None |
|
747 | if base_path.url.scheme != b'path': | |
711 | subpath = paths.get(path.url.host) |
|
748 | new_paths.append(base_path) | |
712 | if subpath is None: |
|
749 | else: | |
|
750 | assert base_path.url.path is None | |||
|
751 | sub_paths = paths.get(base_path.url.host) | |||
|
752 | if sub_paths is None: | |||
713 | m = _(b'cannot use `%s`, "%s" is not a known path') |
|
753 | m = _(b'cannot use `%s`, "%s" is not a known path') | |
714 | m %= (path.rawloc, path.url.host) |
|
754 | m %= (base_path.rawloc, base_path.url.host) | |
715 | raise error.Abort(m) |
|
755 | raise error.Abort(m) | |
|
756 | for subpath in sub_paths: | |||
|
757 | path = base_path.copy() | |||
716 | if subpath.raw_url.scheme == b'path': |
|
758 | if subpath.raw_url.scheme == b'path': | |
717 | m = _(b'cannot use `%s`, "%s" is also defined as a `path://`') |
|
759 | m = _(b'cannot use `%s`, "%s" is also defined as a `path://`') | |
718 | m %= (path.rawloc, path.url.host) |
|
760 | m %= (path.rawloc, path.url.host) | |
@@ -728,7 +770,8 b' def _chain_path(path, ui, paths):' | |||||
728 | suboptions = subpath._all_sub_opts.copy() |
|
770 | suboptions = subpath._all_sub_opts.copy() | |
729 | suboptions.update(path._own_sub_opts) |
|
771 | suboptions.update(path._own_sub_opts) | |
730 | path._apply_suboptions(ui, suboptions) |
|
772 | path._apply_suboptions(ui, suboptions) | |
731 | return path |
|
773 | new_paths.append(path) | |
|
774 | return new_paths | |||
732 |
|
775 | |||
733 |
|
776 | |||
734 | class path(object): |
|
777 | class path(object): |
General Comments 0
You need to be logged in to leave comments.
Login now