Mercurial > hgsubversion
annotate __init__.py @ 198:df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
author | Dan Villiom Podlaski Christiansen <danchr@cs.au.dk> |
---|---|
date | Thu, 12 Feb 2009 15:10:42 +0100 |
parents | 57355b0e7bd1 |
children | 91db8fc049b0 |
rev | line source |
---|---|
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
1 '''integration with Subversion repositories |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
2 |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
3 This extension allows Mercurial to act as a Subversion client, for |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
4 fast incremental, bidirectional updates. |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
5 |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
6 It is *not* ready yet for production use. You should only be using |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
7 this if you're ready to hack on it, and go diving into the internals |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
8 of Mercurial and/or Subversion. |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
9 |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
10 Before using hgsubversion, it is *strongly* encouraged to run the |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
11 automated tests. See `README' in the hgsubversion directory for |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
12 details. |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
13 ''' |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
14 |
52
fb1d911bb0be
svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
15 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
|
16 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 from mercurial import commands |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 from mercurial import hg |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 import svncommand |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 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
|
22 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
|
23 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
|
24 |
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
|
25 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
|
26 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
|
27 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
|
28 |
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
|
29 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
|
30 |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
52
diff
changeset
|
31 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 def svn(ui, repo, subcommand, *args, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
33 '''see detailed help for list of subcommands''' |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
34 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 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
|
36 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 def svn_fetch(ui, svn_url, hg_repo_path=None, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
38 '''clone Subversion repository to a local Mercurial repository. |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
39 |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
40 If no destination directory name is specified, it defaults to the |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
41 basename of the source plus "-hg". |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
42 |
143 | 43 You can specify multiple paths for the location of tags using comma |
44 separated values. | |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
45 ''' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 if not hg_repo_path: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 return res |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 commands.norepo += " svnclone" |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 cmdtable = { |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 "svn": |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 (svn, |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
61 [('u', 'svn-url', '', 'path to the Subversion server.'), |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
62 ('', '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
|
63 ('A', 'authors', '', 'username mapping filename'), |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
64 ('', 'filemap', '', |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
65 'remap file to exclude paths or include only certain paths'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 ], |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
52
diff
changeset
|
67 svncommand.generate_help(), |
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
52
diff
changeset
|
68 ), |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
69 "svnclone": |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
70 (svn_fetch, |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
71 [('S', 'skipto-rev', '0', 'skip commits before this revision.'), |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
72 ('', '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
|
73 ('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
|
74 ('A', 'authors', '', 'username mapping filename'), |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
75 ('', 'filemap', '', |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
76 'remap file to exclude paths or include only certain paths'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 ], |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
78 'hg svnclone source [dest]'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 } |