annotate hgsubversion/layouts/__init__.py @ 1024:8feff33e387d

layouts: make ui object available to layout instances
author David Schleimer <dschleimer@fb.com>
date Tue, 21 May 2013 15:49:07 -0700
parents e8cd211684c4
children cd0d14e25757
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1004
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
1 """Code for dealing with subversion layouts
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
2
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
3 This package is intended to encapsulate everything about subversion
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
4 layouts. This includes detecting the layout based on looking at
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
5 subversion, mapping subversion paths to hg branches, and doing any
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
6 other path translation necessary.
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
7
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
8 NB: this has a long way to go before it does everything it claims to
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
9
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
10 """
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
11
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
12 from mercurial import util as hgutil
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
13
1004
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
14 import detect
1006
7a3b938825cd layouts: refactor layout loading and persisting out of svnmeta.py
David Schleimer <dschleimer@fb.com>
parents: 1004
diff changeset
15 import persist
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
16 import single
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
17 import standard
1004
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
18
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
19 __all__ = [
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
20 "detect",
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
21 "layout_from_name",
1006
7a3b938825cd layouts: refactor layout loading and persisting out of svnmeta.py
David Schleimer <dschleimer@fb.com>
parents: 1004
diff changeset
22 "persist",
1004
b2d89ba6b871 layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff changeset
23 ]
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
24
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
25 # This is the authoritative store of what layouts are available.
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
26 # The intention is for extension authors who wish to build their own
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
27 # layout to add it to this dict.
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
28 NAME_TO_CLASS = {
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
29 "single": single.SingleLayout,
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
30 "standard": standard.StandardLayout,
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
31 }
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
32
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
33
1024
8feff33e387d layouts: make ui object available to layout instances
David Schleimer <dschleimer@fb.com>
parents: 1012
diff changeset
34 def layout_from_name(name, ui):
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
35 """Returns a layout module given the layout name
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
36
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
37 You should use one of the layout.detect.* functions to get the
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
38 name to pass to this function.
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
39
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
40 """
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
41
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
42 if name not in NAME_TO_CLASS:
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
43 raise hgutil.Abort('Unknown hgsubversion layout: %s' %name)
1024
8feff33e387d layouts: make ui object available to layout instances
David Schleimer <dschleimer@fb.com>
parents: 1012
diff changeset
44 return NAME_TO_CLASS[name](ui)