1. Graham Helliwell
  2. guestrepo

Source

guestrepo / tests / test-pull-and-update.t

The default branch has multiple heads

# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# 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

Pull and sync perform the same action on nonexistant repos.

This file tests that repos are cloned correctly

  $ TESTDIR=`pwd`

Make a guest repo:
  $ mkdir gr1
  $ cd gr1
  $ hg init
  $ echo c0 > f
  $ hg add f
  $ hg commit -m 0
  $ cd ..

Make host:
  $ mkdir host
  $ cd host
  $ hg init
  $ echo mygr1 = mygr1-name default >> .hgguestrepo
  $ echo mygr1-name = `readlink -f -n ../gr1` >> .hggrmapping
  $ hg add .hgguestrepo .hggrmapping
  $ hg commit -m 0

Test Pull with clone:
  $ hg grpull
  cloning mygr1
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Check that guest repo exists and was updated
  $ hg id -n -R $TESTDIR/host/mygr1
  0
  $ rm -rf $TESTDIR/host/mygr1

Test sync with clone:
  $ hg grupdate
  cloning mygr1
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

Check that guest repo exists and was updated
  $ hg id -n -R $TESTDIR/host/mygr1
  0
  $ rm -rf $TESTDIR/host/mygr1

Remove guest repo and change a deeper directory
  $ cd $TESTDIR/host
  $ rm -rf ./mygr1
  $ echo many/dirs/deep/mygr1 = mygr1-name default > .hgguestrepo
  $ hg commit -m 1

Run same cloning pull as last time:
  $ hg grpull
  cloning many/dirs/deep/mygr1
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd many/dirs/deep/mygr1
  $ hg id -n
  0

clean up:
  $ cd $TESTDIR/host
  $ rm -rf many

Run cloning sync
  $ hg grupdate
  cloning many/dirs/deep/mygr1
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd many/dirs/deep/mygr1
  $ hg id -n
  0

clean up
  $ cd $TESTDIR/host
  $ rm -rf many

Add another branch to the guest repo so we can test pull/cloning to a branch
  $ cd $TESTDIR/gr1
  $ hg branch b1 2>&1 | grep -v "did you want a bookmark"
  marked working directory as branch b1
  $ echo c1 > f
  $ hg commit -m c1

Add another commit to default to be sure we are selecting the branch
  $ hg up default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo c2 > f
  $ hg commit -m c2

Pull and clone to a specific branch
  $ cd $TESTDIR/host
  $ echo mygr1 = mygr1-name b1 > .hgguestrepo
  $ hg commit -m 2
  $ hg grpull
  cloning mygr1
  updating to branch b1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cat mygr1/f
  c1
  $ hg branch -R ./mygr1
  b1

Sync clone to specific branch
  $ rm -rf ./mygr1
  $ hg grupdate
  cloning mygr1
  updating to branch b1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cat mygr1/f
  c1
  $ hg branch -R ./mygr1
  b1