Mercurial > hgsubversion
comparison hgsubversion/hg_delta_editor.py @ 410:eb524b957345
move aresamefiles() from HgChangeReceiver to util
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 10 Jun 2009 17:29:11 +0200 |
parents | d4615986e1db |
children | d71972428fce |
comparison
equal
deleted
inserted
replaced
409:d4615986e1db | 410:eb524b957345 |
---|---|
723 | 723 |
724 @property | 724 @property |
725 def authors_file(self): | 725 def authors_file(self): |
726 return os.path.join(self.meta_data_dir, 'authors') | 726 return os.path.join(self.meta_data_dir, 'authors') |
727 | 727 |
728 def aresamefiles(self, parentctx, childctx, files): | |
729 """Assuming all files exist in childctx and parentctx, return True | |
730 if none of them was changed in-between. | |
731 """ | |
732 if parentctx == childctx: | |
733 return True | |
734 if parentctx.rev() > childctx.rev(): | |
735 parentctx, childctx = childctx, parentctx | |
736 | |
737 def selfandancestors(selfctx): | |
738 yield selfctx | |
739 for ctx in selfctx.ancestors(): | |
740 yield ctx | |
741 | |
742 files = dict.fromkeys(files) | |
743 for pctx in selfandancestors(childctx): | |
744 if pctx.rev() <= parentctx.rev(): | |
745 return True | |
746 for f in pctx.files(): | |
747 if f in files: | |
748 return False | |
749 # parentctx is not an ancestor of childctx, files are unrelated | |
750 return False | |
751 | |
752 # Here come all the actual editor methods | 728 # Here come all the actual editor methods |
753 | 729 |
754 @ieditor | 730 @ieditor |
755 def delete_entry(self, path, revision_bogus, parent_baton, pool=None): | 731 def delete_entry(self, path, revision_bogus, parent_baton, pool=None): |
756 br_path, branch = self._path_and_branch_for_path(path) | 732 br_path, branch = self._path_and_branch_for_path(path) |
845 if from_branch == branch: | 821 if from_branch == branch: |
846 parentid = self.get_parent_revision(self.current_rev.revnum, | 822 parentid = self.get_parent_revision(self.current_rev.revnum, |
847 branch) | 823 branch) |
848 if parentid != revlog.nullid: | 824 if parentid != revlog.nullid: |
849 parentctx = self.repo.changectx(parentid) | 825 parentctx = self.repo.changectx(parentid) |
850 if self.aresamefiles(parentctx, ctx, [from_file]): | 826 if util.aresamefiles(parentctx, ctx, [from_file]): |
851 self.copies[path] = from_file | 827 self.copies[path] = from_file |
852 | 828 |
853 @ieditor | 829 @ieditor |
854 def add_directory(self, path, parent_baton, copyfrom_path, | 830 def add_directory(self, path, parent_baton, copyfrom_path, |
855 copyfrom_revision, dir_pool=None): | 831 copyfrom_revision, dir_pool=None): |
904 # Preserve the directory copy records if no file was changed between | 880 # Preserve the directory copy records if no file was changed between |
905 # the source and destination revisions, or discard it completely. | 881 # the source and destination revisions, or discard it completely. |
906 parentid = self.get_parent_revision(self.current_rev.revnum, branch) | 882 parentid = self.get_parent_revision(self.current_rev.revnum, branch) |
907 if parentid != revlog.nullid: | 883 if parentid != revlog.nullid: |
908 parentctx = self.repo.changectx(parentid) | 884 parentctx = self.repo.changectx(parentid) |
909 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()): | 885 if util.aresamefiles(parentctx, cp_f_ctx, copies.values()): |
910 self.copies.update(copies) | 886 self.copies.update(copies) |
911 return path | 887 return path |
912 | 888 |
913 @ieditor | 889 @ieditor |
914 def change_file_prop(self, file_baton, name, value, pool=None): | 890 def change_file_prop(self, file_baton, name, value, pool=None): |