The Hackerlab at `regexps.com`

## Shared and Public Archives

up: arch Meets hello-world next: The update/commit Style of Cooperation prev: Retrieving Earlier Revisions

In the earlier chapters, you learned how to create your first archive, start a project, check in the initial sources and subsequent changes, and retrieve past revisions.

In this chapter you'll learn how to make an archive available over a network and begin to learn how multiple programmers can share a single archive.

### Registering for Network Access to Archives

As you should recall, an archive has both a logical name, and a physical location:

            % tla archives
            lord@emf.net--2003-example
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
              |     /usr/lord/{archives}/2003-example
              |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              |                     |
              |              archive location
              |
            archive name

(See Creating a New Archive.)

Some archives can be accessed over a network, currently via any of the protocols:

            FTP
            SFTP
            WebDAV
            plain HTTP

Later in this chapter, you'll learn how to create such archives.

For now, you should know that to access such an archive, you register it's name and physical location, using a URL for the physical location.

For example, to access an HTTP or WebDAV archive:

        % tla register-archive lord@emf.net--2003b \
                http://regexps.srparish.net/{archives}/lord@emf.net--2003b

or an FTP archive:

        % tla register-archive lord@regexps.com--2002 \
                ftp://ftp.regexps.com/{archives}/lord@regexps.com--2002

You can see that these commands have taken effect:

        % tla archives
        lord@emf.net--2003b
                http://regexps.srparish.net/{archives}/lord@emf.net--2003b
        lord@emf.net--2003-example
                /usr/lord/examples/{archives}/2003-example
        lord@regexps.com--2002
                ftp://ftp.regexps.com/{archives}/lord@regexps.com--2002

### Working with Several Archives at Once

After you've registered additional archives, how do you access them?

One trivial way is to make the archive you are interested in your default:

            % tla my-default-archive lord@emf.net--2003

            % tla categories
            [...categories in the remote archive...]

It can, of course, be inconvenient to keep changing your default archive. So for now, let's restore it to the archive we've been using in the examples:

            % tla my-default-archive lord@emf.net--2003-example

There are two other ways to access a remote archive:

#### Selecting an Archive with -A

Every command that operates on archives accepts a `-A` option which can be used to override the default:

            % tla my-default-archive
            lord@emf.net--2003-example

            % tla categories -A lord@emf.net--2003
            [... categories in lord@emf.net--2003 ...]

Usage Note: A `-A` argument takes precedence over your default archive but is overridden by fully qualified project names (see below).

#### Fully Qualified Project Names

Commands that accept project names allow you to use fully qualified project names . A fully qualified name is formed by prefixing an archive name, followed by a slash, to the project name:

       category name:
       tla                     => lord@emf.net--2003/tla

       branch name:
       tla--devo               => lord@emf.net--2003/arch--tla

       version name:
       tla--devo--1.0          => lord@emf.net--2003/tla--devo--1.0

       revision name:
       tla--devo--1.0--patch-1 => lord@emf.net--2003/tla--devo--1.0--patch-1

As in this example:

            % tla my-default-archive
            lord@emf.net--2003-example

            % tla branches lord@emf.net--2003/hello-world
            [... branches of hello-world in lord@emf.net--2003 ...]

Usage Note: A fully qualified name takes precedence over both `-A` arguments and your default archive.

### Read-only Archives

Operating system and server access controls can be used to limit some or all users to read-only access. For example, FTP is usually configured in such a way that anonymous users can read, but not modify the archive.

### Creating Local Mirrors, Remote Mirrors, and Remote Archives

A mirror is an archive whose contents are copied from another archive. You can not commit to a mirror in the ordinary way, you can only update it's copy of it's source.

There are two primary uses for mirror archives: one is to make a local copy of a remote mirror (so that it's contents can be accessed without going over a network); the other is to make a remote copy of a local archive (so that others can access that copy).

#### Mirroring a Remote Archive Locally

Let's suppose that, in order to have the fastest possible access to it, or to be able to use it while disconnected, you want to mirror a remote archive locally rather than accessing it over network.

Supposing that you wanted to do this with `lord@emf.net--2003b` , there are three steps (suppose $remote_location is something like http://my.site.com//archives/lord@emf.net--2003b).

First, register the remote archive under a pseudonum, formed by appending `-SOURCE` to it's name:

            % tla register-archive lord@emf.net--2003b-SOURCE $remote_location

Second, create your local mirror:

            % tla make-archive --mirror-from lord@emf.net--2003b-SOURCE $local_location

That command will, as a side effect, register `lord@emf.net--2003b` as the name of your local mirror.

Finally, copy data from the remote archive:

            % tla archive-mirror lord@emf.net--2003b

Whenever the remote archive has been added to, you can incrementally update your mirror by repeating the `tla archive-mirror` step.

If you don't want to mirror the entire archive, you can optionally limit the mirror to specific categories, branches, or versions. See tla archive-mirror -H for more.

#### Mirroring a Local Archive Remotely

Let's suppose that you have a local archive `mine@somewhere.com` , and you'd like to "publish" a mirror of that archive on the Internet so that other people can read from it.

Assuming that you already have `mine@somewhere.com` registered, you can create the remote mirror with:

            % tla make-archive --mirror mine@somewhere.com $remote_location

Arch will write directly to $remote_location, so it must be a writeable transport such as sftp, and not something such as standard http.

You can initialize or incrementally update the contents of the remote mirror with:

            % tla archive-mirror mine@somewhere.com

One common situation for many people is that they are able to install static files as part of a web site, but they can't provide WebDAV access to that web site. Even under those conditions you can still publish an arch archive, though there are two subtleties.

First, when running make-archive, you need to provide an extra flag:

            % tla make-archive --listing --mirror mine@somewhere.com \
                            $remote_location

The `--listing` flag causes arch to keep `.listing` files up-to-date in the mirror, and that, in turn, allows people to read from the archive using arch over vanilla HTTP (sans WebDAV support).

Second, it _is_ possible for the `.listing` files to fall out of date (for example, if you kill an `archive-mirror` command at just the right time_. If you know or suspect that has occurred, you can repair the archive in question by running archive-fixup as in this example:

            % tla archive-fixup mine@somewhere.com-MIRROR

#### Making a Remote Repository

Although mirroring is a common use of remote repositories, it is possible to create remote repositories which are not mirrors, and then to commit to those directly.

One can create a remote repository with a command such as:

            % tla make-archive $archive_name $remote_location

or, to create a remote repository with .listing files:

            % tla make-archive --listing $archive_name $remote_location

### Mixing Access Modes

There is nothing to prevent you from making a single archive available via multiple access methods. For example, you can register an FTP accessible archive using a local-filesystem location on the machine that contains the FTP directory, but ask other users to register it with an `ftp:` URL.

arch Meets hello-world: A Tutorial Introduction to The arch Revision Control System
The Hackerlab at `regexps.com`