Commit Graph

66 Commits

Author SHA1 Message Date
Mitsuhiro Koga
93b9795d2b svn_swig_wrapper: Ensure subversion config files
We will create a subversion config file if it does not exist.
Currently, svn_config_ensure() exists only swig.
2012-10-29 20:16:19 +09:00
Mitsuhiro Koga
b28225df89 svnwrap: Implement handling of ssl_client_cert_pw_prompt_provider 2012-10-23 03:50:00 +09:00
Mitsuhiro Koga
46eebbab08 svnwrap: Implement handling of ssl_client_cert_prompt_provider 2012-10-23 19:33:15 +09:00
Mitsuhiro Koga
2e72c9c185 svnwrap: Improved handling of username_prompt_provider 2012-10-23 20:12:10 +09:00
Mitsuhiro Koga
5952188779 svnwrap: Improved handling of simple_prompt_provider 2012-10-23 20:12:32 +09:00
Mitsuhiro Koga
c65b7d4cec svnwrap: Refactor the svn_auth_ssl_server_trust_prompt to add other handler
- Since there are five handler, change to SubversionPrompt class from svn_auth_ssl_server_trust_prompt().
- Moved out of the handler to check the callback function is non-None.
2012-10-24 02:19:15 +09:00
Mitsuhiro Koga
a54ae1f482 svnwrap: Implement handling of get_ssl_server_trust_prompt_provider
If the server certificate is untrusted when connected to a subversion repository
using the connection SSL, respond with a message similar to svn client.
Here, we can choose either a permanent accept, temporary accept, rejection.
2012-10-10 00:28:38 +09:00
Patrick Mezard
36f644e1b9 editor: use SimpleStringIO in apply_text()
The design is a little ugly as the data stored in _openfiles will be a
string or a SimpleStringIO depending on the file having been edited or
not but this is a simple way to avoid allocating large blocks of data.
This is also a bet the output stream passed to apply_text() is only
being written and never seeked or read.
2012-09-26 22:18:31 +02:00
Patrick Mezard
ceaf6f2206 editor: add close_file(), enforce file batons semantics
Supporting close_file() is a big step toward reducing memory consumption
as now know which files are still to be edited and which are done
already.
2012-09-24 23:12:01 +02:00
Patrick Mezard
05c5093e88 subvertpy_wrapper: move methods in the relevant editors
Files and directories can only be opened/deleted/closed from a
DirectoryEditor, and deltas can only be applied on a FileEditor.
Invariants could be made stronger by adding a third RevisionEditor class
containing set_target_revision() and open_root() but this will probably
not give interesting results.
2012-09-23 18:06:56 +02:00
Patrick Mezard
0cd03310f8 subvertpy_wrapper: fix files and directories batons handling
The subvertpy wrapper was not recording and passing back the batons
returned by calls such as open_file() or open_directory(). Instead, it
was relying on knowledge about the HgEditor class and was passing the
path argument. Its behaviour was therefore not exactly the same as the
swig one because HgEditor sometimes tests the input baton and skips
None ones, usually generated for ignored entries.

Also, AbstractEditor was translating open_root() into
open_directory(''), while the former, not implemented by HgEditor, was
supplied as a default implementation by the swig bindings. The behaviour
was different again.

This patch was not motivated by any known bug but batons are interesting
as they help control edited entries lifetime. We may use them to reduce
replay mode memory consumption.
2012-09-23 19:42:34 +02:00
Patrick Mezard
6fb10004ee svnwrap: use custom StringIO class in get_file()
The wrappers were calling ra.get_file() with a cStringIO object.
Empirically, svn 1.7.5 is writing 16kB blocks to the stream object, and
cStringIO reallocates its internal buffer and doubles its size whenever
it is filled. With large committed files this requires two large
memory blocks at the same time.

SimpleStringIO implements the mimimum StringIO interface used by
ra.get_file() but instead stores all the blocks and "join" them at the
end. It means more fragmentation but requires only one large block,
without overallocation. Also, 16kB blocks should be friendly to most
allocators.

In practice, this simple change let me convert a revision containing
multiple moderately large files, the largest being around 450MB, with a
32-bits Windows setup, python 2.7, swig svn 1.7.5, in stupid mode, while
it was previously aborting with "not enough memory". The same revision
still fails in replay mode.
2012-09-16 19:31:49 +02:00
Ronny Voelker
26bf8fb781 Honor SVN auto-props (solves issue #186)
The auto-props are read from the users subversion configuration file
(~/.subversion/config on posix). System-wide configuration files are not
taken into account.

The implementation completely bypasses the subversion bindings,
because the current bindings provide little support for this functionality.
2012-01-01 15:59:15 +01:00
Augie Fackler
1250f1d733 subvertpy bindings: abort transaction if we can't finalize it
This should prevent us from leaking pending transactions on the
server.
2012-05-17 09:06:49 -05:00
Augie Fackler
f48040d1bc swig bindings: abort transaction if we can't finalize it
This should prevent us from leaking pending transactions on the
server.
2012-05-17 08:23:49 -05:00
Bryan O'Sullivan
980a7406ee canonicalize svn paths even more awesomely
It turns out that SVN has bizarre path canonicalization rules that
are sort of close to what urllib.quote does, but different in
peculiar ways, and 1.7 suddenly cares deeply about canonicality.
For instance, space (' ') maps to %20, but '~' stays unchanged
instead of turning into %7e.

Along with its new policy of frequent beatings administered to users
of its bindings, SVN 1.7 introduces a function that idempotently
canonicalizes URIs, which I found sort of by accident, because
that's how you learn about SVN API changes.

Older versions of SVN are less anal, so urllib.quote continues to
work fine for them.
2012-05-14 01:13:07 +02:00
Bryan O'Sullivan
d3491e56a5 replay: workaround svn not telling us about x/l flags (issue346) 2012-05-13 15:28:50 +02:00
Bryan O'Sullivan
af24bccc14 svn_swig_wrapper: canonicalize path 2012-05-13 15:23:30 +02:00
Jerome M. BERGER
f411ca18f8 Added ability to configure the password stores 2011-11-22 11:54:25 +01:00
Yonggang Luo
615b9a6b97 hgsubversion/*.py: add space after comment symbol # 2011-10-17 22:44:15 +08:00
Yonggang Luo
bebd961e2a globally: clean up whitespace around operators and commas to conform with PEP8
Mostly autoformatted by Eclipse. A few manual corrections were
performed where Eclipse's autoformatter did something non-idiomatic.
2011-10-12 15:35:25 +08:00
Dan Villiom Podlaski Christiansen
e7f792d2ef subvertpy wrapper: handle NotImplementedError from Subvertpy on missing replay 2011-03-31 20:30:29 +02:00
Peter Arrenbrecht
a97590f5ae subvertpy: fix bug with pushing changes to stuff in subdirs
Seems one needs to call direditor.open_file(path) with a full path, not
one that is relative to the direditor's directory.
2010-09-23 13:50:17 +02:00
Dan Villiom Podlaski Christiansen
dc354599e2 wrapper: fail properly with unsupported versions of Subvertpy (fixes #212)
Calling subvertpy.wc.api_version() will raise an AttributeError with
versions of Subvertpy prior to 0.7.4. This AttributeError completely
breaks hgsubversion, as our infrastructure assumes that only
ImportErrors are raised during imports.

Delaying the call to api_version() until after the Subvertpy version
check should make things work again.
2010-10-03 17:53:20 +02:00
Dan Villiom Podlaski Christiansen
7a95293acb svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
The way hgsubversion handles URLs that may or may not be quoted is
somewhat fragile. As part of fixing issue 132 in 06d89c2063a2, the
path component of URLs was always quoted. The URL has been attempted
encoded since the initial check-in.

The fix from 06d89c2063a2 was incomplete; reverting it allows us to
clone a URL with a '~' in it.[1] Encoding the URL as UTF-8 seldom
works as expected, as the default string encoding is ASCII, causing
Python to be unable to decode any URL containing an 8-bit
character.

The core problem here is that we don't know whether the URL specified
by the user is quoted or not. Rather than trying to deal with this
ourselves, we pass the problem on to Subversion. Then, we obtain the
URL from the RA instance, where it is always quoted. (It's worth
noting that the editor interface, on the other hand, always deals with
unquoted paths...)

Thus, the following invariants should apply to SubversionRepo
attributes:
- svn_url and root will always be quoted.
- subdir will always be unquoted.

Tests are added that verify that it won't affect the conversion
whether a URL is specified in quoted or unquoted form. Furthermore, a
test fixture for this is added *twice*, so that we can thoroughly test
both quoted and unquoted URLs. I'm not adding a test dedicated to
tildes in URLs; it doesn't seem necessary.

[1] Such as <https://svn.kenai.com/svn/winsw~subversion>.
2010-10-04 21:00:36 -05:00
Dan Villiom Podlaski Christiansen
cf80fcfd04 subvertpy wrapper: check against Subversion version compiled against.
The previously used method for checking the Subversion version,
subvertpy.wc.version(), reported back the version of the runtime
library used. This is not what we're interested in; we want to know
what version it was compiled against.

These functions were not available in Subvertpy 0.7.3, necessitating
the earlier bump of the version requirement to 0.7.4.
2010-09-29 18:04:26 +02:00
Dan Villiom Podlaski Christiansen
8c1023cd7c subvertpy wrapper: bump version requirement to 0.7.4.
0.7.4 was released on 2010-09-25 or 25 September 2010.
2010-09-29 18:04:26 +02:00
Dan Villiom Podlaski Christiansen
4cb42fcb70 svnwrap: improve error message when no bindings are found. 2010-09-14 15:25:45 +02:00
Dan Villiom Podlaski Christiansen
6909ff1bc2 subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
0.7.3.1 breaks this. While at it, the capitalisation of `Subvertpy' is
made consistent, and the Subversion tag, if present, is included in
the output.
2010-09-14 21:02:49 +02:00
Peter Arrenbrecht
76a82dfc04 subvertpy: set default username/pwd as with swig
Fixes wrong user name being used for pushed commits.
2010-09-15 17:50:30 +02:00
Dan Villiom Podlaski Christiansen
7bc9b7dc45 svnwrap: add runtime override for choice of Subversion bindings
By setting the `HGSUBVERSION_BINDINGS environment variable to either
`SWIG' or `Subvertpy', the choice of bindings can be forced at
runtime. (For ease of use, the comparison is case-insensitive.)

Examples:

% HGSUBVERSION_BINDINGS=swig hg version --svn
Mercurial Distributed SCM (version 1.6+172-b25e1ced9861)
...
hgsubversion: 1.1.2+43-276742da2d85
Subversion: 1.6.12
bindings: SWIG

% HGSUBVERSION_BINDINGS=subvertpy hg version --svn
Mercurial Distributed SCM (version 1.6+172-b25e1ced9861)
...
hgsubversion: 1.1.2+43-276742da2d85
Subversion: 1.6.12
bindings: Subvertpy 0.7.4

% HGSUBVERSION_BINDINGS=none hg version --svn
Mercurial Distributed SCM (version 1.6+172-b25e1ced9861)
...
abort: cannot use hgsubversion; bindings disabled using HGSUBVERSION_BINDINGS!
2010-08-11 20:03:47 +02:00
Dan Villiom Podlaski Christiansen
6b99ad8b96 svnwrap: suggest installing Subvertpy when no bindings are present 2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
da9aad1d2b svnwrap: activate & prefer subvertpy bindings when available
All tests pass.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
6792daee4e svnwrap: add subvertpy wrapper
Subvertpy is, in many ways, a better interface to Subversion than the
SWIG bindings. It's faster, leaks less and offers a cleaner API. The
added wrapper is able to coexist with the SWIG wrapper, and not
enabled by default. In order to allow this, the wrapper adapts the
output from Subvertpy so that it is similar to the output from the
SWIG bindings. An example of this can be seen in the modules that work
with editors: the nested editors offered by Subvertpy had to be
flattened to work with our editor code.

This change does not activate the Subvertpy wrapper, yet, and thus
does not affect any functionality.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
faf346e7b2 svnwrap: improve a docstring & a comment.
The docstring for SubversionRepo was technically inaccurate; not only
do we require Subversion 1.5, but the reference to a required
parameter is inaccurate, as the parameter has a default value. (To be
fair, relying on the default value is unlikely to work...)

Part of a comment in SubversionRepo.revisions() was redundant, and
could be removed.

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
b11a1e2880 svnwrap: use decorator syntax for properties.
The original reason not to use property syntax was that it didn't work
with Python 2.3. Mercurial dropped support for it more than a year
ago...

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
9ecf2e60f4 editor: move ieditor decorator into svnwrap.
The Subvertpy wrapper will not need this decorator, and moving the
decorator into svnwrap will allow the wrapper to provide a no-op
replacement.

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
cc2a46ccb8 svnwrap: factor out a common module
The new `common' module holds code not specific to the SWIG
wrapper. Factoring it out makes providing multiple wrappers easier.

No functionality change, although imports in one test were updated.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
a9ce123185 svnwrap: s/_chunk_size/chunk_size/
The underscore prefix suggests that the chunk_size is a private
variable. There's no reason for this, so we remove it in preparation
for a refactoring.

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
97e4658b48 svnwrap: s/core.SubversionException/SubversionException/
A recent change made core.SubversionException a member of
svnwrap. Referencing it directly makes the code ever so slightly
cleaner.

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
8481d5ccec svnwrap: remove dead code
Some member functions of SubversionRepo were unused, and removing them
frees other wrappers from adding possibly incorrect implementations of
them.

Two methods, `tags_at_rev' and `_get_copy_source' were completely
unused and could easily be removed. Another two methods, `branches'
and `tags' had explicit tests for them but weren't used in the code
proper; they were removed too. The START property was unnecessary and
could be removed with a tiny refactoring.

No functionality change.
2010-08-11 19:57:35 +02:00
Dan Villiom Podlaski Christiansen
295c0a8c6d svnwrap: kill the ctypes wrapper.
The wrapper was never anywhere near functional, and with the upcoming
subvertpy wrapper, the need for it has diminished. If the
implementation is ever completed, the code can be recovered from the
history of the repository.

No functionality change.
2010-08-11 19:57:34 +02:00
Dan Villiom Podlaski Christiansen
e2e9fb4206 version: mention bindings type in version
In addition, the version output has been rejiggered a bit to mention
the version of hgsubversion first.

While at it, `svn' is changed to `Subversion', as this is its the
proper name.

Before:

% hg version --svn
...
svn bindings: 1.6.12
hgsubversion: 1.1.2+45-123ac53a6343

After:

% hg version --svn
...
hgsubversion: 1.1.2+45-123ac53a6343
Subversion: 1.6.12
bindings: SWIG
2010-08-11 19:57:34 +02:00
Dan Villiom Podlaski Christiansen
28d19c0d6d svnwrap: add get_revision(); a thing wrapper around ra.do_update()
This function allows us to fetch the entire contents of a revision in
a reasonably efficient manner.
2010-07-20 11:55:07 +02:00
Dan Villiom Podlaski Christiansen
3ea18817b9 svncommands: fix layering violation & tweak error messages.
Importing `SubversionException' directly from `svn.core' is a layering
violation: Anything within the Subversion bindings should only be
accessed via svnwrap.

The advantages to doing this are twofold: we only need to intercept
missing bindings in one place, and we have the option of supporting
alternate bindings. As an added bonus, the recently-added support for
intercepting missing Subversion bindings actually works.

Two error messages are tweaked to remove `It appears...' from one
error message (just blaming Subversion instead) and make both errors
include the URL in the suggested command line.
2010-05-14 20:22:32 +02:00
Dan Villiom Podlaski Christiansen
38127671b5 svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
This makes svnwrap independent of Mercurial.
2010-05-14 14:21:25 +02:00
Dan Villiom Podlaski Christiansen
96678cc2bc svn_swig_wrapper: improved handling of missing or outdated bindings.
Instead of aborting with a generic message when Subversion bindings
are missing, provide a helpful message. Also, the version check is
refactored to make it easier to bump our requirements in the
future. Finally, error messages are shorten so they fit in 80 columns
along with the standard `abort: ' prefix.
2010-04-30 17:35:36 +02:00
Dan Villiom Podlaski Christiansen
05fd2cecc4 isolate all imports of Subversion modules in svnwrap.
editor: move dependancy on Subversion bindings to svnwrap package.

In the editor, this involves importing the superclass of `HgEditor' as
`svnwrap.Editor'. Additionally, the `delta.svn_txdelta_apply()'
function has been abstracted away into a simpler interface, stored in
`svnwrap.apply_txdelta()'.
2010-03-31 17:51:09 +02:00
Jonathan Kotta
4aa1d845af handle nonexistant svn repositories, fixes issue 137 2010-03-09 20:58:08 -06:00
Dirkjan Ochtman
6b15b9efbb svnwrap: save the repository root, this might be useful later on 2010-02-22 23:24:11 +01:00