+""" Layout detection for subversion repos.
+Figure out what layout we should be using, based on config, command
+line flags, subversion contents, and anything else we decide to base
+from mercurial import util as hgutil
+def layout_from_subversion(svn, revision=None, ui=None):
+ """ Guess what layout to use based on directories under the svn root.
+ This is intended for use during bootstrapping. It guesses which
+ layout to use based on the presence or absence of the conventional
+ trunk, branches, tags dirs immediately under the path your are
+ Additionally, this will write the layout in use to the ui object
+ rootlist = svn.list_dir('', revision=revision)
+ except svnwrap.SubversionException, e:
+ err = "%s (subversion error: %d)" % (e.args, e.args)
+ raise hgutil.Abort(err)
+ if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))):
+ ui.setconfig('hgsubversion', 'layout', layout)