9492.1.1
by Karl Fogel
Add utilities/formatdoctest.py and utilities/migrater/, both brought |
1 |
Launchpad Migrater |
2 |
===================
|
|
3 |
||
4 |
This tool moves modules, tests, and configuration from the |
|
5 |
canonical.launchpad tree to the lp tree. The tool uses a configuration |
|
6 |
file that maps files to applications. |
|
7 |
||
8 |
This script does most of the migration work, but it is not intended to do a |
|
9 |
complete migration. The goal of the script is to automate most of the |
|
10 |
mechanical work so that a developer can make the needed manual changes to |
|
11 |
land the branch in 2 days. |
|
12 |
||
13 |
It performs a number of updates for the migration and when a file is moved. |
|
14 |
||
15 |
* Builds a tree with the new directory names. Such as |
|
16 |
database => model |
|
17 |
pagetests => stories |
|
18 |
* Some files are renamed, such as tests that end in '-pages' will be |
|
19 |
named as '-views'. |
|
20 |
* Update imports of the moved module in other modules, tests and zcml. |
|
21 |
* Convert the interface glob imports in the moved module to |
|
22 |
specific imports. |
|
23 |
* Extract all browser zcml instructions to browser/configure.zcml |
|
24 |
* Merge all object zcml into <app>/configure.zcml |
|
25 |
||
26 |
test harnesses are installed to run the tests in doc/ and browser/test |
|
27 |
The test_doc.py module is constructed from functions and configuration in |
|
28 |
canonical/launchpad/ftests/test_system_documentation.py. |
|
29 |
||
30 |
||
31 |
What is missing? |
|
32 |
----------------
|
|
33 |
||
34 |
The tool does not know how to separate the modules, tests and zcml into |
|
35 |
app/ and coop/ directories. You can either add these rules, or do it by hand. |
|
36 |
The registry app has a lot coop/ code in its model and browser modules, though |
|
37 |
it should not have a coop/ directory. The separation of application from |
|
38 |
the pillar models and views must be done after the migration has run, and |
|
39 |
probably in a separate branch. |
|
40 |
||
41 |
||
42 |
Using migrater.py to extract an application |
|
43 |
-------------------------------------------
|
|
44 |
||
45 |
The migration script will probably be run many times over a pristine |
|
46 |
launchpad branch. Each pass you will strive to reconcile warnings, and |
|
47 |
add rules to migrate unhandled files. |
|
48 |
||
49 |
* Update file-ownership.txt |
|
50 |
* Add missing files. |
|
51 |
* Page templates do not need to be marked; their migration list is |
|
52 |
built from the moved zcml and browser modules. |
|
53 |
* Prefix the application code to each file that you want to migrate. |
|
54 |
eg. reg canonical/launchpad/database/distribution.py |
|
55 |
||
56 |
* Run the script (takes about 5 minutes) |
|
57 |
cd pristine-launchpad-branch |
|
58 |
../migrater/migrate.py ../migrater/file-ownership.txt <code|reg|soy> |
|
59 |
||
60 |
* Review the script's output |
|
61 |
* Update file-ownership.txt to reconcile modules that the zcml |
|
62 |
configuration indicates are missing. |
|
63 |
* Examine the templates that are shared by multiple files. Are these |
|
64 |
templates are from a module or zcml that should also be be migrated? |
|
65 |
You may choose to add an exception to migrations rules, or update the |
|
66 |
zcml and module to share a template. |
|
67 |
* Consider the files that were not moved. Do you want to add rules |
|
68 |
to the migration script to handle them? |
|
69 |
||
70 |
* Run lint over lib/lp/<app>/tests/test_doc,py and |
|
71 |
lib/lp/<app>/tests/browser/test_views.py. |
|
72 |
* Update the imports in the migrater/ test_doc.py and test_views.py files |
|
73 |
because you may run the script many times, and you will want to test |
|
74 |
often without the need to make repeated fixes to the test harnesses. |
|
75 |
||
76 |
* Test |
|
77 |
test.py -vv -module=lp.<app> |
|
78 |
* You will probably see circular import issues until the warnings from the |
|
79 |
migration script are resolved. If the problem persists, you may choose |
|
80 |
to make this a manual migration task, or postpone migration of the |
|
81 |
problem module. |
|
82 |
* Examine the failures. Consider making changes to the failing code and |
|
83 |
tests in a tree /before/ the migration script makes its changes. |
|
84 |
||
85 |
* Revert the migration changes. |
|
86 |
* Update code, test, and zcml to work to be compatible with the old and |
|
87 |
new tree. Commit. |
|
88 |
* Update the migration script to handle exceptional moves and unsupported |
|
89 |
files. Commit. |
|
90 |
||
91 |
* Repeat until you believe the remaining migration work can be done my hand |
|
92 |
in a short time. |