annotate README.txt @ 56:6ebd2d10fc03 default tip

stub embedding fetch
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 02 Dec 2011 17:41:12 -0800
parents 2dfdff7549b2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 fetch
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
2 =====
0
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 fetch stuff from the interwebs
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
6 `fetch.py <http://k0s.org/mozilla/hg/fetch/raw-file/tip/fetch.py>`_ is
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
7 a single-file python module bundled as a
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
8 `package <http://k0s.org/mozilla/hg/fetch/>`_ for easy installation
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
9 and python importing. The purpose of fetch is to mirror remote
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
10 resources (URLs) to a local filesystem in order to synchronize and
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
11 update dependencies that are desired to be mirrored in this way.
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
12
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
13
0
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 Format
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 ------
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
17 ``fetch`` fetches from a manifest of the format::
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
18
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
19 [URL] [Destination] [Type]
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
21 A URL can contain a hash tag (e.g. http://example.com/foo#bar/fleem)
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
22 which is used to extract the subdirectories from a multi-directory
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
23 resource.
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
24
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
25 The ``Type`` of the resource is used to dispatch to the included
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
26 Fetchers that take care of fetching the object.
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
27
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
28 Manifests are used so that a number of resources may be fetched from a
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
29 particular ``fetch`` run.
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
30
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
31
55
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
32 Example
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
33 -------
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
34
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
35 After you checkout the `repository <http://k0s.org/mozilla/hg/fetch>`_
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
36 and run ``python setup.py develop``, you should be able to run
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
37 ``fetch`` on the example manifest::
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
38
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
39 fetch example.txt
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
40
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
41 This will create a ``tmp`` directory relative to the manifest and pull
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
42 down several resources to it.
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
43
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
44
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
45 Fetchers
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
46 --------
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
47
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
48 ``fetch`` includes several objects for fetching resources::
13
3fee8ecd1af8 restructure while we still just have one module
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
49
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
50 file : fetch a single file
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
51 tar : fetch and extract a tarball
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
52 hg : checkout a mercurial repository
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
53 git : checkout a git repository
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
54
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
55 The ``file`` fetcher cannot have a hash tag subpath since it is a single
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
56 resource.
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
57
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
58 Though ``fetch`` has a set of fetchers included, you can pass an
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
59 arbitrary list into ``fetch.Fetch``'s constructor.
20
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
60
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
61
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
62 Version Control
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
63 ---------------
738d84b4de52 start documenting
Jeff Hammel <jhammel@mozilla.com>
parents: 13
diff changeset
64
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
65 The ``hg`` and the ``git`` fetchers fetch from version control systems and
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
66 have additional options. The only current option to the constructor
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
67 is ``export``, which is by default True. If ``export`` is True, then
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
68 the repository will be exported into a non-versioned structure. If a
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
69 subpath is specified with a ``#`` in the URL, the repository will also
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
70 be exported.
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
71
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
72
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
73 TODO
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
74 ----
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
75
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
76 * use `manifestparser <https://github.com/mozilla/mozbase/blob/master/manifestdestiny/manifestparser.py>`_
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
77 ``.ini`` files versus another manifest
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
78 format: when I started work on ``fetch``, I thought a
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
79 domain-specific manifest would be a big win. But, now, maybe a
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
80 ``.ini`` type manifest looks about the same, and is something that
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
81 is already used. The switch internally wouldn't be that bad, but
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
82 if ``fetch.py`` is used as a single file, it cannot have
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
83 "traditional" python dependencies. Since ``manifestparser.py`` is
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
84 also a single file, and ``fetch`` is only usable with internet
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
85 access anyway, maybe the
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
86 `require <http://k0s.org/hg/config/file/tip/python/require.py>`_
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
87 pattern could be used for this purpose
0
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
88
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
89 * clobber: generally, you will want the existing resource to be
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
90 clobbered, avoiding renames regarding upstream dependencies
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
91
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
92 * outputting only subpaths: often, you will not to fetch from the
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
93 whole manifest, only from certain subpaths of the manifest. You
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
94 should be able to output a subset of what is to be mirrored based
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
95 on destination subpaths. The CLI option ``--dest`` is intended for
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
96 this purpose but currently unused.
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
97
55
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
98 * fetcher options: currently ``read_manifests`` reads an unused
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
99 column into ``options`` when present in the form of a string like
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
100 ``foo=one,bar=two`` into a dict like
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
101 ``{'foo': 'one', 'bar': 'two'}``. This hasn't been needed yet and
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
102 is unused. If we want to have resource-specific options, we should
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
103 use this and make it work. Otherwise it can be deleted.
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
104
55
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
105 * python package fetcher: often you will want to fetch a python
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
106 package as a resource. This would essentially fetch the object
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
107 (using another fetcher) and take the (untarred) result of
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
108 ``python setup.py sdist`` as a resource. This will strip out files
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
109 that aren't part of the python package. Unknowns include how to
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
110 specify the sub-fetcher. You could also include other
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
111 domain-specific fetchers as needed.
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
112
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
113 * note python 2.5+ specifics: ``fetch`` currently uses at least
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
114 ``os.path.relpath`` from python 2.5 and perhaps other 2.5+isms as
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
115 well. These should at least be documented and checked for if not
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
116 obviated. One such reimplementation is at
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
117 https://github.com/mozilla/mozbase/blob/master/manifestdestiny/manifestparser.py#L66
2dfdff7549b2 note how example works
Jeff Hammel <jhammel@mozilla.com>
parents: 53
diff changeset
118
53
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
119
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
120 Unsolved Problems
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
121 -----------------
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
122
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
123 A common story for ``fetch`` is mirroring files into a VCS repository
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
124 because the remote resources are needed as part of the repository and
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
125 there is no better way to retrieve and/or update them. However, what
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
126 do you do if these remote resources are altered? In an ideal
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
127 ecosystem, the fixes would be automatically triaged and triggered for
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
128 upstream inclusion, or the diffs from the upstream are kept in local
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
129 modifications (although vendor branches, etc, are more suitable for
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
130 the latter class of problems, and in general discouraged when a less
81fe0523a078 documentation
Jeff Hammel <jhammel@mozilla.com>
parents: 20
diff changeset
131 intrusive system of consuming upstream dependencies are available).
0
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
132
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
133 ----
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
134
3497a30190d2 initial commit of fetch, WIP
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
135 Jeff Hammel
13
3fee8ecd1af8 restructure while we still just have one module
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
136 http://k0s.org/mozilla/hg/fetch