Show More
@@ -1,6 +1,17 b'' | |||||
1 | # Subversion 1.4/1.5 Python API backend |
|
1 | # Subversion 1.4/1.5 Python API backend | |
2 | # |
|
2 | # | |
3 | # Copyright(C) 2007 Daniel Holth et al |
|
3 | # Copyright(C) 2007 Daniel Holth et al | |
|
4 | # | |||
|
5 | # Configuration options: | |||
|
6 | # | |||
|
7 | # convert.svn.trunk | |||
|
8 | # Relative path to the trunk (default: "trunk") | |||
|
9 | # convert.svn.branches | |||
|
10 | # Relative path to tree of branches (default: "branches") | |||
|
11 | # | |||
|
12 | # Set these in a hgrc, or on the command line as follows: | |||
|
13 | # | |||
|
14 | # hg convert --config convert.svn.trunk=wackoname [...] | |||
4 |
|
15 | |||
5 | import pprint |
|
16 | import pprint | |
6 | import locale |
|
17 | import locale | |
@@ -88,26 +99,47 b' class convert_svn(converter_source):' | |||||
88 | lastrevs[module] = revnum |
|
99 | lastrevs[module] = revnum | |
89 | self.lastrevs = lastrevs |
|
100 | self.lastrevs = lastrevs | |
90 |
|
101 | |||
|
102 | def exists(self, path, optrev): | |||
|
103 | try: | |||
|
104 | return svn.client.ls(self.url.rstrip('/') + '/' + path, | |||
|
105 | optrev, False, self.ctx) | |||
|
106 | except SubversionException, err: | |||
|
107 | return [] | |||
|
108 | ||||
91 | def getheads(self): |
|
109 | def getheads(self): | |
92 | # detect standard /branches, /tags, /trunk layout |
|
110 | # detect standard /branches, /tags, /trunk layout | |
93 | optrev = svn.core.svn_opt_revision_t() |
|
111 | optrev = svn.core.svn_opt_revision_t() | |
94 | optrev.kind = svn.core.svn_opt_revision_number |
|
112 | optrev.kind = svn.core.svn_opt_revision_number | |
95 | optrev.value.number = self.last_changed |
|
113 | optrev.value.number = self.last_changed | |
96 | rpath = self.url.strip('/') |
|
114 | rpath = self.url.strip('/') | |
97 | paths = svn.client.ls(rpath, optrev, False, self.ctx) |
|
115 | cfgtrunk = self.ui.config('convert', 'svn.trunk') | |
98 | if 'branches' in paths and 'trunk' in paths: |
|
116 | cfgbranches = self.ui.config('convert', 'svn.branches') | |
99 | self.module += '/trunk' |
|
117 | trunk = (cfgtrunk or 'trunk').strip('/') | |
|
118 | branches = (cfgbranches or 'branches').strip('/') | |||
|
119 | if self.exists(trunk, optrev) and self.exists(branches, optrev): | |||
|
120 | self.ui.note('found trunk at %r and branches at %r\n' % | |||
|
121 | (trunk, branches)) | |||
|
122 | oldmodule = self.module | |||
|
123 | self.module += '/' + trunk | |||
100 | lt = self.latest(self.module, self.last_changed) |
|
124 | lt = self.latest(self.module, self.last_changed) | |
101 | self.head = self.revid(lt) |
|
125 | self.head = self.revid(lt) | |
102 | self.heads = [self.head] |
|
126 | self.heads = [self.head] | |
103 |
branches = svn.client.ls(rpath + '/ |
|
127 | branchnames = svn.client.ls(rpath + '/' + branches, optrev, False, | |
104 | for branch in branches.keys(): |
|
128 | self.ctx) | |
105 | module = '/branches/' + branch |
|
129 | for branch in branchnames.keys(): | |
|
130 | if oldmodule: | |||
|
131 | module = '/' + oldmodule + '/' + branches + '/' + branch | |||
|
132 | else: | |||
|
133 | module = '/' + branches + '/' + branch | |||
106 | brevnum = self.latest(module, self.last_changed) |
|
134 | brevnum = self.latest(module, self.last_changed) | |
107 | brev = self.revid(brevnum, module) |
|
135 | brev = self.revid(brevnum, module) | |
108 | self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
|
136 | self.ui.note('found branch %s at %d\n' % (branch, brevnum)) | |
109 | self.heads.append(brev) |
|
137 | self.heads.append(brev) | |
|
138 | elif cfgtrunk or cfgbranches: | |||
|
139 | raise util.Abort(_('trunk/branch layout expected, ' | |||
|
140 | 'but not found')) | |||
110 | else: |
|
141 | else: | |
|
142 | self.ui.note('working with one branch\n') | |||
111 | self.heads = [self.head] |
|
143 | self.heads = [self.head] | |
112 | return self.heads |
|
144 | return self.heads | |
113 |
|
145 | |||
@@ -193,8 +225,8 b' class convert_svn(converter_source):' | |||||
193 | except SubversionException: |
|
225 | except SubversionException: | |
194 | dirent = None |
|
226 | dirent = None | |
195 | if not dirent: |
|
227 | if not dirent: | |
196 | raise util.Abort('%s not found up to revision %d' \ |
|
228 | print self.base, path | |
197 | % (path, stop)) |
|
229 | raise util.Abort('%s not found up to revision %d' % (path, stop)) | |
198 |
|
230 | |||
199 | return dirent.created_rev |
|
231 | return dirent.created_rev | |
200 |
|
232 |
General Comments 0
You need to be logged in to leave comments.
Login now