548 This is useful for command and action that does not support multiple |
548 This is useful for command and action that does not support multiple |
549 destination (yet). |
549 destination (yet). |
550 |
550 |
551 The `action` parameter will be used for the error message. |
551 The `action` parameter will be used for the error message. |
552 """ |
552 """ |
553 urls = [] |
553 sources = [] |
554 if source is None: |
554 if source is not None: |
555 if b'default' in ui.paths: |
555 sources.append(source) |
556 urls.extend(p.rawloc for p in ui.paths[b'default']) |
556 |
557 else: |
557 pull_paths = list(get_pull_paths(repo, ui, sources=sources)) |
558 # XXX this is the historical default behavior, but that is not |
558 path_count = len(pull_paths) |
559 # great, consider breaking BC on this. |
559 if path_count != 1: |
560 urls.append(b'default') |
|
561 else: |
|
562 if source in ui.paths: |
|
563 urls.extend(p.rawloc for p in ui.paths[source]) |
|
564 else: |
|
565 # Try to resolve as a local path or URI. |
|
566 path = try_path(ui, source) |
|
567 if path is not None: |
|
568 urls.append(path.rawloc) |
|
569 else: |
|
570 urls.append(source) |
|
571 if len(urls) != 1: |
|
572 if source is None: |
560 if source is None: |
573 msg = _( |
561 msg = _( |
574 b"default path points to %d urls while %s only supports one" |
562 b"default path points to %d urls while %s only supports one" |
575 ) |
563 ) |
576 msg %= (len(urls), action) |
564 msg %= (path_count, action) |
577 else: |
565 else: |
578 msg = _(b"path points to %d urls while %s only supports one: %s") |
566 msg = _(b"path points to %d urls while %s only supports one: %s") |
579 msg %= (len(urls), action, source) |
567 msg %= (path_count, action, source) |
580 raise error.Abort(msg) |
568 raise error.Abort(msg) |
581 return parseurl(urls[0], default_branches) |
569 return parseurl(pull_paths[0].rawloc, default_branches) |
582 |
570 |
583 |
571 |
584 def get_clone_path(ui, source, default_branches=()): |
572 def get_clone_path(ui, source, default_branches=()): |
585 """return the `(origsource, path, branch)` selected as clone source""" |
573 """return the `(origsource, path, branch)` selected as clone source""" |
586 urls = [] |
574 urls = [] |