comparison hgsubversion/svnmeta.py @ 1299:8b3b456afd5f

svnmeta: copy layout_from_subversion from detect
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 24 Mar 2014 11:20:54 -0500
parents 4ba1481484e6
children 9e46dfddd3a9
comparison
equal deleted inserted replaced
1298:4ba1481484e6 1299:8b3b456afd5f
10 import compathacks 10 import compathacks
11 import util 11 import util
12 import maps 12 import maps
13 import layouts 13 import layouts
14 import editor 14 import editor
15 import svnwrap
15 16
16 17
17 class SVNMeta(object): 18 class SVNMeta(object):
18 19
19 def __init__(self, repo, uuid=None, subdir=None, skiperrorcheck=False): 20 def __init__(self, repo, uuid=None, subdir=None, skiperrorcheck=False):
141 pre=pre), 142 pre=pre),
142 lambda x, y: self._set_cachedconfig(y, 143 lambda x, y: self._set_cachedconfig(y,
143 name, 144 name,
144 filename)) 145 filename))
145 setattr(SVNMeta, name, prop) 146 setattr(SVNMeta, name, prop)
147
148 def layout_from_subversion(self, svn, revision=None):
149 """ Guess what layout to use based on directories under the svn root.
150
151 This is intended for use during bootstrapping. It guesses which
152 layout to use based on the presence or absence of the conventional
153 trunk, branches, tags dirs immediately under the path your are
154 cloning.
155
156 Additionally, this will write the layout in use to the ui object
157 passed, if any.
158
159 """
160
161 try:
162 rootlist = svn.list_dir('', revision=revision)
163 except svnwrap.SubversionException, e:
164 err = "%s (subversion error: %d)" % (e.args[0], e.args[1])
165 raise hgutil.Abort(err)
166 if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))):
167 layout = 'standard'
168 else:
169 layout = 'single'
170 self.ui.setconfig('hgsubversion', 'layout', layout)
171 return layout
146 172
147 def layout_from_commit(self, subdir, revpath, branch): 173 def layout_from_commit(self, subdir, revpath, branch):
148 """ Guess what the layout is based existing commit info 174 """ Guess what the layout is based existing commit info
149 175
150 Specifically, this compares the subdir for the repository and the 176 Specifically, this compares the subdir for the repository and the