Mercurial > hgsubversion
annotate hgsubversion/svnwrap/subvertpy_wrapper.py @ 939:997de286ba0c
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.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Mon, 24 Sep 2012 23:12:01 +0200 |
parents | bb599a47a9d0 |
children | 27fec8bf9273 |
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 abort(self): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
104 # TODO: should we do something special here? |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
105 self.close() |
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 close(self): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
108 del self.editor |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
109 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
110 class FileEditor(AbstractEditor): |
935
1de83496df4e
subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents:
931
diff
changeset
|
111 def __init__(self, editor, baton): |
1de83496df4e
subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents:
931
diff
changeset
|
112 super(FileEditor, self).__init__(editor, baton) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
113 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
114 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
|
115 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
|
116 |
936
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
117 def apply_textdelta(self, base_checksum): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
118 return self.editor.apply_textdelta(self.baton, base_checksum) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
119 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
120 def close(self, checksum=None): |
939
997de286ba0c
editor: add close_file(), enforce file batons semantics
Patrick Mezard <patrick@mezard.eu>
parents:
936
diff
changeset
|
121 self.editor.close_file(self.baton, checksum) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
122 super(FileEditor, self).close() |
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 class DirectoryEditor(AbstractEditor): |
935
1de83496df4e
subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents:
931
diff
changeset
|
125 def __init__(self, editor, baton): |
1de83496df4e
subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents:
931
diff
changeset
|
126 super(DirectoryEditor, self).__init__(editor, baton) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
127 |
936
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
128 def delete_entry(self, path, revnum): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
129 self.editor.delete_entry(path, revnum, self.baton) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
130 |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
131 def open_directory(self, path, base_revnum): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
132 baton = self.editor.open_directory(path, self.baton, base_revnum) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
133 return DirectoryEditor(self.editor, baton) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
134 |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
135 def add_directory(self, path, copyfrom_path=None, copyfrom_rev=-1): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
136 baton = self.editor.add_directory( |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
137 path, self.baton, copyfrom_path, copyfrom_rev) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
138 return DirectoryEditor(self.editor, baton) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
139 |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
140 def open_file(self, path, base_revnum): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
141 baton = self.editor.open_file(path, self.baton, base_revnum) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
142 return FileEditor(self.editor, baton) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
143 |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
144 def add_file(self, path, copyfrom_path=None, copyfrom_rev=-1): |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
145 baton = self.editor.add_file( |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
146 path, self.baton, copyfrom_path, copyfrom_rev) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
147 return FileEditor(self.editor, baton) |
bb599a47a9d0
subvertpy_wrapper: move methods in the relevant editors
Patrick Mezard <patrick@mezard.eu>
parents:
935
diff
changeset
|
148 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
149 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
|
150 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
|
151 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
152 def close(self): |
935
1de83496df4e
subvertpy_wrapper: fix files and directories batons handling
Patrick Mezard <patrick@mezard.eu>
parents:
931
diff
changeset
|
153 self.editor.close_directory(self.baton) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
154 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
|
155 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 class SubversionRepo(object): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 """Wrapper for a Subversion repository. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
159 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
|
160 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
|
161 requirements. |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
162 |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
163 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
|
164 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
|
165 """ |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
837
diff
changeset
|
166 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
|
167 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
|
168 # --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
|
169 self.username = parsed[0] |
3941d73c262e
svnwrappers: override svn+ssh credentials with supplied ones if any
Patrick Mezard <pmezard@gmail.com>
parents:
392
diff
changeset
|
170 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
|
171 self.svn_url = parsed[2] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
173 self.init_ra_and_client() |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
174 |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
709
diff
changeset
|
175 self.svn_url = self.remote.get_url() |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
176 self.uuid = self.remote.get_uuid() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
177 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
|
178 assert self.svn_url.startswith(self.root) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
179 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
180 # *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
|
181 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
|
182 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
|
183 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
|
184 # 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
|
185 # 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
|
186 self.subdir = urllib.unquote(self.subdir) |
89
edeec6829d80
SubversionRepo: remember svn.diff3() does not work
Patrick Mezard <pmezard@gmail.com>
parents:
87
diff
changeset
|
187 self.hasdiff3 = True |
911
772280aed751
Honor SVN auto-props (solves issue #186)
Ronny Voelker <ronny.voelker@googlemail.com>
parents:
906
diff
changeset
|
188 self.autoprops_config = common.AutoPropsConfig() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
190 def init_ra_and_client(self): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
191 """ |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
192 Initializes the RA and client layers. |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
193 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
194 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
|
195 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
|
196 is affected by this. |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
197 """ |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
198 def getclientstring(): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
199 return 'hgsubversion' |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
200 # TODO: handle certificate authentication, Mercurial style |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
201 def getpass(realm, username, may_save): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
202 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
|
203 def getuser(realm, may_save): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
204 return self.username or '', False |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
205 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
206 providers = ra.get_platform_specific_client_providers() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
207 providers += [ |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
208 ra.get_simple_provider(), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
209 ra.get_username_provider(), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
210 ra.get_ssl_client_cert_file_provider(), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
211 ra.get_ssl_client_cert_pw_file_provider(), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
212 ra.get_ssl_server_trust_file_provider(), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
213 ra.get_username_prompt_provider(getuser, 0), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
214 ra.get_simple_prompt_provider(getpass, 0), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
215 ] |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
216 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
217 auth = ra.Auth(providers) |
694
e32ed1802478
subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
676
diff
changeset
|
218 if self.username: |
e32ed1802478
subvertpy: set default username/pwd as with swig
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
676
diff
changeset
|
219 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
|
220 if self.password: |
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_PASSWORD, self.password) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
222 |
717
ae5968ffe6fe
svnwrap: fix handling of quotable URLs (fixes #197, refs #132)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
709
diff
changeset
|
223 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
|
224 client_string_func=getclientstring, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
225 auth=auth) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
226 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
227 self.client = client.Client() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
228 self.client.auth = auth |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
230 @property |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
231 def HEAD(self): |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
232 return self.remote.get_latest_revnum() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
233 |
674
a51e50d943b2
svnwrap: use decorator syntax for properties.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
673
diff
changeset
|
234 @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
|
235 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
|
236 try: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
237 holder = [] |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
238 def callback(paths, revnum, props, haschildren): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
239 holder.append(revnum) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
240 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
241 self.remote.get_log(paths=[''], |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
242 start=self.HEAD, end=1, limit=1, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
243 discover_changed_paths=False, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
244 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
|
245 |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
246 return holder[-1] |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
247 except SubversionException, e: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
248 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
|
249 raise |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
250 else: |
79440ed81011
Allow specifying a revision to stop at using the -H flag.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
300
diff
changeset
|
251 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
|
252 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
253 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
|
254 """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
|
255 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 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
|
257 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
258 Args: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
259 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
|
260 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
|
261 """ |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
262 # TODO: reject leading slashes like the docstring says |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
263 if path: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
264 path = path.rstrip('/') + '/' |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
265 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
266 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
|
267 dirents, fetched_rev, properties = r |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
268 return dirents |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
269 |
666
192a3f65837a
svnwrap: remove dead code
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
664
diff
changeset
|
270 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
|
271 chunk_size=common.chunk_size): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 """Load the history of this repo. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
273 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 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
|
275 of revisions at a time. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
276 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 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
|
278 to perform RA calls to get deltas. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
279 """ |
361
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
280 if paths is None: |
cfdd4ec5230a
Merge fetch_history_at_paths() and revisions() in svn wrappers.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
342
diff
changeset
|
281 paths = [''] |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
282 if not stop: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
283 stop = self.HEAD |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
284 while stop > start: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
285 def callback(paths, revnum, props, haschildren): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
286 if paths is None: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
287 return |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
288 r = common.Revision(revnum, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
289 props.get(properties.PROP_REVISION_AUTHOR), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
290 props.get(properties.PROP_REVISION_LOG), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
291 props.get(properties.PROP_REVISION_DATE), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
292 dict([(k, PathAdapter(v)) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
293 for k, v in paths.iteritems()]), |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
294 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
|
295 revisions.append(r) |
675
31cd9f41ec09
svnwrap: improve a docstring & a comment.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
674
diff
changeset
|
296 # 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
|
297 revisions = collections.deque() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
298 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
299 revprops = [properties.PROP_REVISION_AUTHOR, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
300 properties.PROP_REVISION_DATE, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
301 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
|
302 try: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
303 # 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
|
304 # 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
|
305 # when converting the 65k+ rev. in LLVM. |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
306 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
|
307 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
|
308 discover_changed_paths=True, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
309 callback=callback) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
310 except SubversionException, e: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
311 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
|
312 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
|
313 % (self.subdir.rstrip('/'), stop)) |
672
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
314 raise common.SubversionConnectionException(msg) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
315 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
|
316 raise common.SubversionConnectionException(e.args[0]) |
590
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
317 else: |
5e9ab25e0112
handle nonexistant svn repositories, fixes issue 137
Jonathan Kotta <jpkotta@gmail.com>
parents:
572
diff
changeset
|
318 raise |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
319 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
320 while len(revisions) > 1: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
321 yield revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
322 |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
323 if len(revisions) == 0: |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
324 # 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
|
325 break |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 else: |
300
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
327 r = revisions.popleft() |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
328 start = r.revnum |
4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
298
diff
changeset
|
329 yield r |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 |
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
81
diff
changeset
|
331 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
|
332 deleteddirs, props, copies): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 """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
|
334 """ |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
335 def commitcb(*args): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
336 commit_info.append(args) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
337 commit_info = [] |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
338 revprops = { properties.PROP_REVISION_LOG: message } |
837
805ef27fbcbe
hgsubversion/*.py: add space after comment symbol #
Yonggang Luo <luoyonggang@gmail.com>
parents:
832
diff
changeset
|
339 # revprops.update(props) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
340 commiteditor = self.remote.get_commit_editor(revprops, commitcb) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
341 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
342 paths = set(paths) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
343 paths.update(addeddirs) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
344 paths.update(deleteddirs) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
345 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
346 # 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
|
347 for path in paths.copy(): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
348 for i in xrange(path.count('/'), -1, -1): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
349 p = path.rsplit('/', i)[0] |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
350 if p in paths: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
351 continue |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
352 paths.add(p) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
353 paths = sorted(paths) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
354 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
355 def visitdir(editor, directory, paths, pathidx): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
356 while pathidx < len(paths): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
357 path = paths[pathidx] |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
358 if directory and not path.startswith(directory + '/'): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
359 return pathidx |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
360 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
361 pathidx += 1 |
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 if path in file_data: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
364 # visiting a file |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
365 base_text, new_text, action = file_data[path] |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
366 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
|
367 fileeditor = editor.open_file(path, base_revision) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
368 elif action == 'add': |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
369 frompath, fromrev = copies.get(path, (None, -1)) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
370 if frompath: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
371 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
|
372 fileeditor = editor.add_file(path, frompath, fromrev) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
373 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
|
374 editor.delete_entry(path, base_revision) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
375 continue |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
376 else: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
377 assert False, 'invalid action \'%s\'' % action |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
378 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
379 if path in props: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
380 if props[path].get('svn:special', None): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
381 new_text = 'link %s' % new_text |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
382 for p, v in props[path].iteritems(): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
383 fileeditor.change_prop(p, v) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
384 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
385 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
386 handler = fileeditor.apply_textdelta() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
387 delta.send_stream(cStringIO.StringIO(new_text), handler) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
388 fileeditor.close() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
389 |
175
2412800b1258
Support svn:externals changes via .hgsvnexternals updates
Patrick Mezard <pmezard@gmail.com>
parents:
172
diff
changeset
|
390 else: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
391 # visiting a directory |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
392 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
|
393 direditor = editor.add_directory(path) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
394 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
|
395 direditor = editor.delete_entry(path, base_revision) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
396 continue |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
397 else: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
398 direditor = editor.open_directory(path) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
399 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
400 if path in props: |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
401 for p, v in props[path].iteritems(): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
402 direditor.change_prop(p, v) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
403 |
730
efb87d5bb311
subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
718
diff
changeset
|
404 pathidx = visitdir(direditor, path, paths, pathidx) |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
405 direditor.close() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
406 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
407 return pathidx |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
408 |
906
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
409 try: |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
410 rooteditor = commiteditor.open_root() |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
411 visitdir(rooteditor, '', paths, 0) |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
412 rooteditor.close() |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
413 commiteditor.close() |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
414 except: |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
415 commiteditor.abort() |
757d6a862c83
subvertpy bindings: abort transaction if we can't finalize it
Augie Fackler <raf@durin42.com>
parents:
844
diff
changeset
|
416 raise |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
417 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
418 def get_replay(self, revision, editor, oldestrev=0): |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
419 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 try: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
421 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
|
422 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
|
423 # 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 'cannot satisfy replay requests.') |
2cc1342d4476
svnwrap: factor out a common module
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
668
diff
changeset
|
429 raise common.SubversionRepoCanNotReplay(msg) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
430 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
431 raise |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
432 |
649
2060e0ca8dd5
svnwrap: add get_revision(); a thing wrapper around ra.do_update()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
611
diff
changeset
|
433 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
|
434 ''' 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
|
435 reporter = self.remote.do_update(revision, '', True, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
436 AbstractEditor(editor)) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
437 reporter.set_path('', revision, True) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
438 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
|
439 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 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
|
441 deleted=True, ignore_type=False): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 """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
|
443 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
445 url = self.path2url(path) |
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
446 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
|
447 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 if other_rev is None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
449 other_rev = revision - 1 |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
450 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
451 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
|
452 no_diff_deleted=deleted, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
453 ignore_content_type=ignore_type) |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
454 error = errfile.read() |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
455 assert not error, error |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
456 |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
457 return outfile.read() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
458 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 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
|
460 """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
|
461 |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
462 "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
|
463 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
|
464 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
|
465 IOError. |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
466 """ |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
467 mode = '' |
66
a31968146f3c
svnwrap: Fix leakage of temp dirs by using try/finally blocks.
Augie Fackler <durin42@gmail.com>
parents:
63
diff
changeset
|
468 try: |
931
e1dbd9646d6a
svnwrap: use custom StringIO class in get_file()
Patrick Mezard <patrick@mezard.eu>
parents:
911
diff
changeset
|
469 out = common.SimpleStringIO() |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
470 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
|
471 data = out.getvalue() |
04c92c2c4501
SubversionRepo: work around ra.get_files() not releasing input buffer
Patrick Mezard <pmezard@gmail.com>
parents:
97
diff
changeset
|
472 out.close() |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
473 if isinstance(info, list): |
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
474 info = info[-1] |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
475 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
|
476 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
|
477 except SubversionException, e: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
478 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
|
479 # 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
|
480 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
|
481 raise |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
796
diff
changeset
|
482 if mode == 'l': |
97
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
483 linkprefix = "link " |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
484 if data.startswith(linkprefix): |
0d3a2a7cefa3
hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents:
92
diff
changeset
|
485 data = data[len(linkprefix):] |
76
6c62bd201785
SubversionRepo: make get_file() return the file mode
Patrick Mezard <pmezard@gmail.com>
parents:
75
diff
changeset
|
486 return data, mode |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
487 |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
488 def list_props(self, path, revision): |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
489 """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
|
490 specified path does not exist. |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
491 """ |
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
492 try: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
493 pl = self.client.proplist(self.path2url(path), revision, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
494 client.depth_empty) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
495 except SubversionException, e: |
172
84fbf1469a31
SubversionRepo: simplify and rename proplist() into list_prop()
Patrick Mezard <pmezard@gmail.com>
parents:
155
diff
changeset
|
496 # 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
|
497 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
|
498 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
|
499 raise |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
500 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
|
501 |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
502 def list_files(self, dirpath, revision): |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
503 """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
|
504 |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
505 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
|
506 '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
|
507 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
|
508 revision. |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
509 """ |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
510 try: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
511 entries = self.client.list(self.path2url(dirpath), revision, |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
512 client.depth_infinity, ra.DIRENT_KIND) |
667
e872f549e42f
svnwrap: s/core.SubversionException/SubversionException/
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
666
diff
changeset
|
513 except SubversionException, e: |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
514 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
|
515 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
|
516 '%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
|
517 raise |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
518 for path, e in entries.iteritems(): |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
519 if not path: continue |
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
520 kind = _svntypes.get(e['kind']) |
77
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
521 yield path, kind |
ed3dd5bf45da
fetch_command: bypass export3() and checkout manually
Patrick Mezard <pmezard@gmail.com>
parents:
76
diff
changeset
|
522 |
87
b033d74be76b
fetch_command: in stupid non-diffy mode, take changed paths in account
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
523 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
|
524 """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
|
525 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
|
526 """ |
676
2a9c009790ce
svnwrap: add subvertpy wrapper
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
675
diff
changeset
|
527 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
|
528 return _svntypes.get(kind) |
489
cd793ca555af
svnwrap: properly escape URLs before giving them to libsvn_*
Chema Cortes <pych3m4@gmail.com>
parents:
467
diff
changeset
|
529 |
491
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
530 def path2url(self, path): |
b71507d7becc
svn_swig_wrapper: minor code cleanup.
Augie Fackler <durin42@gmail.com>
parents:
489
diff
changeset
|
531 """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
|
532 """ |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
533 if not path or path == '.': |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
534 return self.svn_url |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
491
diff
changeset
|
535 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
|
536 return '/'.join((self.svn_url, urllib.quote(path).rstrip('/'),)) |