1. Graham Helliwell
  2. guestrepo


guestrepo / guestrepo / __init__.py

# Guestrepo: A Mercurial Extension for the managing of components
# Copyright (C) 2012   Schweitzer Engineering Laboratories, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Contact information:

# opensource@selinc.com

# Schweitzer Engineering Laboratories, Inc.
# 2350 NE Hopkins Court
# Pullman, WA 99163 - USA

'''handle modules and components

    Commands for managing nested repositories


    Guest repositories are administered using the two files .hggrmapping and
    .hgguestrepo. These files are in the INI format used by Mercurial.

    Remote Paths

    Each guest repository must have a remote path defined in the .hggrmapping
    file to successfully push or pull.
    Remote paths are referenced by assigning a each path a unique name.
    The .hggrmapping file lists remote paths in the following INI format:

       name = remote-path

    If a remote repository is moved, the path referenced by a name can be
    updated to point to the new location.

    Example .hggrmapping file:

      remoteid  = http://host/path/to/repo

      remoteid2 = /path/to/repo2

    The .hggrmapping file used for any operation is the .hggrmapping file at
    the most recently committed head of the current branch.
    Using the most recent revision of the .hggrmapping file keeps the guests of
    previous revisions pointed to the correct location.

    The `--local` flag causes the .hggrmapping file in the working directory
    to be used.

    Guest Repository Listing

    The .hgguestrepo file defines guests by specifying three things:

    :location:      The location of the guest relative to the root of the parent
    :remote id:     The name of a remote path defined in the .hggrmapping file.
    :changeset id:  A Mercurial identifier e.g., a tag, bookmark, changeset
                    hash, branch, or other future identifier resolvable to a
                    single changeset.

    The .hgguestrepo file lists guest repositories in the following INI format:

      location = remote-id changeset-id

    Example .hgguestrepo file:

      path/to/guest = remoteid csid

      path/to/other/guest = remoteid2 csid

    If the the directory of the guest repository exists, it must contain a
    mercurial repository.

from guestrepo import grpull, grpush, grupdate, freeze, summary, state, grout, grin

import convert
import lockedui

# reused options
# option format: (short option, option name, default value, description)
localopt = [('l', 'local', False,
           "use the .hggrmapping file in the working directory")]

pullopt = [('p', 'pull', False,
           "perform a grpull before the grupdate")]

updateopt = [('u', 'update', False,
           "perform a grupdate after the grpull")]

forcepartialopt = [('f', 'forcepartial', False,
           "force a partial update by silently ignoring disallowed paths")]

threadopt = [('j', 'threads', 1,
          'number of threads to use. '
          'WARNING: ssh prompts are broken, and username and password prompts '
          'may become unordered '
          'when more than one thread is used', 'THREADS')]

silentnoop = [('s', 'silentnoop', False,
           "consider the operation a success if no guest repository config exists")]

# Command table for the guestrepo extension
# See the readme for a description of each command
# format: {"command-name": (function, options-list, help-string)}
cmdtable = {
   "grpull": (grpull,
              localopt + threadopt + updateopt + forcepartialopt + silentnoop,
              "hg grpull [REPO [+]] [options]"),
   "grpush": (grpush,
              localopt + threadopt + forcepartialopt + silentnoop,
              "hg grpush [REPO [+]] [options]"),
   "grupdate": (grupdate,
              localopt + threadopt + pullopt + forcepartialopt + silentnoop,
              "hg grupdate [REPO [+]] [options]"),
   "grfreeze": (freeze,
              "hg grfreeze"),
   "grsummary": (summary,
              [("i", "id", False,
                "Print the short changeset id")],
              "hg grsummary"),
   "grstate": (state,
              "hg grstate"),
   "grout" : (grout,
              "hg grout"),
   "grin" : (grin,
              "hg grin"),
   "grconvert": (convert.convert,
         [('b', 'branch', False,
           "write the current branch of each subrepo instead of the changeset")
         "hg grconvert [--branch]")