comparison hg_delta_editor.py @ 67:e319c9168910

hg_delta_editor: register svn file copies
author Patrick Mezard <pmezard@gmail.com>
date Wed, 05 Nov 2008 13:37:07 +0100
parents 430af23bef4a
children 63ece4ea25c9
comparison
equal deleted inserted replaced
66:a31968146f3c 67:e319c9168910
125 self.current_files = {} 125 self.current_files = {}
126 self.deleted_files = {} 126 self.deleted_files = {}
127 self.current_rev = None 127 self.current_rev = None
128 self.current_files_exec = {} 128 self.current_files_exec = {}
129 self.current_files_symlink = {} 129 self.current_files_symlink = {}
130 # Map fully qualified destination file paths to module source path
131 self.copies = {}
130 self.missing_plaintexts = set() 132 self.missing_plaintexts = set()
131 self.commit_branches_empty = {} 133 self.commit_branches_empty = {}
132 self.base_revision = None 134 self.base_revision = None
133 135
134 def _save_metadata(self): 136 def _save_metadata(self):
349 if branch not in self.branches and branch not in self.repo.branchtags(): 351 if branch not in self.branches and branch not in self.repo.branchtags():
350 continue 352 continue
351 extra['branch'] = branch 353 extra['branch'] = branch
352 parent_ctx = self.repo.changectx(parents[0]) 354 parent_ctx = self.repo.changectx(parents[0])
353 def filectxfn(repo, memctx, path): 355 def filectxfn(repo, memctx, path):
354 copied = None
355 current_file = files[path] 356 current_file = files[path]
356 if current_file in self.deleted_files: 357 if current_file in self.deleted_files:
357 raise IOError() 358 raise IOError()
358 # TODO(augie) tag copies from files 359 copied = self.copies.get(current_file)
359 flags = parent_ctx.flags(path) 360 flags = parent_ctx.flags(path)
360 is_exec = self.current_files_exec.get(current_file, 361 is_exec = self.current_files_exec.get(current_file,
361 'x' in flags) 362 'x' in flags)
362 is_link = self.current_files_symlink.get(current_file, 363 is_link = self.current_files_symlink.get(current_file,
363 'l' in flags) 364 'l' in flags)
499 copyfrom_revision, file_pool=None): 500 copyfrom_revision, file_pool=None):
500 self.current_file = 'foobaz' 501 self.current_file = 'foobaz'
501 self.base_revision = None 502 self.base_revision = None
502 if path in self.deleted_files: 503 if path in self.deleted_files:
503 del self.deleted_files[path] 504 del self.deleted_files[path]
504 if (self._is_path_valid(path) and 505 if not self._is_path_valid(path):
505 self._path_and_branch_for_path(path)[0]): 506 return
506 self.current_file = path 507 fpath, branch = self._path_and_branch_for_path(path)
507 self.should_edit_most_recent_plaintext = False 508 if not fpath:
508 if copyfrom_path: 509 return
509 self.ui.status('A+ %s\n' % path) 510 self.current_file = path
510 # TODO(augie) handle this better, actually mark a copy 511 self.should_edit_most_recent_plaintext = False
511 (from_file, 512 if not copyfrom_path:
512 from_branch) = self._path_and_branch_for_path(copyfrom_path) 513 self.ui.status('A %s\n' % path)
513 if not from_file: 514 return
514 self.missing_plaintexts.add(path) 515 self.ui.status('A+ %s\n' % path)
515 return 516 (from_file,
516 ha = self.get_parent_revision(copyfrom_revision + 1, 517 from_branch) = self._path_and_branch_for_path(copyfrom_path)
517 from_branch) 518 if not from_file:
518 ctx = self.repo.changectx(ha) 519 self.missing_plaintexts.add(path)
519 if from_file in ctx: 520 return
520 fctx = ctx.filectx(from_file) 521 ha = self.get_parent_revision(copyfrom_revision + 1,
521 cur_file = self.current_file 522 from_branch)
522 self.current_files[cur_file] = fctx.data() 523 ctx = self.repo.changectx(ha)
523 self.current_files_symlink[cur_file] = 'l' in fctx.flags() 524 if from_file in ctx:
524 self.current_files_exec[cur_file] = 'x' in fctx.flags() 525 fctx = ctx.filectx(from_file)
525 else: 526 cur_file = self.current_file
526 self.ui.status('A %s\n' % path) 527 self.current_files[cur_file] = fctx.data()
527 528 self.current_files_symlink[cur_file] = 'l' in fctx.flags()
529 self.current_files_exec[cur_file] = 'x' in fctx.flags()
530 if from_branch == branch:
531 self.copies[path] = from_file
528 532
529 @stash_exception_on_self 533 @stash_exception_on_self
530 def add_directory(self, path, parent_baton, copyfrom_path, 534 def add_directory(self, path, parent_baton, copyfrom_path,
531 copyfrom_revision, dir_pool=None): 535 copyfrom_revision, dir_pool=None):
532 if self._is_path_valid(path): 536 if self._is_path_valid(path):
569 self.current_files[fp_c] = fctx.data() 573 self.current_files[fp_c] = fctx.data()
570 self.current_files_exec[fp_c] = 'x' in fctx.flags() 574 self.current_files_exec[fp_c] = 'x' in fctx.flags()
571 self.current_files_symlink[fp_c] = 'l' in fctx.flags() 575 self.current_files_symlink[fp_c] = 'l' in fctx.flags()
572 if fp_c in self.deleted_files: 576 if fp_c in self.deleted_files:
573 del self.deleted_files[fp_c] 577 del self.deleted_files[fp_c]
574 # TODO(augie) tag copies from files 578 if branch == source_branch:
579 self.copies[fp_c] = f
575 580
576 @stash_exception_on_self 581 @stash_exception_on_self
577 def change_file_prop(self, file_baton, name, value, pool=None): 582 def change_file_prop(self, file_baton, name, value, pool=None):
578 if name == 'svn:executable': 583 if name == 'svn:executable':
579 self.current_files_exec[self.current_file] = bool(value) 584 self.current_files_exec[self.current_file] = bool(value)