Mercurial > hgsubversion
annotate hgsubversion/layouts/__init__.py @ 1012:e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
This pulls the logic for mapping from svn path to mercurial branch
name out of svnmeta.py and into the new layouts library. It also sets
up the structure for that library. This diff does not modify any call
to svnmeta.localname, rather leaving it in place as a simple proxy to
the new layout object.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Wed, 24 Apr 2013 15:07:11 -0700 |
parents | 7a3b938825cd |
children | 8feff33e387d |
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 |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
34 def layout_from_name(name): |
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) |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
44 return NAME_TO_CLASS[name]() |