Mercurial > evolve
comparison hgext3rd/topic/__init__.py @ 6700:a7d94f235488
topic: remove transaction validator compatibility for hg 5.3
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 26 Oct 2023 14:49:37 -0300 |
parents | e0712a00154e |
children | f0cbc19e77ef |
comparison
equal
deleted
inserted
replaced
6698:c329bd4beaa6 | 6700:a7d94f235488 |
---|---|
841 if desc in (b'strip', b'repair') or ctr is not None: | 841 if desc in (b'strip', b'repair') or ctr is not None: |
842 return tr | 842 return tr |
843 | 843 |
844 reporef = weakref.ref(self) | 844 reporef = weakref.ref(self) |
845 if self.ui.configbool(b'experimental', b'enforce-single-head'): | 845 if self.ui.configbool(b'experimental', b'enforce-single-head'): |
846 if util.safehasattr(tr, '_validator'): | |
847 # hg <= 5.3 (36f08ae87ef6) | |
848 origvalidator_single_head = tr._validator | |
849 | |
850 def _validate_single_head(tr2): | 846 def _validate_single_head(tr2): |
851 repo = reporef() | 847 repo = reporef() |
852 flow.enforcesinglehead(repo, tr2) | 848 flow.enforcesinglehead(repo, tr2) |
853 | 849 |
854 def validator(tr2): | 850 tr.addvalidator(b'000-enforce-single-head', _validate_single_head) |
855 _validate_single_head(tr2) | |
856 return origvalidator_single_head(tr2) | |
857 | |
858 if util.safehasattr(tr, '_validator'): | |
859 # hg <= 5.3 (36f08ae87ef6) | |
860 tr._validator = validator | |
861 else: | |
862 tr.addvalidator(b'000-enforce-single-head', _validate_single_head) | |
863 | 851 |
864 topicmodeserver = self.ui.config(b'experimental', | 852 topicmodeserver = self.ui.config(b'experimental', |
865 b'topic-mode.server', b'ignore') | 853 b'topic-mode.server', b'ignore') |
866 publishbare = self.ui.configbool(b'experimental', | 854 publishbare = self.ui.configbool(b'experimental', |
867 b'topic.publish-bare-branch') | 855 b'topic.publish-bare-branch') |
868 ispush = desc.startswith((b'push', b'serve')) | 856 ispush = desc.startswith((b'push', b'serve')) |
869 if (topicmodeserver != b'ignore' and ispush): | 857 if (topicmodeserver != b'ignore' and ispush): |
870 if util.safehasattr(tr, '_validator'): | |
871 # hg <= 5.3 (36f08ae87ef6) | |
872 origvalidator_untopiced = tr._validator | |
873 | |
874 def _validate_untopiced(tr2): | 858 def _validate_untopiced(tr2): |
875 repo = reporef() | 859 repo = reporef() |
876 flow.rejectuntopicedchangeset(repo, tr2) | 860 flow.rejectuntopicedchangeset(repo, tr2) |
877 | 861 |
878 def validator(tr2): | 862 tr.addvalidator(b'000-reject-untopiced', _validate_untopiced) |
879 _validate_untopiced(tr2) | |
880 return origvalidator_untopiced(tr2) | |
881 | |
882 if util.safehasattr(tr, '_validator'): | |
883 # hg <= 5.3 (36f08ae87ef6) | |
884 tr._validator = validator | |
885 else: | |
886 tr.addvalidator(b'000-reject-untopiced', _validate_untopiced) | |
887 | 863 |
888 elif publishbare and ispush: | 864 elif publishbare and ispush: |
889 origclose = tr.close | 865 origclose = tr.close |
890 trref = weakref.ref(tr) | 866 trref = weakref.ref(tr) |
891 | 867 |
897 tr.close = close | 873 tr.close = close |
898 allow_publish = self.ui.configbool(b'experimental', | 874 allow_publish = self.ui.configbool(b'experimental', |
899 b'topic.allow-publish', | 875 b'topic.allow-publish', |
900 True) | 876 True) |
901 if not allow_publish: | 877 if not allow_publish: |
902 if util.safehasattr(tr, '_validator'): | |
903 # hg <= 5.3 (36f08ae87ef6) | |
904 origvalidator_publish = tr._validator | |
905 | |
906 def _validate_publish(tr2): | 878 def _validate_publish(tr2): |
907 repo = reporef() | 879 repo = reporef() |
908 flow.reject_publish(repo, tr2) | 880 flow.reject_publish(repo, tr2) |
909 | 881 |
910 def validator(tr2): | 882 tr.addvalidator(b'000-reject-publish', _validate_publish) |
911 _validate_publish(tr2) | |
912 return origvalidator_publish(tr2) | |
913 | |
914 if util.safehasattr(tr, '_validator'): | |
915 # hg <= 5.3 (36f08ae87ef6) | |
916 tr._validator = validator | |
917 else: | |
918 tr.addvalidator(b'000-reject-publish', _validate_publish) | |
919 | |
920 if util.safehasattr(tr, '_validator'): | |
921 # hg <= 5.3 (36f08ae87ef6) | |
922 origvalidator_affected_tns = tr._validator | |
923 | 883 |
924 def _validate_affected_tns(tr2): | 884 def _validate_affected_tns(tr2): |
925 repo = reporef() | 885 repo = reporef() |
926 assert repo is not None # help pytype | 886 assert repo is not None # help pytype |
927 find_affected_tns(repo, tr2) | 887 find_affected_tns(repo, tr2) |
928 | 888 |
929 def validator(tr2): | 889 tr.addvalidator(b'999-find-affected-tns', _validate_affected_tns) |
930 result = origvalidator_affected_tns(tr2) | |
931 _validate_affected_tns(tr2) | |
932 return result | |
933 | |
934 if util.safehasattr(tr, '_validator'): | |
935 # hg <= 5.3 (36f08ae87ef6) | |
936 tr._validator = validator | |
937 else: | |
938 tr.addvalidator(b'999-find-affected-tns', _validate_affected_tns) | |
939 | 890 |
940 # real transaction start | 891 # real transaction start |
941 ct = self.currenttopic | 892 ct = self.currenttopic |
942 if not ct: | 893 if not ct: |
943 return tr | 894 return tr |