2009-01-18 00:30:37 +03:00
|
|
|
'''integration with Subversion repositories
|
|
|
|
|
|
|
|
This extension allows Mercurial to act as a Subversion client, for
|
|
|
|
fast incremental, bidirectional updates.
|
|
|
|
|
|
|
|
It is *not* ready yet for production use. You should only be using
|
|
|
|
this if you're ready to hack on it, and go diving into the internals
|
|
|
|
of Mercurial and/or Subversion.
|
|
|
|
|
|
|
|
Before using hgsubversion, it is *strongly* encouraged to run the
|
|
|
|
automated tests. See `README' in the hgsubversion directory for
|
|
|
|
details.
|
|
|
|
'''
|
|
|
|
|
2008-11-01 21:40:19 +03:00
|
|
|
import os
|
|
|
|
|
2008-09-30 20:42:52 +04:00
|
|
|
from mercurial import commands
|
|
|
|
from mercurial import hg
|
|
|
|
|
|
|
|
import svncommand
|
|
|
|
import fetch_command
|
2008-12-04 22:10:40 +03:00
|
|
|
import tag_repo
|
|
|
|
import util
|
|
|
|
|
|
|
|
def reposetup(ui, repo):
|
|
|
|
if not util.is_svn_repo(repo):
|
|
|
|
return
|
|
|
|
|
|
|
|
repo.__class__ = tag_repo.generate_repo_class(ui, repo)
|
2008-09-30 20:42:52 +04:00
|
|
|
|
2008-11-21 07:03:30 +03:00
|
|
|
|
2008-09-30 20:42:52 +04:00
|
|
|
def svn(ui, repo, subcommand, *args, **opts):
|
2009-01-18 00:30:37 +03:00
|
|
|
'''see detailed help for list of subcommands'''
|
|
|
|
|
2008-09-30 20:42:52 +04:00
|
|
|
return svncommand.svncmd(ui, repo, subcommand, *args, **opts)
|
|
|
|
|
|
|
|
def svn_fetch(ui, svn_url, hg_repo_path=None, **opts):
|
2009-01-18 00:30:37 +03:00
|
|
|
'''clone Subversion repository to a local Mercurial repository.
|
2008-12-14 18:31:26 +03:00
|
|
|
|
|
|
|
If no destination directory name is specified, it defaults to the
|
|
|
|
basename of the source plus "-hg".
|
|
|
|
|
2008-12-16 06:36:14 +03:00
|
|
|
You can specify multiple paths for the location of tags using comma
|
|
|
|
separated values.
|
2008-12-14 18:31:26 +03:00
|
|
|
'''
|
2008-09-30 20:42:52 +04:00
|
|
|
if not hg_repo_path:
|
|
|
|
hg_repo_path = hg.defaultdest(svn_url) + "-hg"
|
|
|
|
ui.status("Assuming destination %s\n" % hg_repo_path)
|
2008-11-01 21:40:19 +03:00
|
|
|
should_update = not os.path.exists(hg_repo_path)
|
2008-12-12 05:41:57 +03:00
|
|
|
svn_url = util.normalize_url(svn_url)
|
2008-11-01 21:40:19 +03:00
|
|
|
res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts)
|
|
|
|
if (res is None or res == 0) and should_update:
|
|
|
|
repo = hg.repository(ui, hg_repo_path)
|
|
|
|
commands.update(ui, repo, repo['tip'].node())
|
|
|
|
return res
|
2008-09-30 20:42:52 +04:00
|
|
|
|
|
|
|
commands.norepo += " svnclone"
|
|
|
|
cmdtable = {
|
|
|
|
"svn":
|
|
|
|
(svn,
|
2009-01-18 00:30:37 +03:00
|
|
|
[('u', 'svn-url', '', 'path to the Subversion server.'),
|
|
|
|
('', 'stupid', False, 'be stupid and use diffy replay.'),
|
2008-12-31 05:13:32 +03:00
|
|
|
('A', 'authors', '', 'username mapping filename'),
|
2009-01-18 00:30:37 +03:00
|
|
|
('', 'filemap', '',
|
|
|
|
'remap file to exclude paths or include only certain paths'),
|
2008-09-30 20:42:52 +04:00
|
|
|
],
|
2008-11-21 07:03:30 +03:00
|
|
|
svncommand.generate_help(),
|
|
|
|
),
|
2008-12-14 18:31:26 +03:00
|
|
|
"svnclone":
|
|
|
|
(svn_fetch,
|
2009-01-18 00:30:37 +03:00
|
|
|
[('S', 'skipto-rev', '0', 'skip commits before this revision.'),
|
|
|
|
('', 'stupid', False, 'be stupid and use diffy replay.'),
|
2008-12-31 05:13:32 +03:00
|
|
|
('T', 'tag-locations', 'tags', 'Relative path to Subversion tags.'),
|
|
|
|
('A', 'authors', '', 'username mapping filename'),
|
2009-01-18 00:30:37 +03:00
|
|
|
('', 'filemap', '',
|
|
|
|
'remap file to exclude paths or include only certain paths'),
|
2008-09-30 20:42:52 +04:00
|
|
|
],
|
2008-12-14 18:31:26 +03:00
|
|
|
'hg svnclone source [dest]'),
|
2008-09-30 20:42:52 +04:00
|
|
|
}
|