# HG changeset patch # User Sean Farley # Date 1395678054 18000 # Node ID 8b3b456afd5ff823b7dcbb18acc965146be79296 # Parent 4ba1481484e6c8112e02330278d592e4d3f65829 svnmeta: copy layout_from_subversion from detect diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -12,6 +12,7 @@ import util import maps import layouts import editor +import svnwrap class SVNMeta(object): @@ -144,6 +145,31 @@ class SVNMeta(object): filename)) setattr(SVNMeta, name, prop) + def layout_from_subversion(self, svn, revision=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 + cloning. + + Additionally, this will write the layout in use to the ui object + passed, if any. + + """ + + try: + rootlist = svn.list_dir('', revision=revision) + except svnwrap.SubversionException, e: + err = "%s (subversion error: %d)" % (e.args[0], e.args[1]) + raise hgutil.Abort(err) + if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))): + layout = 'standard' + else: + layout = 'single' + self.ui.setconfig('hgsubversion', 'layout', layout) + return layout + def layout_from_commit(self, subdir, revpath, branch): """ Guess what the layout is based existing commit info