annotate __init__.py @ 302:827d4702a3b3

Adapt rebuildmeta and its test to the disappearance of '.hg/svn/last_rev'. This should have been part of changeset a55a16f3eb6d. Oops.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 27 Mar 2009 03:28:22 +0100
parents 79440ed81011
children ce676eff002b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 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
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:
293
fa26c7ef0180 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
edd9f4e5154a Phrasing nits.
Augie Fackler <durin42@gmail.com>
parents: 142
diff changeset
52 You can specify multiple paths for the location of tags using comma
edd9f4e5154a Phrasing nits.
Augie Fackler <durin42@gmail.com>
parents: 142
diff changeset
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:
d06572495c5e Better error message when we encounter an unknown SSL cert.
Augie Fackler <durin42@gmail.com>
parents: 199
diff changeset
61 res = fetch_command.fetch_revisions(ui, svn_url, hg_repo_path, **opts)
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:
293
fa26c7ef0180 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'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 ],
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
83 svncommand.generate_help(),
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 52
diff changeset
84 ),
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
85 "svnclone":
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
86 (svn_fetch,
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 293
diff changeset
87 [('S', 'skipto-rev', 0, 'skip commits before this revision.'),
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 293
diff changeset
88 ('H', 'head', 0, 'skip revisions after this one.'),
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
89 ('', '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
90 ('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
91 ('A', 'authors', '', 'username mapping filename'),
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
92 ('', 'filemap', '',
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 179
diff changeset
93 '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
94 ],
142
42958d9de864 documentation update
Alexander Solovyov <piranha@piranha.org.ua>
parents: 140
diff changeset
95 'hg svnclone source [dest]'),
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 }