Show More
@@ -24,6 +24,8 b' from mercurial import demandimport' | |||
|
24 | 24 | |
|
25 | 25 | # patch demandimport, due to bug in mercurial when it always triggers |
|
26 | 26 | # demandimport.enable() |
|
27 | from vcsserver.utils import safe_bytes | |
|
28 | ||
|
27 | 29 | demandimport.enable = lambda *args, **kwargs: 1 |
|
28 | 30 | |
|
29 | 31 | from mercurial import ui |
@@ -70,6 +72,7 b' from mercurial import strip as hgext_str' | |||
|
70 | 72 | |
|
71 | 73 | |
|
72 | 74 | def get_ctx(repo, ref): |
|
75 | ref = safe_bytes(ref) | |
|
73 | 76 | try: |
|
74 | 77 | ctx = repo[ref] |
|
75 | 78 | except (ProgrammingError, TypeError): |
@@ -39,7 +39,7 b' from vcsserver.hgcompat import (' | |||
|
39 | 39 | patch, peer, revrange, ui, hg_tag, Abort, LookupError, RepoError, |
|
40 | 40 | RepoLookupError, InterventionRequired, RequirementError, |
|
41 | 41 | alwaysmatcher, patternmatcher, hgutil, hgext_strip) |
|
42 | from vcsserver.utils import ascii_bytes, ascii_str, safe_str | |
|
42 | from vcsserver.utils import ascii_bytes, ascii_str, safe_str, safe_bytes | |
|
43 | 43 | from vcsserver.vcs_base import RemoteBase |
|
44 | 44 | |
|
45 | 45 | log = logging.getLogger(__name__) |
@@ -479,7 +479,7 b' class HgRemote(RemoteBase):' | |||
|
479 | 479 | repo = self._factory.repo(wire) |
|
480 | 480 | |
|
481 | 481 | ctx = self._get_ctx(repo, revision) |
|
482 | fctx = ctx.filectx(path) | |
|
482 | fctx = ctx.filectx(safe_bytes(path)) | |
|
483 | 483 | |
|
484 | 484 | def history_iter(): |
|
485 | 485 | limit_rev = fctx.rev() |
@@ -510,7 +510,7 b' class HgRemote(RemoteBase):' | |||
|
510 | 510 | def _node_history_until(_context_uid, _repo_id): |
|
511 | 511 | repo = self._factory.repo(wire) |
|
512 | 512 | ctx = self._get_ctx(repo, revision) |
|
513 | fctx = ctx.filectx(path) | |
|
513 | fctx = ctx.filectx(safe_bytes(path)) | |
|
514 | 514 | |
|
515 | 515 | file_log = list(fctx.filelog()) |
|
516 | 516 | if limit: |
@@ -524,7 +524,7 b' class HgRemote(RemoteBase):' | |||
|
524 | 524 | def fctx_annotate(self, wire, revision, path): |
|
525 | 525 | repo = self._factory.repo(wire) |
|
526 | 526 | ctx = self._get_ctx(repo, revision) |
|
527 | fctx = ctx.filectx(path) | |
|
527 | fctx = ctx.filectx(safe_bytes(path)) | |
|
528 | 528 | |
|
529 | 529 | result = [] |
|
530 | 530 | for i, annotate_obj in enumerate(fctx.annotate(), 1): |
@@ -538,18 +538,19 b' class HgRemote(RemoteBase):' | |||
|
538 | 538 | def fctx_node_data(self, wire, revision, path): |
|
539 | 539 | repo = self._factory.repo(wire) |
|
540 | 540 | ctx = self._get_ctx(repo, revision) |
|
541 | fctx = ctx.filectx(path) | |
|
542 |
return fctx.data |
|
|
541 | fctx = ctx.filectx(safe_bytes(path)) | |
|
542 | return fctx.data() | |
|
543 | 543 | |
|
544 | 544 | @reraise_safe_exceptions |
|
545 | 545 | def fctx_flags(self, wire, commit_id, path): |
|
546 | 546 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
547 | 547 | region = self._region(wire) |
|
548 | ||
|
548 | 549 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
549 | 550 | def _fctx_flags(_repo_id, _commit_id, _path): |
|
550 | 551 | repo = self._factory.repo(wire) |
|
551 | 552 | ctx = self._get_ctx(repo, commit_id) |
|
552 | fctx = ctx.filectx(path) | |
|
553 | fctx = ctx.filectx(safe_bytes(path)) | |
|
553 | 554 | return fctx.flags() |
|
554 | 555 | |
|
555 | 556 | return _fctx_flags(repo_id, commit_id, path) |
@@ -558,11 +559,12 b' class HgRemote(RemoteBase):' | |||
|
558 | 559 | def fctx_size(self, wire, commit_id, path): |
|
559 | 560 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
560 | 561 | region = self._region(wire) |
|
562 | ||
|
561 | 563 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
562 | 564 | def _fctx_size(_repo_id, _revision, _path): |
|
563 | 565 | repo = self._factory.repo(wire) |
|
564 | 566 | ctx = self._get_ctx(repo, commit_id) |
|
565 | fctx = ctx.filectx(path) | |
|
567 | fctx = ctx.filectx(safe_bytes(path)) | |
|
566 | 568 | return fctx.size() |
|
567 | 569 | return _fctx_size(repo_id, commit_id, path) |
|
568 | 570 | |
@@ -574,7 +576,6 b' class HgRemote(RemoteBase):' | |||
|
574 | 576 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
575 | 577 | def _get_all_commit_ids(_context_uid, _repo_id, _name): |
|
576 | 578 | repo = self._factory.repo(wire) |
|
577 | repo = repo.filtered(name) | |
|
578 | 579 | revs = [ascii_str(repo[x].hex()) for x in repo.filtered(b'visible').changelog.revs()] |
|
579 | 580 | return revs |
|
580 | 581 | return _get_all_commit_ids(context_uid, repo_id, name) |
@@ -591,7 +592,7 b' class HgRemote(RemoteBase):' | |||
|
591 | 592 | |
|
592 | 593 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
593 | 594 | def _is_large_file(_context_uid, _repo_id, _commit_id, _path): |
|
594 | return largefiles.lfutil.isstandin(path) | |
|
595 | return largefiles.lfutil.isstandin(safe_bytes(path)) | |
|
595 | 596 | |
|
596 | 597 | return _is_large_file(context_uid, repo_id, commit_id, path) |
|
597 | 598 | |
@@ -604,7 +605,7 b' class HgRemote(RemoteBase):' | |||
|
604 | 605 | def _is_binary(_repo_id, _sha, _path): |
|
605 | 606 | repo = self._factory.repo(wire) |
|
606 | 607 | ctx = self._get_ctx(repo, revision) |
|
607 | fctx = ctx.filectx(path) | |
|
608 | fctx = ctx.filectx(safe_bytes(path)) | |
|
608 | 609 | return fctx.isbinary() |
|
609 | 610 | |
|
610 | 611 | return _is_binary(repo_id, revision, path) |
@@ -637,8 +638,8 b' class HgRemote(RemoteBase):' | |||
|
637 | 638 | @reraise_safe_exceptions |
|
638 | 639 | def lookup(self, wire, revision, both): |
|
639 | 640 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
641 | region = self._region(wire) | |
|
640 | 642 | |
|
641 | region = self._region(wire) | |
|
642 | 643 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
643 | 644 | def _lookup(_context_uid, _repo_id, _revision, _both): |
|
644 | 645 | |
@@ -696,12 +697,15 b' class HgRemote(RemoteBase):' | |||
|
696 | 697 | @reraise_safe_exceptions |
|
697 | 698 | def rev_range(self, wire, commit_filter): |
|
698 | 699 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
700 | region = self._region(wire) | |
|
699 | 701 | |
|
700 | region = self._region(wire) | |
|
701 | 702 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
702 | 703 | def _rev_range(_context_uid, _repo_id, _filter): |
|
703 | 704 | repo = self._factory.repo(wire) |
|
704 | revisions = [rev for rev in revrange(repo, commit_filter)] | |
|
705 | revisions = [ | |
|
706 | ascii_str(repo[rev].hex()) | |
|
707 | for rev in revrange(repo, list(map(ascii_bytes, commit_filter))) | |
|
708 | ] | |
|
705 | 709 | return revisions |
|
706 | 710 | |
|
707 | 711 | return _rev_range(context_uid, repo_id, sorted(commit_filter)) |
@@ -720,7 +724,7 b' class HgRemote(RemoteBase):' | |||
|
720 | 724 | return len(repo) - 1, 0 |
|
721 | 725 | |
|
722 | 726 | stop, start = get_revs(repo, [node + ':']) |
|
723 |
revs = [ |
|
|
727 | revs = [ascii_str(repo[r].hex()) for r in range(start, stop + 1)] | |
|
724 | 728 | return revs |
|
725 | 729 | |
|
726 | 730 | @reraise_safe_exceptions |
@@ -774,6 +778,7 b' class HgRemote(RemoteBase):' | |||
|
774 | 778 | def tags(self, wire): |
|
775 | 779 | cache_on, context_uid, repo_id = self._cache_on(wire) |
|
776 | 780 | region = self._region(wire) |
|
781 | ||
|
777 | 782 | @region.conditional_cache_on_arguments(condition=cache_on) |
|
778 | 783 | def _tags(_context_uid, _repo_id): |
|
779 | 784 | repo = self._factory.repo(wire) |
@@ -1050,7 +1055,7 b' class HgRemote(RemoteBase):' | |||
|
1050 | 1055 | mode = b'x' in flags and 0o755 or 0o644 |
|
1051 | 1056 | is_link = b'l' in flags |
|
1052 | 1057 | |
|
1053 |
yield ArchiveNode(file_path, mode, is_link, ctx[fn].data |
|
|
1058 | yield ArchiveNode(file_path, mode, is_link, ctx[fn].data) | |
|
1054 | 1059 | |
|
1055 | 1060 | return archive_repo(file_walker, archive_dest_path, kind, mtime, archive_at_path, |
|
1056 | 1061 | archive_dir_name, commit_id) |
General Comments 0
You need to be logged in to leave comments.
Login now