Mercurial > hgsubversion
annotate __init__.py @ 247:1272e87546ed
Move help, update into svncommands.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Wed, 08 Apr 2009 18:59:50 +0200 |
parents | 4950b18cf949 |
children | a9134fa28d15 |
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 |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
19 from mercurial import util as mutil |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
20 |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
21 from svn import core |
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 import svncommand |
241
4950b18cf949
Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
234
diff
changeset
|
24 import svncommands |
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
|
25 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
|
26 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
|
27 |
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 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
|
29 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
|
30 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
|
31 |
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
|
32 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
|
33 |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
52
diff
changeset
|
34 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 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
|
36 '''see detailed help for list of subcommands''' |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
37 try: |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
38 return svncommand.svncmd(ui, repo, subcommand, *args, **opts) |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
39 except core.SubversionException, e: |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
209
diff
changeset
|
40 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
41 raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n' |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
42 'Please try running svn ls on that url first.') |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
43 raise |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
44 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 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
|
47 '''clone Subversion repository to a local Mercurial repository. |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
48 |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
49 If no destination directory name is specified, it defaults to the |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
50 basename of the source plus "-hg". |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
51 |
143 | 52 You can specify multiple paths for the location of tags using comma |
53 separated values. | |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
54 ''' |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 if not hg_repo_path: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 svn_url = util.normalize_url(svn_url) |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
60 try: |
241
4950b18cf949
Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
234
diff
changeset
|
61 res = svncommands.pull(ui, svn_url, hg_repo_path, **opts) |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
62 except core.SubversionException, e: |
224
2165461d2dd8
Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
209
diff
changeset
|
63 if e.apr_err == core.SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED: |
209
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
64 raise mutil.Abort('It appears svn does not trust the ssl cert for this site.\n' |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
65 'Please try running svn ls on that url first.') |
d06572495c5e
Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents:
199
diff
changeset
|
66 raise |
52
fb1d911bb0be
svnclone now updates to the tip revision if it is the initial clone.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 return res |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 commands.norepo += " svnclone" |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 cmdtable = { |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 "svn": |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 (svn, |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
76 [('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
|
77 ('', '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
|
78 ('A', 'authors', '', 'username mapping filename'), |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
79 ('', 'filemap', '', |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
80 'remap file to exclude paths or include only certain paths'), |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
81 ('', 'force', False, 'force an operation to happen'), |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
224
diff
changeset
|
82 ('', 'username', '', 'username for authentication'), |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
224
diff
changeset
|
83 ('', 'password', '', 'password for authentication'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 ], |
247
1272e87546ed
Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
241
diff
changeset
|
85 svncommands.generate_help(), |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
52
diff
changeset
|
86 ), |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
87 "svnclone": |
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
88 (svn_fetch, |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
89 [('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
|
90 ('', '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
|
91 ('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
|
92 ('A', 'authors', '', 'username mapping filename'), |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
93 ('', 'filemap', '', |
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
179
diff
changeset
|
94 'remap file to exclude paths or include only certain paths'), |
234
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
224
diff
changeset
|
95 ('', 'username', '', 'username for authentication'), |
33e885f5f86a
Add --username and --password options to all commands
Daniel Tang <dytang@cs.purdue.edu>
parents:
224
diff
changeset
|
96 ('', 'password', '', 'password for authentication'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 ], |
142
42958d9de864
documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents:
140
diff
changeset
|
98 'hg svnclone source [dest]'), |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 } |