annotate __init__.py @ 168:4f26fa049452

authormap: Add tests, fix in stupid mode.
author Augie Fackler <durin42@gmail.com>
date Tue, 30 Dec 2008 20:14:03 -0600
parents 3cd6a7354207
children a336e3e82648
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
1 import os
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
2
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 from mercurial import commands
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 from mercurial import hg
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 import svncommand
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 import fetch_command
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
8 import tag_repo
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
9 import util
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
10
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
11 def reposetup(ui, repo):
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
12 if not util.is_svn_repo(repo):
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
13 return
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
14
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
15 repo.__class__ = tag_repo.generate_repo_class(ui, repo)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
17
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 def svn(ui, repo, subcommand, *args, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 return svncommand.svncmd(ui, repo, subcommand, *args, **opts)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 def svn_fetch(ui, svn_url, hg_repo_path=None, **opts):
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
22 '''Clone Subversion repository to local Mercurial repository.
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
23
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
24 If no destination directory name is specified, it defaults to the
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
25 basename of the source plus "-hg".
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
26
143
edd9f4e5154a Phrasing nits.
Augie Fackler <durin42@gmail.com>
parents: 142
diff changeset
27 You can specify multiple paths for the location of tags using comma
edd9f4e5154a Phrasing nits.
Augie Fackler <durin42@gmail.com>
parents: 142
diff changeset
28 separated values.
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
29 '''
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 if not hg_repo_path:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 hg_repo_path = hg.defaultdest(svn_url) + "-hg"
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 ui.status("Assuming destination %s\n" % hg_repo_path)
52
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
33 should_update = not os.path.exists(hg_repo_path)
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
34 svn_url = util.normalize_url(svn_url)
52
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
35 res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts)
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
36 if (res is None or res == 0) and should_update:
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
37 repo = hg.repository(ui, hg_repo_path)
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
38 commands.update(ui, repo, repo['tip'].node())
fb1d911bb0be svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents: 0
diff changeset
39 return res
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 commands.norepo += " svnclone"
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 cmdtable = {
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43 "svn":
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 (svn,
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
45 [('u', 'svn-url', '', 'Path to the Subversion server.'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 ('', 'stupid', False, 'Be stupid and use diffy replay.'),
167
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 143
diff changeset
47 ('A', 'authors', '', 'username mapping filename'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 ],
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
49 svncommand.generate_help(),
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
50 ),
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
51 "svnclone":
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
52 (svn_fetch,
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
53 [('S', 'skipto-rev', '0', 'Skip commits before this revision.'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 ('', 'stupid', False, 'Be stupid and use diffy replay.'),
167
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 143
diff changeset
55 ('T', 'tag-locations', 'tags', 'Relative path to Subversion tags.'),
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 143
diff changeset
56 ('A', 'authors', '', 'username mapping filename'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 ],
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
58 'hg svnclone source [dest]'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 }