Mercurial > hgsubversion
annotate hgsubversion/layouts/__init__.py @ 1275:ca771cbf69c6
layouts: use meta.infix in standard
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:20:51 -0500 |
parents | 4744b7bfa476 |
children | 14dab195b2b4 |
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 |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1024
diff
changeset
|
14 import custom |
1004
b2d89ba6b871
layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
15 import detect |
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", |
1004
b2d89ba6b871
layouts: pull out code for detecting layout from subversion
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
22 ] |
1012
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
23 |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
24 # 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
|
25 # 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
|
26 # 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
|
27 NAME_TO_CLASS = { |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
1024
diff
changeset
|
28 "custom": custom.CustomLayout, |
1012
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 |
1265
4744b7bfa476
layouts: change constructor to take a meta object
Sean Farley <sean.michael.farley@gmail.com>
parents:
1264
diff
changeset
|
34 def layout_from_name(name, meta): |
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: |
1265
4744b7bfa476
layouts: change constructor to take a meta object
Sean Farley <sean.michael.farley@gmail.com>
parents:
1264
diff
changeset
|
43 raise hgutil.Abort('Unknown hgsubversion layout: %s' % name) |
4744b7bfa476
layouts: change constructor to take a meta object
Sean Farley <sean.michael.farley@gmail.com>
parents:
1264
diff
changeset
|
44 return NAME_TO_CLASS[name](meta) |