annotate hgsubversion/svnwrap/subvertpy_wrapper.py @ 935:1de83496df4e

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.
author Patrick Mezard <patrick@mezard.eu>
date Sun, 23 Sep 2012 19:42:34 +0200
parents e1dbd9646d6a
children bb599a47a9d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import cStringIO
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import getpass
531
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 511
diff changeset
3 import errno
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 import shutil
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 import sys
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 import tempfile
238
e8b3ca865f93 Fix a boneheaded mistake I made when I touched up a previous patch.
Augie Fackler <durin42@gmail.com>
parents: 235
diff changeset
8 import urllib
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
9 import collections
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
11 import common
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
12
324
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
13 import warnings
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
14 warnings.filterwarnings('ignore',
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
15 module='svn.core',
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
16 category=DeprecationWarning)
c4061e57974c svnwrap: Filter out deprecation warnings on 2.6.
Augie Fackler <durin42@gmail.com>
parents: 305
diff changeset
17
708
f28c6d5d73fd subvertpy wrapper: bump version requirement to 0.7.4.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 695
diff changeset
18 subvertpy_required = (0, 7, 4)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
19 subversion_required = (1, 5, 0)
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
20
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
21 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
22 from subvertpy import client
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
23 from subvertpy import delta
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
24 from subvertpy import properties
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
25 from subvertpy import ra
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
26 import subvertpy
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
27 except ImportError:
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
28 raise ImportError('Subvertpy %d.%d.%d or later required, but not found'
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
29 % subvertpy_required)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
30
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
31 def _versionstr(v):
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
32 return '.'.join(str(d) for d in v)
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
33
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
34 if subvertpy.__version__ < subvertpy_required: # pragma: no cover
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
35 raise ImportError('Subvertpy %s or later required, '
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
36 'but %s found'
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
37 % (_versionstr(subvertpy_required),
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
38 _versionstr(subvertpy.__version__)))
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
39
718
db0eb6237420 wrapper: fail properly with unsupported versions of Subvertpy (fixes #212)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 717
diff changeset
40 subversion_version = subvertpy.wc.api_version()
db0eb6237420 wrapper: fail properly with unsupported versions of Subvertpy (fixes #212)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 717
diff changeset
41
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
42 if subversion_version[:3] < subversion_required:
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
43 raise ImportError('Subversion %s or later required, '
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
44 'but Subvertpy is using %s'
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
45 % (_versionstr(subversion_required),
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
46 _versionstr(subversion_version[:3])))
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
47
607
b5f1b629c629 svn_swig_wrapper: improved handling of missing or outdated bindings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 601
diff changeset
48
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 181
diff changeset
49 def version():
709
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
50 svnvers = _versionstr(subversion_version[:3])
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
51 if subversion_version[3]:
2c278d71b73d subvertpy wrapper: check against Subversion version compiled against.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 708
diff changeset
52 svnvers += '-' + subversion_version[3]
695
066b9c8e500e subvertpy_wrapper: don't assume the version is a three-tuple (fixes #206)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 694
diff changeset
53 return (svnvers, 'Subvertpy ' + _versionstr(subvertpy.__version__))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54
601
0fe490ce2fbb isolate all imports of Subversion modules in svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 590
diff changeset
55 # exported values
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
56 ERR_FS_CONFLICT = subvertpy.ERR_FS_CONFLICT
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
57 ERR_FS_NOT_FOUND = subvertpy.ERR_FS_NOT_FOUND
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
58 ERR_FS_TXN_OUT_OF_DATE = subvertpy.ERR_FS_TXN_OUT_OF_DATE
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
59 ERR_INCOMPLETE_DATA = subvertpy.ERR_INCOMPLETE_DATA
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
60 ERR_RA_DAV_PATH_NOT_FOUND = subvertpy.ERR_RA_DAV_PATH_NOT_FOUND
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
61 ERR_RA_DAV_REQUEST_FAILED = subvertpy.ERR_RA_DAV_REQUEST_FAILED
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
62 SubversionException = subvertpy.SubversionException
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
63 apply_txdelta = delta.apply_txdelta_handler
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
64 # superclass for editor.HgEditor
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
65 Editor = object
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
67 def ieditor(fn):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
68 """No-op decorator to identify methods used by the SVN editor interface.
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
69
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
70 This decorator is not needed for Subvertpy, but is retained for
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
71 compatibility with the SWIG bindings.
673
32089d080ff8 editor: move ieditor decorator into svnwrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 672
diff changeset
72 """
92
7486c6f6cccc svnwrap: Fix handling of auth providers so cached credentials can work.
Augie Fackler <durin42@gmail.com>
parents: 89
diff changeset
73
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
74 return fn
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
76 _svntypes = {
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
77 subvertpy.NODE_DIR: 'd',
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
78 subvertpy.NODE_FILE: 'f',
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
79 }
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
80
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
81 class PathAdapter(object):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
82 __slots__ = ('action', 'copyfrom_path', 'copyfrom_rev')
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
83
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
84 def __init__(self, path):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
85 self.action, self.copyfrom_path, self.copyfrom_rev = path
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
86 if self.copyfrom_path:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
87 self.copyfrom_path = intern(self.copyfrom_path)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
88
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
89 class AbstractEditor(object):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
90 __slots__ = ('editor', 'baton')
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
91
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
92 def __init__(self, editor, baton=None):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
93 self.editor = editor
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
94 self.baton = baton
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
95
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
96 def set_target_revision(self, rev):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
97 pass
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
98
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
99 def open_root(self, base_revnum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
100 baton = self.editor.open_root(None, base_revnum)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
101 return DirectoryEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
102
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
103 def open_directory(self, path, base_revnum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
104 baton = self.editor.open_directory(path, self.baton, base_revnum)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
105 return DirectoryEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
106
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
107 def open_file(self, path, base_revnum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
108 baton = self.editor.open_file(path, self.baton, base_revnum)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
109 return FileEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
110
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
111 def add_directory(self, path, copyfrom_path=None, copyfrom_rev=-1):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
112 baton = self.editor.add_directory(
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
113 path, self.baton, copyfrom_path, copyfrom_rev)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
114 return DirectoryEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
115
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
116 def add_file(self, path, copyfrom_path=None, copyfrom_rev=-1):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
117 baton = self.editor.add_file(
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
118 path, self.baton, copyfrom_path, copyfrom_rev)
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
119 return FileEditor(self.editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
120
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
121 def apply_textdelta(self, base_checksum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
122 return self.editor.apply_textdelta(self.baton, base_checksum)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
123
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
124 def change_prop(self, name, value):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
125 raise NotImplementedError()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
126
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
127 def abort(self):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
128 # TODO: should we do something special here?
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
129 self.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
130
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
131 def close(self):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
132 del self.editor
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
133
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
134 def delete_entry(self, path, revnum):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
135 self.editor.delete_entry(path, revnum, self.baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
136
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
137 class FileEditor(AbstractEditor):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
138 def __init__(self, editor, baton):
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
139 super(FileEditor, self).__init__(editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
140
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
141 def change_prop(self, name, value):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
142 self.editor.change_file_prop(self.baton, name, value, pool=None)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
143
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
144 def close(self, checksum=None):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
145 super(FileEditor, self).close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
146
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
147 class DirectoryEditor(AbstractEditor):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
148 def __init__(self, editor, baton):
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
149 super(DirectoryEditor, self).__init__(editor, baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
150
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
151 def change_prop(self, name, value):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
152 self.editor.change_dir_prop(self.baton, name, value, pool=None)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
153
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
154 def close(self):
935
1de83496df4e subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents: 931
diff changeset
155 self.editor.close_directory(self.baton)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
156 super(DirectoryEditor, self).close()
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
157
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 class SubversionRepo(object):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 """Wrapper for a Subversion repository.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
161 This wrapper uses Subvertpy, an alternate set of bindings for Subversion
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
162 that's more pythonic and sucks less. See earlier in this file for version
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
163 requirements.
844
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
164
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
165 Note that password stores do not work, the parameter is only here
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
166 to ensure that the API is the same as for the SWIG wrapper.
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 """
844
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 837
diff changeset
168 def __init__(self, url='', username='', password='', head=None, password_stores=None):
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
169 parsed = common.parse_url(url, username, password)
235
2969a20e0eef Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents: 234
diff changeset
170 # --username and --password override URL credentials
467
3941d73c262e svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents: 392
diff changeset
171 self.username = parsed[0]
3941d73c262e svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents: 392
diff changeset
172 self.password = parsed[1]
235
2969a20e0eef Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents: 234
diff changeset
173 self.svn_url = parsed[2]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 self.init_ra_and_client()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
176
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
177 self.svn_url = self.remote.get_url()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
178 self.uuid = self.remote.get_uuid()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
179 self.root = self.remote.get_repos_root()
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
180 assert self.svn_url.startswith(self.root)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
181
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 # *will* have a leading '/', would not if we used get_repos_root2
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
183 self.subdir = self.svn_url[len(self.root):]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184 if not self.subdir or self.subdir[-1] != '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 self.subdir += '/'
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
186 # the RA interface always yields quoted paths, but the editor interface
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
187 # expects unquoted paths
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
188 self.subdir = urllib.unquote(self.subdir)
89
edeec6829d80 SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents: 87
diff changeset
189 self.hasdiff3 = True
911
772280aed751 Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents: 906
diff changeset
190 self.autoprops_config = common.AutoPropsConfig()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 def init_ra_and_client(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
194 Initializes the RA and client layers.
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
195
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
196 With the SWIG bindings, getting unified diffs runs the remote server
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
197 sometimes runs out of open files. It is not known whether the Subvertpy
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
198 is affected by this.
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
199 """
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
200 def getclientstring():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
201 return 'hgsubversion'
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
202 # TODO: handle certificate authentication, Mercurial style
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
203 def getpass(realm, username, may_save):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
204 return self.username or username, self.password or '', False
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
205 def getuser(realm, may_save):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
206 return self.username or '', False
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
207
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
208 providers = ra.get_platform_specific_client_providers()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
209 providers += [
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
210 ra.get_simple_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
211 ra.get_username_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
212 ra.get_ssl_client_cert_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
213 ra.get_ssl_client_cert_pw_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
214 ra.get_ssl_server_trust_file_provider(),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
215 ra.get_username_prompt_provider(getuser, 0),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
216 ra.get_simple_prompt_provider(getpass, 0),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
217 ]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
218
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
219 auth = ra.Auth(providers)
694
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
220 if self.username:
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
221 auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_USERNAME, self.username)
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
222 if self.password:
e32ed1802478 subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 676
diff changeset
223 auth.set_parameter(subvertpy.AUTH_PARAM_DEFAULT_PASSWORD, self.password)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
224
717
ae5968ffe6fe svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 709
diff changeset
225 self.remote = ra.RemoteAccess(url=self.svn_url,
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
226 client_string_func=getclientstring,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
227 auth=auth)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
228
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
229 self.client = client.Client()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
230 self.client.auth = auth
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231
674
a51e50d943b2 svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 673
diff changeset
232 @property
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233 def HEAD(self):
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
234 return self.remote.get_latest_revnum()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235
674
a51e50d943b2 svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 673
diff changeset
236 @property
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
237 def last_changed_rev(self):
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
238 try:
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
239 holder = []
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
240 def callback(paths, revnum, props, haschildren):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
241 holder.append(revnum)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
242
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
243 self.remote.get_log(paths=[''],
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
244 start=self.HEAD, end=1, limit=1,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
245 discover_changed_paths=False,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
246 callback=callback)
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
247
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
248 return holder[-1]
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
249 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
250 if e.args[0] == ERR_FS_NOT_FOUND:
301
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
251 raise
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
252 else:
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
253 return self.HEAD
79440ed81011 Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 300
diff changeset
254
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
255 def list_dir(self, path, revision=None):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256 """List the contents of a server-side directory.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
257
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
258 Returns a dict-like object with one dict key per directory entry.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 Args:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 dir: the directory to list, no leading slash
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
262 rev: the revision at which to list the directory, defaults to HEAD
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
264 # TODO: reject leading slashes like the docstring says
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
265 if path:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
266 path = path.rstrip('/') + '/'
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
267
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
268 r = self.remote.get_dir(path, revision or self.HEAD, ra.DIRENT_ALL)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
269 dirents, fetched_rev, properties = r
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
270 return dirents
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
271
666
192a3f65837a svnwrap: remove dead code
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 664
diff changeset
272 def revisions(self, paths=None, start=0, stop=0,
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
273 chunk_size=common.chunk_size):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
274 """Load the history of this repo.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
275
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
276 This is LAZY. It returns a generator, and fetches a small number
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
277 of revisions at a time.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
278
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279 The reason this is lazy is so that you can use the same repo object
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 to perform RA calls to get deltas.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
281 """
361
cfdd4ec5230a Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
282 if paths is None:
cfdd4ec5230a Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
283 paths = ['']
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284 if not stop:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 stop = self.HEAD
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286 while stop > start:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
287 def callback(paths, revnum, props, haschildren):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
288 if paths is None:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
289 return
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
290 r = common.Revision(revnum,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
291 props.get(properties.PROP_REVISION_AUTHOR),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
292 props.get(properties.PROP_REVISION_LOG),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
293 props.get(properties.PROP_REVISION_DATE),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
294 dict([(k, PathAdapter(v))
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
295 for k, v in paths.iteritems()]),
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
296 strip_path=self.subdir)
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
297 revisions.append(r)
675
31cd9f41ec09 svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 674
diff changeset
298 # we only access revisions in a FIFO manner
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
299 revisions = collections.deque()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
300
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
301 revprops = [properties.PROP_REVISION_AUTHOR,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
302 properties.PROP_REVISION_DATE,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
303 properties.PROP_REVISION_LOG]
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
304 try:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
305 # TODO: using min(start + chunk_size, stop) may be preferable;
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
306 # ra.get_log(), even with chunk_size set, takes a while
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
307 # when converting the 65k+ rev. in LLVM.
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
308 self.remote.get_log(paths=paths, revprops=revprops,
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
309 start=start + 1, end=stop, limit=chunk_size,
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
310 discover_changed_paths=True,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
311 callback=callback)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
312 except SubversionException, e:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
313 if e.args[1] == ERR_FS_NOT_FOUND:
609
aafbf0d40dc2 svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 607
diff changeset
314 msg = ('%s not found at revision %d!'
aafbf0d40dc2 svnwrap: use SubversionConnectionException instead of mercurial.util.Abort
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 607
diff changeset
315 % (self.subdir.rstrip('/'), stop))
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
316 raise common.SubversionConnectionException(msg)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
317 elif e.args[1] == subvertpy.ERR_FS_NO_SUCH_REVISION:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
318 raise common.SubversionConnectionException(e.args[0])
590
5e9ab25e0112 handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents: 572
diff changeset
319 else:
5e9ab25e0112 handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents: 572
diff changeset
320 raise
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
321
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
322 while len(revisions) > 1:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
323 yield revisions.popleft()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
324
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
325 if len(revisions) == 0:
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
326 # exit the loop; there is no history for the path.
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
327 break
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
328 else:
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
329 r = revisions.popleft()
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
330 start = r.revnum
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 298
diff changeset
331 yield r
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
332
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents: 81
diff changeset
333 def commit(self, paths, message, file_data, base_revision, addeddirs,
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
334 deleteddirs, props, copies):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
335 """Commits the appropriate targets from revision in editor's store.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
336 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
337 def commitcb(*args):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
338 commit_info.append(args)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 commit_info = []
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
340 revprops = { properties.PROP_REVISION_LOG: message }
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
341 # revprops.update(props)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
342 commiteditor = self.remote.get_commit_editor(revprops, commitcb)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
343
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
344 paths = set(paths)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
345 paths.update(addeddirs)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
346 paths.update(deleteddirs)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
347
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
348 # ensure that all parents are visited too; this may be slow
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
349 for path in paths.copy():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
350 for i in xrange(path.count('/'), -1, -1):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
351 p = path.rsplit('/', i)[0]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
352 if p in paths:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
353 continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
354 paths.add(p)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
355 paths = sorted(paths)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
356
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
357 def visitdir(editor, directory, paths, pathidx):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
358 while pathidx < len(paths):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
359 path = paths[pathidx]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
360 if directory and not path.startswith(directory + '/'):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
361 return pathidx
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
362
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
363 pathidx += 1
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
364
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
365 if path in file_data:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
366 # visiting a file
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
367 base_text, new_text, action = file_data[path]
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
368 if action == 'modify':
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
369 fileeditor = editor.open_file(path, base_revision)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
370 elif action == 'add':
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
371 frompath, fromrev = copies.get(path, (None, -1))
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
372 if frompath:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
373 frompath = self.path2url(frompath)
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
374 fileeditor = editor.add_file(path, frompath, fromrev)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
375 elif action == 'delete':
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
376 editor.delete_entry(path, base_revision)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
377 continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
378 else:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
379 assert False, 'invalid action \'%s\'' % action
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
380
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
381 if path in props:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
382 if props[path].get('svn:special', None):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
383 new_text = 'link %s' % new_text
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
384 for p, v in props[path].iteritems():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
385 fileeditor.change_prop(p, v)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
386
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
387
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
388 handler = fileeditor.apply_textdelta()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
389 delta.send_stream(cStringIO.StringIO(new_text), handler)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
390 fileeditor.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
391
175
2412800b1258 Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents: 172
diff changeset
392 else:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
393 # visiting a directory
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
394 if path in addeddirs:
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
395 direditor = editor.add_directory(path)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
396 elif path in deleteddirs:
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
397 direditor = editor.delete_entry(path, base_revision)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
398 continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
399 else:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
400 direditor = editor.open_directory(path)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
401
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
402 if path in props:
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
403 for p, v in props[path].iteritems():
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
404 direditor.change_prop(p, v)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
405
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 718
diff changeset
406 pathidx = visitdir(direditor, path, paths, pathidx)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
407 direditor.close()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
408
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
409 return pathidx
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
410
906
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
411 try:
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
412 rooteditor = commiteditor.open_root()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
413 visitdir(rooteditor, '', paths, 0)
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
414 rooteditor.close()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
415 commiteditor.close()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
416 except:
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
417 commiteditor.abort()
757d6a862c83 subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents: 844
diff changeset
418 raise
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
419
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
420 def get_replay(self, revision, editor, oldestrev=0):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
421
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
422 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
423 self.remote.replay(revision, oldestrev, AbstractEditor(editor))
837
805ef27fbcbe hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents: 832
diff changeset
424 except (SubversionException, NotImplementedError), e: # pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
425 # can I depend on this number being constant?
796
22f0c50c29a6 subvertpy wrapper: handle NotImplementedError from Subvertpy on missing replay
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 730
diff changeset
426 if (isinstance(e, NotImplementedError) or
22f0c50c29a6 subvertpy wrapper: handle NotImplementedError from Subvertpy on missing replay
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 730
diff changeset
427 e.args[1] == subvertpy.ERR_RA_NOT_IMPLEMENTED or
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
428 e.args[1] == subvertpy.ERR_UNSUPPORTED_FEATURE):
672
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
429 msg = ('This Subversion server is older than 1.4.0, and '
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
430 'cannot satisfy replay requests.')
2cc1342d4476 svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 668
diff changeset
431 raise common.SubversionRepoCanNotReplay(msg)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434
649
2060e0ca8dd5 svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
435 def get_revision(self, revision, editor):
2060e0ca8dd5 svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
436 ''' feed the contents of the given revision to the given editor '''
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
437 reporter = self.remote.do_update(revision, '', True,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
438 AbstractEditor(editor))
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
439 reporter.set_path('', revision, True)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
440 reporter.finish()
649
2060e0ca8dd5 svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
441
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
442 def get_unified_diff(self, path, revision, other_path=None, other_rev=None,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
443 deleted=True, ignore_type=False):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
444 """Gets a unidiff of path at revision against revision-1.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
445 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
446
491
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
447 url = self.path2url(path)
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
448 url2 = (other_path and self.path2url(other_path) or url)
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
449
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 if other_rev is None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 other_rev = revision - 1
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
452
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
453 outfile, errfile = self.client.diff(other_rev, revision, url2, url,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
454 no_diff_deleted=deleted,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
455 ignore_content_type=ignore_type)
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
456 error = errfile.read()
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
457 assert not error, error
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
458
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
459 return outfile.read()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
460
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
461 def get_file(self, path, revision):
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
462 """Return content and mode of file at given path and revision.
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
463
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
464 "link " prefix is dropped from symlink content. Mode is 'x' if
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
465 file is executable, 'l' if a symlink, the empty string
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
466 otherwise. If the file does not exist at this revision, raise
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
467 IOError.
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
468 """
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
469 mode = ''
66
a31968146f3c svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
470 try:
931
e1dbd9646d6a svnwrap: use custom StringIO class in get_file()
Patrick Mezard <patrick@mezard.eu>
parents: 911
diff changeset
471 out = common.SimpleStringIO()
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
472 rev, info = self.remote.get_file(path, out, revision)
122
04c92c2c4501 SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents: 97
diff changeset
473 data = out.getvalue()
04c92c2c4501 SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents: 97
diff changeset
474 out.close()
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
475 if isinstance(info, list):
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
476 info = info[-1]
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
477 mode = (properties.PROP_EXECUTABLE in info) and 'x' or ''
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
478 mode = (properties.PROP_SPECIAL in info) and 'l' or mode
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
479 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
480 if e.args[1] in (ERR_FS_NOT_FOUND, ERR_RA_DAV_PATH_NOT_FOUND):
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
481 # File not found
531
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 511
diff changeset
482 raise IOError(errno.ENOENT, e.args[0])
74
450d5d9d3b80 SubversionRepo: do not use temporary file in get_file()
Patrick Mezard <pmezard@gmail.com>
parents: 70
diff changeset
483 raise
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
484 if mode == 'l':
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
485 linkprefix = "link "
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
486 if data.startswith(linkprefix):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 92
diff changeset
487 data = data[len(linkprefix):]
76
6c62bd201785 SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents: 75
diff changeset
488 return data, mode
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
489
172
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
490 def list_props(self, path, revision):
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
491 """Return a mapping of property names to values, raise IOError if
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
492 specified path does not exist.
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
493 """
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
494 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
495 pl = self.client.proplist(self.path2url(path), revision,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
496 client.depth_empty)
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
497 except SubversionException, e:
172
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
498 # Specified path does not exist at this revision
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
499 if e.args[1] == subvertpy.ERR_NODE_UNKNOWN_KIND:
531
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 511
diff changeset
500 raise IOError(errno.ENOENT, e.args[0])
172
84fbf1469a31 SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents: 155
diff changeset
501 raise
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
502 return pl and pl[0][1] or {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
503
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
504 def list_files(self, dirpath, revision):
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
505 """List the content of a directory at a given revision, recursively.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
506
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
507 Yield tuples (path, kind) where 'path' is the entry path relatively to
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
508 'dirpath' and 'kind' is 'f' if the entry is a file, 'd' if it is a
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
509 directory. Raise IOError if the directory cannot be found at given
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
510 revision.
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
511 """
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
512 try:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
513 entries = self.client.list(self.path2url(dirpath), revision,
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
514 client.depth_infinity, ra.DIRENT_KIND)
667
e872f549e42f svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 666
diff changeset
515 except SubversionException, e:
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
516 if e.args[1] == subvertpy.ERR_FS_NOT_FOUND:
531
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 511
diff changeset
517 raise IOError(errno.ENOENT,
cf4fe45bf8fd Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 511
diff changeset
518 '%s cannot be found at r%d' % (dirpath, revision))
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
519 raise
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
520 for path, e in entries.iteritems():
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
521 if not path: continue
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
522 kind = _svntypes.get(e['kind'])
77
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
523 yield path, kind
ed3dd5bf45da fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents: 76
diff changeset
524
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
525 def checkpath(self, path, revision):
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
526 """Return the entry type at the given revision, 'f', 'd' or None
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
527 if the entry does not exist.
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
528 """
676
2a9c009790ce svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 675
diff changeset
529 kind = self.remote.check_path(path, revision)
87
b033d74be76b fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
530 return _svntypes.get(kind)
489
cd793ca555af svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents: 467
diff changeset
531
491
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
532 def path2url(self, path):
b71507d7becc svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents: 489
diff changeset
533 """Build svn URL for path, URL-escaping path.
489
cd793ca555af svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents: 467
diff changeset
534 """
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
535 if not path or path == '.':
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
536 return self.svn_url
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 491
diff changeset
537 assert path[0] != '/', path
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 796
diff changeset
538 return '/'.join((self.svn_url, urllib.quote(path).rstrip('/'),))