Skip to content

Commit 29cdb03

Browse files
authored
Merge pull request #9701 from cabalism/doc/compare-source-repos-9665
source-repository versus source-repository-package
2 parents 214acd8 + d5dfd6e commit 29cdb03

6 files changed

+512
-72
lines changed

doc/cabal-commands.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ e.g. you plan to work on a project with unreliable or no internet access.
457457

458458
Check ``cabal fetch --help`` for a complete list of options.
459459

460+
.. _cabal-get:
461+
460462
cabal get
461463
^^^^^^^^^
462464

@@ -1399,6 +1401,7 @@ A list of all warnings with their constructor:
13991401
- ``no-docs``: missing expected documentation files (changelog).
14001402
- ``doc-place``: documentation files listed in ``extra-source-files`` instead of ``extra-doc-files``.
14011403

1404+
.. _cabal-sdist:
14021405

14031406
cabal sdist
14041407
^^^^^^^^^^^

doc/cabal-package-description-file.rst

Lines changed: 37 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,43 +2676,32 @@ Starting with Cabal-2.2 it's possible to use common build info stanzas.
26762676

26772677
TBW
26782678

2679-
Source Repositories
2680-
^^^^^^^^^^^^^^^^^^^
2679+
2680+
.. _pkg-author-source:
2681+
2682+
*Source code* repository marker
2683+
-------------------------------
26812684

26822685
.. pkg-section:: source-repository
26832686
:since: 1.6
26842687

2685-
It is often useful to be able to specify a source revision control
2686-
repository for a package. Cabal lets you specify this information in
2687-
a relatively structured form which enables other tools to interpret and
2688-
make effective use of the information. For example the information
2689-
should be sufficient for an automatic tool to checkout the sources.
2690-
2691-
Cabal supports specifying different information for various common
2692-
source control systems. Obviously not all automated tools will support
2693-
all source control systems.
2688+
A marker that points to the *source code* for this package within a
2689+
**source code repository**.
26942690

2695-
Cabal supports specifying repositories for different use cases. By
2696-
declaring which case we mean automated tools can be more useful. There
2697-
are currently two kinds defined:
2691+
There are two kinds. You can specify one or the other or both at once:
26982692

26992693
- The ``head`` kind refers to the latest development branch of the
27002694
package. This may be used for example to track activity of a project
27012695
or as an indication to outside developers what sources to get for
27022696
making new contributions.
27032697

27042698
- The ``this`` kind refers to the branch and tag of a repository that
2705-
contains the sources for this version or release of a package. For
2706-
most source control systems this involves specifying a tag, id or
2707-
hash of some form and perhaps a branch. The purpose is to be able to
2708-
reconstruct the sources corresponding to a particular package
2709-
version. This might be used to indicate what sources to get if
2710-
someone needs to fix a bug in an older branch that is no longer an
2711-
active head branch.
2712-
2713-
You can specify one kind or the other or both. As an example here are
2714-
the repositories for the Cabal library. Note that the ``this`` kind of
2715-
repository specifies a tag.
2699+
contains the sources for this version or release of a package. For most
2700+
source control systems this involves specifying a tag, id or hash of some
2701+
form and perhaps a branch.
2702+
2703+
As an example, here are the repositories for the Cabal library. Note that the
2704+
``this`` kind of repository specifies a tag.
27162705

27172706
::
27182707

@@ -2725,32 +2714,29 @@ repository specifies a tag.
27252714
location: https://github.com/haskell/cabal
27262715
tag: 1.6.1
27272716

2728-
The exact fields are as follows:
2729-
2730-
.. pkg-field:: type: token
2717+
The :ref:`cabal get<cabal-get>` command uses the kind of repository with
2718+
its ``--source-repository`` option, if provided.
27312719

2732-
The name of the source control system used for this repository. The
2733-
currently recognised types are:
2720+
.. _source-repository-fields:
27342721

2735-
- ``darcs``
2736-
- ``git``
2737-
- ``svn``
2738-
- ``cvs``
2739-
- ``mercurial`` (or alias ``hg``)
2740-
- ``bazaar`` (or alias ``bzr``)
2741-
- ``arch``
2742-
- ``monotone``
2722+
The :ref:`VCS fields<vcs-fields>` of ``source-repository`` are:
27432723

2744-
This field is required.
2724+
..
2725+
data SourceRepo = SourceRepo
2726+
{ repoKind :: RepoKind
2727+
, repoType :: Maybe RepoType
2728+
, repoLocation :: Maybe String
2729+
, repoModule :: Maybe String
2730+
, repoBranch :: Maybe String
2731+
, repoTag :: Maybe String
2732+
, repoSubdir :: Maybe FilePath
2733+
}
27452734
2746-
.. pkg-field:: location: URL
2735+
.. pkg-field:: type: VCS kind
27472736

2748-
The location of the repository. The exact form of this field depends
2749-
on the repository type. For example:
2737+
This field is required.
27502738

2751-
- for darcs: ``http://code.haskell.org/foo/``
2752-
- for git: ``git://github.com/foo/bar.git``
2753-
- for CVS: ``[email protected]:/cvs``
2739+
.. pkg-field:: location: VCS location
27542740

27552741
This field is required.
27562742

@@ -2762,35 +2748,20 @@ The exact fields are as follows:
27622748
This field is required for the CVS repository type and should not be
27632749
used otherwise.
27642750

2765-
.. pkg-field:: branch: token
2766-
2767-
Many source control systems support the notion of a branch, as a
2768-
distinct concept from having repositories in separate locations. For
2769-
example CVS, SVN and git use branches while darcs uses different
2770-
locations for different branches. If you need to specify a branch to
2771-
identify a your repository then specify it in this field.
2751+
.. pkg-field:: branch: VCS branch
27722752

27732753
This field is optional.
27742754

2775-
.. pkg-field:: tag: token
2776-
2777-
A tag identifies a particular state of a source repository. The tag
2778-
can be used with a ``this`` repository kind to identify the state of
2779-
a repository corresponding to a particular package version or
2780-
release. The exact form of the tag depends on the repository type.
2755+
.. pkg-field:: tag: VCS tag
27812756

27822757
This field is required for the ``this`` repository kind.
27832758

2784-
.. pkg-field:: subdir: directory
2759+
This might be used to indicate what sources to get if someone needs to fix a
2760+
bug in an older branch that is no longer an active head branch.
27852761

2786-
Some projects put the sources for multiple packages under a single
2787-
source repository. This field lets you specify the relative path
2788-
from the root of the repository to the top directory for the
2789-
package, i.e. the directory containing the package's ``.cabal``
2790-
file.
2762+
.. pkg-field:: subdir: VCS subdirectory
27912763

2792-
This field is optional. It defaults to empty which corresponds to the
2793-
root directory of the repository.
2764+
This field is optional but, if given, specifies a single subdirectory.
27942765

27952766

27962767
.. _setup-hooks:

doc/cabal-project-description-file.rst

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ Formally, the format is described by the following BNF:
205205
| "{" Glob "," ... "," Glob "}" # union (match any of these)
206206
207207
208-
Specifying Packages from Remote Version Control Locations
209-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
208+
.. _pkg-consume-source:
209+
210+
Taking a dependency from a *source code* repository
211+
---------------------------------------------------
210212

211213
Since version 2.4, the ``source-repository-package`` stanza allows for
212214
specifying packages in a remote version control system that cabal should
@@ -238,18 +240,43 @@ Hackage.
238240
Since version 3.4, cabal-install creates tarballs for each package coming
239241
from a ``source-repository-package`` stanza (effectively applying cabal
240242
sdists to such packages). It gathers the names of the packages from the
241-
appropriate .cabal file in the version control repository, and allows
243+
appropriate ``.cabal`` file in the version control repository, and allows
242244
their use just like Hackage or locally defined packages.
243245

246+
.. _source-repository-package-fields:
247+
248+
The :ref:`VCS fields<vcs-fields>` of ``source-repository-package`` are:
249+
250+
..
251+
data SourceRepositoryPackage f = SourceRepositoryPackage
252+
{ srpType :: !RepoType
253+
, srpLocation :: !String
254+
, srpTag :: !(Maybe String)
255+
, srpBranch :: !(Maybe String)
256+
, srpSubdir :: !(f FilePath)
257+
, srpCommand :: ![String]
258+
}
259+
244260
.. cfg-field:: type: VCS kind
245261

246-
.. cfg-field:: location: VCS location (usually URL)
262+
This field is required.
263+
264+
.. cfg-field:: location: VCS location
265+
266+
This field is required.
267+
268+
.. cfg-field:: branch: VCS branch
269+
270+
This field is optional.
247271

248272
.. cfg-field:: tag: VCS tag
249273

250-
.. cfg-field:: subdir: subdirectory list
274+
This field is optional.
275+
276+
.. cfg-field:: subdir: VCS subdirectory list
251277

252-
Look in one or more subdirectories of the repository for cabal files, rather than the root.
278+
Look in one or more subdirectories of the repository for cabal files, rather
279+
than the root. This field is optional.
253280

254281
.. cfg-field:: post-checkout-command: command
255282

0 commit comments

Comments
 (0)