Mercurial > hgsubversion
comparison hg_delta_editor.py @ 228:f71af18c4379
Merge with crew.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 07 Apr 2009 13:48:58 -0500 |
parents | f2c65dd3d5c0 d79843a3d42c |
children | c0063328587f |
comparison
equal
deleted
inserted
replaced
223:330f0b15d417 | 228:f71af18c4379 |
---|---|
56 f = open(self.revmap_file, 'a') | 56 f = open(self.revmap_file, 'a') |
57 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n') | 57 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n') |
58 f.flush() | 58 f.flush() |
59 f.close() | 59 f.close() |
60 self.revmap[revnum, branch] = node_hash | 60 self.revmap[revnum, branch] = node_hash |
61 | |
62 def last_known_revision(self): | |
63 """Obtain the highest numbered -- i.e. latest -- revision known. | |
64 | |
65 Currently, this function just iterates over the entire revision map | |
66 using the max() builtin. This may be slow for extremely large | |
67 repositories, but for now, it's fast enough. | |
68 """ | |
69 try: | |
70 return max(k[0] for k in self.revmap.iterkeys()) | |
71 except ValueError: | |
72 return 0 | |
61 | 73 |
62 def __init__(self, path=None, repo=None, ui_=None, | 74 def __init__(self, path=None, repo=None, ui_=None, |
63 subdir='', author_host='', | 75 subdir='', author_host='', |
64 tag_locations=['tags'], | 76 tag_locations=['tags'], |
65 authors=None, | 77 authors=None, |
131 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): | 143 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): |
132 self.repo = hg.repository(self.ui, repo_path) | 144 self.repo = hg.repository(self.ui, repo_path) |
133 assert os.path.isfile(self.revmap_file) | 145 assert os.path.isfile(self.revmap_file) |
134 assert os.path.isfile(self.svn_url_file) | 146 assert os.path.isfile(self.svn_url_file) |
135 assert os.path.isfile(self.uuid_file) | 147 assert os.path.isfile(self.uuid_file) |
136 assert os.path.isfile(self.last_revision_handled_file) | |
137 else: | 148 else: |
138 self.repo = hg.repository(self.ui, repo_path, create=True) | 149 self.repo = hg.repository(self.ui, repo_path, create=True) |
139 os.makedirs(os.path.dirname(self.uuid_file)) | 150 os.makedirs(os.path.dirname(self.uuid_file)) |
140 f = open(self.revmap_file, 'w') | 151 f = open(self.revmap_file, 'w') |
141 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) | 152 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) |
521 # Accumulate externals records for all branches | 532 # Accumulate externals records for all branches |
522 revnum = self.current_rev.revnum | 533 revnum = self.current_rev.revnum |
523 branches = {} | 534 branches = {} |
524 for path, entry in self.externals.iteritems(): | 535 for path, entry in self.externals.iteritems(): |
525 if not self._is_path_valid(path): | 536 if not self._is_path_valid(path): |
537 self.ui.warn('WARNING: Invalid path %s in externals\n' % path) | |
526 continue | 538 continue |
527 p, b, bp = self._split_branch_path(path) | 539 p, b, bp = self._split_branch_path(path) |
528 if bp not in branches: | 540 if bp not in branches: |
529 external = svnexternals.externalsfile() | 541 external = svnexternals.externalsfile() |
530 parent = self.get_parent_revision(revnum, b) | 542 parent = self.get_parent_revision(revnum, b) |
690 def authorforsvnauthor(self, author): | 702 def authorforsvnauthor(self, author): |
691 if(author in self.authors): | 703 if(author in self.authors): |
692 return self.authors[author] | 704 return self.authors[author] |
693 return '%s%s' %(author, self.author_host) | 705 return '%s%s' %(author, self.author_host) |
694 | 706 |
707 def svnauthorforauthor(self, author): | |
708 for svnauthor, hgauthor in self.authors.iteritems(): | |
709 if author == hgauthor: | |
710 return svnauthor | |
711 else: | |
712 # return the original svn-side author | |
713 return author.rsplit('@', 1)[0] | |
714 | |
695 def readauthors(self, authorfile): | 715 def readauthors(self, authorfile): |
696 self.ui.note(('Reading authormap from %s\n') % authorfile) | 716 self.ui.note(('Reading authormap from %s\n') % authorfile) |
697 f = open(authorfile, 'r') | 717 f = open(authorfile, 'r') |
698 for line in f: | 718 for line in f: |
699 if not line.strip(): | 719 if not line.strip(): |
775 | 795 |
776 def uuid_file(self): | 796 def uuid_file(self): |
777 return self.meta_file_named('uuid') | 797 return self.meta_file_named('uuid') |
778 uuid_file = property(uuid_file) | 798 uuid_file = property(uuid_file) |
779 | 799 |
780 def last_revision_handled_file(self): | |
781 return self.meta_file_named('last_rev') | |
782 last_revision_handled_file = property(last_revision_handled_file) | |
783 | |
784 def branch_info_file(self): | 800 def branch_info_file(self): |
785 return self.meta_file_named('branch_info') | 801 return self.meta_file_named('branch_info') |
786 branch_info_file = property(branch_info_file) | 802 branch_info_file = property(branch_info_file) |
787 | 803 |
788 def tag_info_file(self): | 804 def tag_info_file(self): |
851 baserev = base_revision | 867 baserev = base_revision |
852 if baserev is None or baserev == -1: | 868 if baserev is None or baserev == -1: |
853 baserev = self.current_rev.revnum - 1 | 869 baserev = self.current_rev.revnum - 1 |
854 parent = self.get_parent_revision(baserev + 1, branch) | 870 parent = self.get_parent_revision(baserev + 1, branch) |
855 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) | 871 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) |
872 else: | |
873 self.ui.warn('WARNING: Opening non-existant file %s\n' % path) | |
856 open_file = stash_exception_on_self(open_file) | 874 open_file = stash_exception_on_self(open_file) |
857 | 875 |
858 def aresamefiles(self, parentctx, childctx, files): | 876 def aresamefiles(self, parentctx, childctx, files): |
859 """Assuming all files exist in childctx and parentctx, return True | 877 """Assuming all files exist in childctx and parentctx, return True |
860 if none of them was changed in-between. | 878 if none of them was changed in-between. |
1036 handler(window, baton) | 1054 handler(window, baton) |
1037 # window being None means commit this file | 1055 # window being None means commit this file |
1038 if not window: | 1056 if not window: |
1039 self.current_files[self.current_file] = target.getvalue() | 1057 self.current_files[self.current_file] = target.getvalue() |
1040 except core.SubversionException, e: #pragma: no cover | 1058 except core.SubversionException, e: #pragma: no cover |
1041 if e.message == 'Delta source ended unexpectedly': | 1059 if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA: |
1042 self.missing_plaintexts.add(self.current_file) | 1060 self.missing_plaintexts.add(self.current_file) |
1043 else: #pragma: no cover | 1061 else: #pragma: no cover |
1044 self._exception_info = sys.exc_info() | 1062 raise util.Abort(*e.args) |
1045 raise | |
1046 except: #pragma: no cover | 1063 except: #pragma: no cover |
1047 print len(base), self.current_file | 1064 print len(base), self.current_file |
1048 self._exception_info = sys.exc_info() | 1065 self._exception_info = sys.exc_info() |
1049 raise | 1066 raise |
1050 return txdelt_window | 1067 return txdelt_window |