annotate __init__.py @ 108:de19a13edfa8

fetch_command: extract diff code in a function
author Patrick Mezard <pmezard@gmail.com>
date Tue, 25 Nov 2008 09:18:29 -0600
parents fb1d911bb0be
children ed42f6e5705a
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
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 def svn(ui, repo, subcommand, *args, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 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
11
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 def svn_fetch(ui, svn_url, hg_repo_path=None, **opts):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 if not hg_repo_path:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 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
15 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
16 should_update = not os.path.exists(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
17 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
18 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
19 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
20 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
21 return res
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 commands.norepo += " svnclone"
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 cmdtable = {
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 "svn":
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 (svn,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 [('u', 'svn_url', '', 'Path to the Subversion server.'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 ('', 'stupid', False, 'Be stupid and use diffy replay.'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 ],
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 'hg svn subcommand'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 "svnclone" :(svn_fetch,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 [('S', 'skipto_rev', '0', 'Skip commits before this revision.'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 ('', 'stupid', False, 'Be stupid and use diffy replay.'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 ('T', 'tag_locations', 'tags', 'Relative path to where tags get '
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 'stored, as comma sep. values if there is more than one such path.')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 ],
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 'hg svn_fetch svn_url, dest'),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 }