Mercurial > hgsubversion
changeset 228:f71af18c4379
Merge with crew.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 07 Apr 2009 13:48:58 -0500 |
parents | 330f0b15d417 (current diff) d79843a3d42c (diff) |
children | 7f20914e52e8 |
files | fetch_command.py hg_delta_editor.py rebuildmeta.py svnwrap/svn_swig_wrapper.py utility_commands.py |
diffstat | 8 files changed, 36 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py +++ b/__init__.py @@ -37,7 +37,7 @@ def svn(ui, repo, subcommand, *args, **o try: return svncommand.svncmd(ui, repo, subcommand, *args, **opts) except core.SubversionException, e: - if e.apr_err == 230001: + if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n' 'Please try running svn ls on that url first.') raise @@ -60,7 +60,7 @@ def svn_fetch(ui, svn_url, hg_repo_path= try: res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts) except core.SubversionException, e: - if e.apr_err == 230001: + if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n' 'Please try running svn ls on that url first.') raise
--- a/fetch_command.py +++ b/fetch_command.py @@ -54,11 +54,10 @@ def fetch_revisions(ui, svn_url, hg_repo if os.path.exists(hg_editor.uuid_file): uuid = open(hg_editor.uuid_file).read() assert uuid == svn.uuid - start = int(open(hg_editor.last_revision_handled_file, 'r').read()) + start = hg_editor.last_known_revision() else: open(hg_editor.uuid_file, 'w').write(svn.uuid) open(hg_editor.svn_url_file, 'w').write(svn_url) - open(hg_editor.last_revision_handled_file, 'w').write(str(0)) initializing_repo = True start = skipto_rev @@ -92,20 +91,12 @@ def fetch_revisions(ui, svn_url, hg_repo else: stupid_svn_server_pull_rev(ui, svn, hg_editor, r) converted = True - tmpfile = '%s_tmp' % hg_editor.last_revision_handled_file - fp = open(tmpfile, 'w') - fp.write(str(r.revnum)) - fp.close() - merc_util.rename(tmpfile, - hg_editor.last_revision_handled_file) except core.SubversionException, e: #pragma: no cover - if hasattr(e, 'message') and ( - 'Server sent unexpected return value (502 Bad Gateway)' - ' in response to PROPFIND') in e.message: + if e.apr_err == core.SVN_ERR_RA_DAV_REQUEST_FAILED: tries += 1 ui.status('Got a 502, retrying (%s)\n' % tries) else: - raise + raise merc_util.Abort(*e.args) util.swap_out_encoding(old_encoding) fetch_revisions = util.register_subcommand('pull')(fetch_revisions) @@ -249,7 +240,7 @@ def stupid_diff_branchrev(ui, svn, hg_ed except svnwrap.SubversionRepoCanNotDiff: raise BadPatchApply('subversion diffing code is not supported') except core.SubversionException, e: - if (hasattr(e, 'apr_err') and e.apr_err != 160013): + if (hasattr(e, 'apr_err') and e.apr_err != core.SVN_ERR_FS_NOT_FOUND): raise raise BadPatchApply('previous revision does not exist') if '\0' in d: @@ -610,7 +601,7 @@ def stupid_svn_server_pull_rev(ui, svn, ui, svn, hg_editor, b, r, parentctx) except BadPatchApply, e: # Either this revision or the previous one does not exist. - ui.status("fetching entire rev: %s.\n" % e.message) + ui.status("Fetching entire revision: %s.\n" % e.args[0]) files_touched, filectxfn2 = stupid_fetch_branchrev( svn, hg_editor, b, branches[b], r, parentctx)
--- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -59,6 +59,18 @@ class HgChangeReceiver(delta.Editor): f.close() self.revmap[revnum, branch] = node_hash + def last_known_revision(self): + """Obtain the highest numbered -- i.e. latest -- revision known. + + Currently, this function just iterates over the entire revision map + using the max() builtin. This may be slow for extremely large + repositories, but for now, it's fast enough. + """ + try: + return max(k[0] for k in self.revmap.iterkeys()) + except ValueError: + return 0 + def __init__(self, path=None, repo=None, ui_=None, subdir='', author_host='', tag_locations=['tags'], @@ -133,7 +145,6 @@ class HgChangeReceiver(delta.Editor): assert os.path.isfile(self.revmap_file) assert os.path.isfile(self.svn_url_file) assert os.path.isfile(self.uuid_file) - assert os.path.isfile(self.last_revision_handled_file) else: self.repo = hg.repository(self.ui, repo_path, create=True) os.makedirs(os.path.dirname(self.uuid_file)) @@ -523,6 +534,7 @@ class HgChangeReceiver(delta.Editor): branches = {} for path, entry in self.externals.iteritems(): if not self._is_path_valid(path): + self.ui.warn('WARNING: Invalid path %s in externals\n' % path) continue p, b, bp = self._split_branch_path(path) if bp not in branches: @@ -692,6 +704,14 @@ class HgChangeReceiver(delta.Editor): return self.authors[author] return '%s%s' %(author, self.author_host) + def svnauthorforauthor(self, author): + for svnauthor, hgauthor in self.authors.iteritems(): + if author == hgauthor: + return svnauthor + else: + # return the original svn-side author + return author.rsplit('@', 1)[0] + def readauthors(self, authorfile): self.ui.note(('Reading authormap from %s\n') % authorfile) f = open(authorfile, 'r') @@ -777,10 +797,6 @@ class HgChangeReceiver(delta.Editor): return self.meta_file_named('uuid') uuid_file = property(uuid_file) - def last_revision_handled_file(self): - return self.meta_file_named('last_rev') - last_revision_handled_file = property(last_revision_handled_file) - def branch_info_file(self): return self.meta_file_named('branch_info') branch_info_file = property(branch_info_file) @@ -853,6 +869,8 @@ class HgChangeReceiver(delta.Editor): baserev = self.current_rev.revnum - 1 parent = self.get_parent_revision(baserev + 1, branch) self.load_base_from_ctx(path, fpath, self.repo.changectx(parent)) + else: + self.ui.warn('WARNING: Opening non-existant file %s\n' % path) open_file = stash_exception_on_self(open_file) def aresamefiles(self, parentctx, childctx, files): @@ -1038,11 +1056,10 @@ class HgChangeReceiver(delta.Editor): if not window: self.current_files[self.current_file] = target.getvalue() except core.SubversionException, e: #pragma: no cover - if e.message == 'Delta source ended unexpectedly': + if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA: self.missing_plaintexts.add(self.current_file) else: #pragma: no cover - self._exception_info = sys.exc_info() - raise + raise util.Abort(*e.args) except: #pragma: no cover print len(base), self.current_file self._exception_info = sys.exc_info()
--- a/rebuildmeta.py +++ b/rebuildmeta.py @@ -79,9 +79,6 @@ def rebuildmeta(ui, repo, hg_repo_path, if c.branch() == 'closed-branches': if branch in branchinfo: del branchinfo[branch] - lastrevfile = open(os.path.join(svnmetadir, 'last_rev'), 'w') - lastrevfile.write(str(last_rev)) - lastrevfile.close() branchinfofile = open(os.path.join(svnmetadir, 'branch_info'), 'w') pickle.dump(branchinfo, branchinfofile) branchinfofile.close()
--- a/svncommand.py +++ b/svncommand.py @@ -5,7 +5,6 @@ import traceback from mercurial import hg from mercurial import node -from mercurial import util as merc_util import svnwrap import util
--- a/svnwrap/svn_swig_wrapper.py +++ b/svnwrap/svn_swig_wrapper.py @@ -189,7 +189,7 @@ class SubversionRepo(object): try: tags = self.list_dir('tags', revision=revision).keys() except core.SubversionException, e: - if e.apr_err == 160013: + if e.apr_err == core.SVN_ERR_FS_NOT_FOUND: return {} raise tag_info = {} @@ -370,10 +370,8 @@ class SubversionRepo(object): e_baton, self.pool) except core.SubversionException, e: #pragma: no cover # can I depend on this number being constant? - if (e.message == "Server doesn't support the replay command" - or e.apr_err == 170003 - or e.message == 'The requested report is unknown.' - or e.apr_err == 200007): + if (e.apr_err == core.SVN_ERR_RA_NOT_IMPLEMENTED or + e.apr_err == core.SVN_ERR_UNSUPPORTED_FEATURE): raise SubversionRepoCanNotReplay, ('This Subversion server ' 'is older than 1.4.0, and cannot satisfy replay requests.') else:
--- a/tests/test_rebuildmeta.py +++ b/tests/test_rebuildmeta.py @@ -22,8 +22,6 @@ def _do_case(self, name, stupid): args=[test_util.fileurl(self.repo_path + subdir), ]) dest = hg.repository(u, os.path.dirname(dest.path)) - self.assert_(open(os.path.join(src.path, 'svn', 'last_rev')).read() >= - open(os.path.join(dest.path, 'svn', 'last_rev')).read()) for tf in ('rev_map', 'uuid', 'url'): self.assertEqual(open(os.path.join(src.path, 'svn', tf)).read(), open(os.path.join(dest.path, 'svn', tf)).read())
--- a/utility_commands.py +++ b/utility_commands.py @@ -89,7 +89,7 @@ def run_svn_info(ui, repo, hg_repo_path, if url[-1] == '/': url = url[:-1] url = '%s%s' % (url, branchpath) - author = '@'.join(parent.user().split('@')[:-1]) + author = hge.svnauthorforauthor(parent.user()) # cleverly figure out repo root w/o actually contacting the server reporoot = url[:len(url)-len(subdir)] ui.status('''URL: %(url)s