comparison hg_delta_editor.py @ 326:33736e2e25f0

alternate approach for supporting svn schemes for repository paths We now intercept the operations in the local repo class, and handle the relevant operation ourselves. This frees us from wrapping all relevant commands and replicating their functionality. The implementation is incomplete; only one test has been modified to use the standard Mercurial API with the changed URLs. Once changed, those tests will likely reveal bugs or missing features in the new wrappers. Also, new wrappers will be needed for handling conversion flags such as -A/--authormap.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 07 May 2009 20:50:53 +0200
parents 5dc8fee7fc96
children 235022089da6
comparison
equal deleted inserted replaced
320:1ba8ed29148e 326:33736e2e25f0
87 if not ui_: 87 if not ui_:
88 ui_ = ui.ui() 88 ui_ = ui.ui()
89 self.ui = ui_ 89 self.ui = ui_
90 if repo: 90 if repo:
91 self.repo = repo 91 self.repo = repo
92 self.__setup_repo(repo)
92 self.path = os.path.normpath(os.path.join(self.repo.path, '..')) 93 self.path = os.path.normpath(os.path.join(self.repo.path, '..'))
93 elif path: 94 elif path:
94 self.path = path 95 self.path = path
95 self.__setup_repo(path) 96 self.__setup_repo(path)
96 else: #pragma: no cover
97 raise TypeError("Expected either path or repo argument")
98 97
99 self.subdir = subdir 98 self.subdir = subdir
100 if self.subdir and self.subdir[0] == '/': 99 if self.subdir and self.subdir[0] == '/':
101 self.subdir = self.subdir[1:] 100 self.subdir = self.subdir[1:]
102 self.revmap = {} 101 self.revmap = {}
142 self.lastdate = date 141 self.lastdate = date
143 else: 142 else:
144 date = self.lastdate 143 date = self.lastdate
145 return date 144 return date
146 145
147 def __setup_repo(self, repo_path): 146 def __setup_repo(self, arg):
148 """Verify the repo is going to work out for us. 147 """Verify the repo is going to work out for us.
149 148
150 This method will fail an assertion if the repo exists but doesn't have 149 This method will fail an assertion if the repo exists but doesn't have
151 the Subversion metadata. 150 the Subversion metadata.
152 """ 151 """
153 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): 152 if isinstance(arg, basestring):
154 self.repo = hg.repository(self.ui, repo_path) 153 self.path = arg
154 self.repo = hg.repository(self.ui, self.path, create=True)
155 elif arg:
156 self.repo = arg
157 self.path = os.path.normpath(os.path.join(self.repo.path, '..'))
158 else: #pragma: no cover
159 raise TypeError("editor requires either a path or a repository "
160 "specified")
161
162 if os.path.isdir(self.meta_data_dir) and os.listdir(self.meta_data_dir):
155 assert os.path.isfile(self.revmap_file) 163 assert os.path.isfile(self.revmap_file)
156 assert os.path.isfile(self.svn_url_file) 164 assert os.path.isfile(self.svn_url_file)
157 assert os.path.isfile(self.uuid_file) 165 assert os.path.isfile(self.uuid_file)
158 else: 166 else:
159 self.repo = hg.repository(self.ui, repo_path, create=True)
160 os.makedirs(os.path.dirname(self.uuid_file)) 167 os.makedirs(os.path.dirname(self.uuid_file))
161 f = open(self.revmap_file, 'w') 168 f = open(self.revmap_file, 'w')
162 f.write('%s\n' % util.REVMAP_FILE_VERSION) 169 f.write('%s\n' % util.REVMAP_FILE_VERSION)
163 f.flush() 170 f.flush()
164 f.close() 171 f.close()