Mercurial > hgsubversion
comparison hgsubversion/hg_delta_editor.py @ 362:705f33c0a323
Replace stash_exception_on_self() by @ieditor.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 28 May 2009 09:55:33 +0200 |
parents | cc7a10efddc9 |
children | ccef78b91ac9 |
comparison
equal
deleted
inserted
replaced
361:cfdd4ec5230a | 362:705f33c0a323 |
---|---|
33 except: #pragma: no cover | 33 except: #pragma: no cover |
34 raise | 34 raise |
35 else: | 35 else: |
36 hgutil.rename(path, file_path) | 36 hgutil.rename(path, file_path) |
37 | 37 |
38 def stash_exception_on_self(fn): | 38 def ieditor(fn): |
39 """Stash any exception raised in the method on self. | 39 """Helps identify methods used by the SVN editor interface. |
40 | |
41 Stash any exception raised in the method on self. | |
40 | 42 |
41 This is required because the SWIG bindings just mutate any exception into | 43 This is required because the SWIG bindings just mutate any exception into |
42 a generic Subversion exception with no way of telling what the original was. | 44 a generic Subversion exception with no way of telling what the original was. |
43 This allows the editor object to notice when you try and commit and really | 45 This allows the editor object to notice when you try and commit and really |
44 got an exception in the replay process. | 46 got an exception in the replay process. |
851 base = 'link ' + base | 853 base = 'link ' + base |
852 self.set_file(svnpath, base, 'x' in fctx.flags(), 'l' in fctx.flags()) | 854 self.set_file(svnpath, base, 'x' in fctx.flags(), 'l' in fctx.flags()) |
853 else: | 855 else: |
854 self.missing_plaintexts.add(svnpath) | 856 self.missing_plaintexts.add(svnpath) |
855 | 857 |
858 @ieditor | |
856 def delete_entry(self, path, revision_bogus, parent_baton, pool=None): | 859 def delete_entry(self, path, revision_bogus, parent_baton, pool=None): |
857 br_path, branch = self._path_and_branch_for_path(path) | 860 br_path, branch = self._path_and_branch_for_path(path) |
858 if br_path == '': | 861 if br_path == '': |
859 self.branches_to_delete.add(branch) | 862 self.branches_to_delete.add(branch) |
860 if br_path is not None: | 863 if br_path is not None: |
873 for f in ctx.walk(util.PrefixMatch(br_path2)): | 876 for f in ctx.walk(util.PrefixMatch(br_path2)): |
874 f_p = '%s/%s' % (path, f[len(br_path2):]) | 877 f_p = '%s/%s' % (path, f[len(br_path2):]) |
875 if f_p not in self.current_files: | 878 if f_p not in self.current_files: |
876 self.delete_file(f_p) | 879 self.delete_file(f_p) |
877 self.delete_file(path) | 880 self.delete_file(path) |
878 delete_entry = stash_exception_on_self(delete_entry) | 881 |
879 | 882 @ieditor |
880 def open_file(self, path, parent_baton, base_revision, p=None): | 883 def open_file(self, path, parent_baton, base_revision, p=None): |
881 self.current_file = None | 884 self.current_file = None |
882 fpath, branch = self._path_and_branch_for_path(path) | 885 fpath, branch = self._path_and_branch_for_path(path) |
883 if fpath: | 886 if fpath: |
884 self.current_file = path | 887 self.current_file = path |
893 baserev = self.current_rev.revnum - 1 | 896 baserev = self.current_rev.revnum - 1 |
894 parent = self.get_parent_revision(baserev + 1, branch) | 897 parent = self.get_parent_revision(baserev + 1, branch) |
895 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) | 898 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) |
896 else: | 899 else: |
897 self.ui.debug('WARNING: Opening non-existant file %s\n' % path) | 900 self.ui.debug('WARNING: Opening non-existant file %s\n' % path) |
898 open_file = stash_exception_on_self(open_file) | |
899 | 901 |
900 def aresamefiles(self, parentctx, childctx, files): | 902 def aresamefiles(self, parentctx, childctx, files): |
901 """Assuming all files exist in childctx and parentctx, return True | 903 """Assuming all files exist in childctx and parentctx, return True |
902 if none of them was changed in-between. | 904 if none of them was changed in-between. |
903 """ | 905 """ |
919 if f in files: | 921 if f in files: |
920 return False | 922 return False |
921 # parentctx is not an ancestor of childctx, files are unrelated | 923 # parentctx is not an ancestor of childctx, files are unrelated |
922 return False | 924 return False |
923 | 925 |
926 @ieditor | |
924 def add_file(self, path, parent_baton=None, copyfrom_path=None, | 927 def add_file(self, path, parent_baton=None, copyfrom_path=None, |
925 copyfrom_revision=None, file_pool=None): | 928 copyfrom_revision=None, file_pool=None): |
926 self.current_file = None | 929 self.current_file = None |
927 self.base_revision = None | 930 self.base_revision = None |
928 if path in self.deleted_files: | 931 if path in self.deleted_files: |
956 branch) | 959 branch) |
957 if parentid != revlog.nullid: | 960 if parentid != revlog.nullid: |
958 parentctx = self.repo.changectx(parentid) | 961 parentctx = self.repo.changectx(parentid) |
959 if self.aresamefiles(parentctx, ctx, [from_file]): | 962 if self.aresamefiles(parentctx, ctx, [from_file]): |
960 self.copies[path] = from_file | 963 self.copies[path] = from_file |
961 add_file = stash_exception_on_self(add_file) | 964 |
962 | 965 @ieditor |
963 def add_directory(self, path, parent_baton, copyfrom_path, | 966 def add_directory(self, path, parent_baton, copyfrom_path, |
964 copyfrom_revision, dir_pool=None): | 967 copyfrom_revision, dir_pool=None): |
965 self.dir_batons[path] = path | 968 self.dir_batons[path] = path |
966 br_path, branch = self._path_and_branch_for_path(path) | 969 br_path, branch = self._path_and_branch_for_path(path) |
967 if br_path is not None: | 970 if br_path is not None: |
1016 if parentid != revlog.nullid: | 1019 if parentid != revlog.nullid: |
1017 parentctx = self.repo.changectx(parentid) | 1020 parentctx = self.repo.changectx(parentid) |
1018 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()): | 1021 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()): |
1019 self.copies.update(copies) | 1022 self.copies.update(copies) |
1020 return path | 1023 return path |
1021 add_directory = stash_exception_on_self(add_directory) | 1024 |
1022 | 1025 @ieditor |
1023 def change_file_prop(self, file_baton, name, value, pool=None): | 1026 def change_file_prop(self, file_baton, name, value, pool=None): |
1024 if name == 'svn:executable': | 1027 if name == 'svn:executable': |
1025 self.current_files_exec[self.current_file] = bool(value is not None) | 1028 self.current_files_exec[self.current_file] = bool(value is not None) |
1026 elif name == 'svn:special': | 1029 elif name == 'svn:special': |
1027 self.current_files_symlink[self.current_file] = bool(value is not None) | 1030 self.current_files_symlink[self.current_file] = bool(value is not None) |
1028 change_file_prop = stash_exception_on_self(change_file_prop) | 1031 |
1029 | 1032 @ieditor |
1030 def change_dir_prop(self, dir_baton, name, value, pool=None): | 1033 def change_dir_prop(self, dir_baton, name, value, pool=None): |
1031 if dir_baton is None: | 1034 if dir_baton is None: |
1032 return | 1035 return |
1033 path = self.dir_batons[dir_baton] | 1036 path = self.dir_batons[dir_baton] |
1034 if name == 'svn:externals': | 1037 if name == 'svn:externals': |
1035 self.externals[path] = value | 1038 self.externals[path] = value |
1036 change_dir_prop = stash_exception_on_self(change_dir_prop) | 1039 |
1037 | 1040 @ieditor |
1038 def open_directory(self, path, parent_baton, base_revision, dir_pool=None): | 1041 def open_directory(self, path, parent_baton, base_revision, dir_pool=None): |
1039 self.dir_batons[path] = path | 1042 self.dir_batons[path] = path |
1040 p_, branch = self._path_and_branch_for_path(path) | 1043 p_, branch = self._path_and_branch_for_path(path) |
1041 if p_ == '': | 1044 if p_ == '': |
1042 self.commit_branches_empty[branch] = False | 1045 self.commit_branches_empty[branch] = False |
1043 return path | 1046 return path |
1044 open_directory = stash_exception_on_self(open_directory) | 1047 |
1045 | 1048 @ieditor |
1046 def close_directory(self, dir_baton, dir_pool=None): | 1049 def close_directory(self, dir_baton, dir_pool=None): |
1047 if dir_baton is not None: | 1050 if dir_baton is not None: |
1048 del self.dir_batons[dir_baton] | 1051 del self.dir_batons[dir_baton] |
1049 close_directory = stash_exception_on_self(close_directory) | 1052 |
1050 | 1053 @ieditor |
1051 def apply_textdelta(self, file_baton, base_checksum, pool=None): | 1054 def apply_textdelta(self, file_baton, base_checksum, pool=None): |
1052 # We know coming in here the file must be one of the following options: | 1055 # We know coming in here the file must be one of the following options: |
1053 # 1) Deleted (invalid, fail an assertion) | 1056 # 1) Deleted (invalid, fail an assertion) |
1054 # 2) Missing a base text (bail quick since we have to fetch a full plaintext) | 1057 # 2) Missing a base text (bail quick since we have to fetch a full plaintext) |
1055 # 3) Has a base text in self.current_files, apply deltas | 1058 # 3) Has a base text in self.current_files, apply deltas |
1087 except: #pragma: no cover | 1090 except: #pragma: no cover |
1088 print len(base), self.current_file | 1091 print len(base), self.current_file |
1089 self._exception_info = sys.exc_info() | 1092 self._exception_info = sys.exc_info() |
1090 raise | 1093 raise |
1091 return txdelt_window | 1094 return txdelt_window |
1092 apply_textdelta = stash_exception_on_self(apply_textdelta) | |
1093 | 1095 |
1094 class MissingPlainTextError(Exception): | 1096 class MissingPlainTextError(Exception): |
1095 """Exception raised when the repo lacks a source file required for replaying | 1097 """Exception raised when the repo lacks a source file required for replaying |
1096 a txdelta. | 1098 a txdelta. |
1097 """ | 1099 """ |