Mercurial > hg
comparison mercurial/utils/urlutil.py @ 47411:515014d72aa2
urlutil: byteify several localized messages
Flagged by pytype.
Differential Revision: https://phab.mercurial-scm.org/D10872
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 11 Jun 2021 23:51:27 -0400 |
parents | 65333ecc8b34 |
children | c887bab2dccf |
comparison
equal
deleted
inserted
replaced
47410:65333ecc8b34 | 47411:515014d72aa2 |
---|---|
536 else: | 536 else: |
537 dests = [dest] | 537 dests = [dest] |
538 dests = list(get_push_paths(repo, ui, dests)) | 538 dests = list(get_push_paths(repo, ui, dests)) |
539 if len(dests) != 1: | 539 if len(dests) != 1: |
540 if dest is None: | 540 if dest is None: |
541 msg = _("default path points to %d urls while %s only supports one") | 541 msg = _( |
542 b"default path points to %d urls while %s only supports one" | |
543 ) | |
542 msg %= (len(dests), action) | 544 msg %= (len(dests), action) |
543 else: | 545 else: |
544 msg = _("path points to %d urls while %s only supports one: %s") | 546 msg = _(b"path points to %d urls while %s only supports one: %s") |
545 msg %= (len(dests), action, dest) | 547 msg %= (len(dests), action, dest) |
546 raise error.Abort(msg) | 548 raise error.Abort(msg) |
547 return dests[0] | 549 return dests[0] |
548 | 550 |
549 | 551 |
555 | 557 |
556 Note that for now, we cannot get multiple destination so this function is "trivial". | 558 Note that for now, we cannot get multiple destination so this function is "trivial". |
557 | 559 |
558 The `action` parameter will be used for the error message. | 560 The `action` parameter will be used for the error message. |
559 """ | 561 """ |
560 urls = [] | |
561 if source is None: | |
562 if b'default' in ui.paths: | |
563 urls.extend(p.rawloc for p in ui.paths[b'default']) | |
564 else: | |
565 # XXX this is the historical default behavior, but that is not | |
566 # great, consider breaking BC on this. | |
567 urls.append(b'default') | |
568 else: | |
569 if source in ui.paths: | |
570 urls.extend(p.rawloc for p in ui.paths[source]) | |
571 else: | |
572 # Try to resolve as a local path or URI. | |
573 path = try_path(ui, source) | |
574 if path is not None: | |
575 urls.append(path.rawloc) | |
576 else: | |
577 urls.append(source) | |
578 if len(urls) != 1: | |
579 if source is None: | |
580 msg = _("default path points to %d urls while %s only supports one") | |
581 msg %= (len(urls), action) | |
582 else: | |
583 msg = _("path points to %d urls while %s only supports one: %s") | |
584 msg %= (len(urls), action, source) | |
585 raise error.Abort(msg) | |
586 return parseurl(urls[0], default_branches) | |
587 | |
588 | |
589 def get_clone_path(ui, source, default_branches=()): | |
590 """return the `(origsource, path, branch)` selected as clone source""" | |
591 urls = [] | 562 urls = [] |
592 if source is None: | 563 if source is None: |
593 if b'default' in ui.paths: | 564 if b'default' in ui.paths: |
594 urls.extend(p.rawloc for p in ui.paths[b'default']) | 565 urls.extend(p.rawloc for p in ui.paths[b'default']) |
595 else: | 566 else: |
607 else: | 578 else: |
608 urls.append(source) | 579 urls.append(source) |
609 if len(urls) != 1: | 580 if len(urls) != 1: |
610 if source is None: | 581 if source is None: |
611 msg = _( | 582 msg = _( |
612 "default path points to %d urls while only one is supported" | 583 b"default path points to %d urls while %s only supports one" |
584 ) | |
585 msg %= (len(urls), action) | |
586 else: | |
587 msg = _(b"path points to %d urls while %s only supports one: %s") | |
588 msg %= (len(urls), action, source) | |
589 raise error.Abort(msg) | |
590 return parseurl(urls[0], default_branches) | |
591 | |
592 | |
593 def get_clone_path(ui, source, default_branches=()): | |
594 """return the `(origsource, path, branch)` selected as clone source""" | |
595 urls = [] | |
596 if source is None: | |
597 if b'default' in ui.paths: | |
598 urls.extend(p.rawloc for p in ui.paths[b'default']) | |
599 else: | |
600 # XXX this is the historical default behavior, but that is not | |
601 # great, consider breaking BC on this. | |
602 urls.append(b'default') | |
603 else: | |
604 if source in ui.paths: | |
605 urls.extend(p.rawloc for p in ui.paths[source]) | |
606 else: | |
607 # Try to resolve as a local path or URI. | |
608 path = try_path(ui, source) | |
609 if path is not None: | |
610 urls.append(path.rawloc) | |
611 else: | |
612 urls.append(source) | |
613 if len(urls) != 1: | |
614 if source is None: | |
615 msg = _( | |
616 b"default path points to %d urls while only one is supported" | |
613 ) | 617 ) |
614 msg %= len(urls) | 618 msg %= len(urls) |
615 else: | 619 else: |
616 msg = _("path points to %d urls while only one is supported: %s") | 620 msg = _(b"path points to %d urls while only one is supported: %s") |
617 msg %= (len(urls), source) | 621 msg %= (len(urls), source) |
618 raise error.Abort(msg) | 622 raise error.Abort(msg) |
619 url = urls[0] | 623 url = urls[0] |
620 clone_path, branch = parseurl(url, default_branches) | 624 clone_path, branch = parseurl(url, default_branches) |
621 return url, clone_path, branch | 625 return url, clone_path, branch |