Mercurial > hgsubversion
diff 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 |
line wrap: on
line diff
--- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -89,12 +89,11 @@ class HgChangeReceiver(delta.Editor): self.ui = ui_ if repo: self.repo = repo + self.__setup_repo(repo) self.path = os.path.normpath(os.path.join(self.repo.path, '..')) elif path: self.path = path self.__setup_repo(path) - else: #pragma: no cover - raise TypeError("Expected either path or repo argument") self.subdir = subdir if self.subdir and self.subdir[0] == '/': @@ -144,19 +143,27 @@ class HgChangeReceiver(delta.Editor): date = self.lastdate return date - def __setup_repo(self, repo_path): + def __setup_repo(self, arg): """Verify the repo is going to work out for us. This method will fail an assertion if the repo exists but doesn't have the Subversion metadata. """ - if os.path.isdir(repo_path) and len(os.listdir(repo_path)): - self.repo = hg.repository(self.ui, repo_path) + if isinstance(arg, basestring): + self.path = arg + self.repo = hg.repository(self.ui, self.path, create=True) + elif arg: + self.repo = arg + self.path = os.path.normpath(os.path.join(self.repo.path, '..')) + else: #pragma: no cover + raise TypeError("editor requires either a path or a repository " + "specified") + + if os.path.isdir(self.meta_data_dir) and os.listdir(self.meta_data_dir): assert os.path.isfile(self.revmap_file) assert os.path.isfile(self.svn_url_file) assert os.path.isfile(self.uuid_file) else: - self.repo = hg.repository(self.ui, repo_path, create=True) os.makedirs(os.path.dirname(self.uuid_file)) f = open(self.revmap_file, 'w') f.write('%s\n' % util.REVMAP_FILE_VERSION)