File: stg-dispatch

package info (click to toggle)
stgit 0.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,748 kB
  • sloc: python: 10,558; sh: 5,739; lisp: 2,678; makefile: 142; perl: 42
file content (44 lines) | stat: -rwxr-xr-x 1,039 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
set -e

# stg-dispatch - percollates files matching a pattern down to another patch.
# It does the same job as stg-fold-files-from (and makes use of it to
# do so), but from the patch containing the changes to migrate,
# instead of doing so from the target patch.

# usage: stg-dispatch [-n] <topatch> [-#<n>[-<n>][,<n>]...] <file-pattern>

# Copyright (c) 2007 Yann Dirson <ydirson@altern.org>
# Subject to the GNU GPL, version 2.

die()
{
    echo >&2 "$(basename $0) error: $*"
    exit 1
}

noact=0
if [ "x$1" = "x-n" ]; then
    noact=1
    shift
fi

TOPATCH="$1"
shift

stg series --applied --noprefix | grep "^$TOPATCH\$" >/dev/null ||
    die "cannot dispatch to unapplied patch '$TOPATCH'"

CURRENTPATCH=$(stg top)

[ "x$TOPATCH" != "x$CURRENTPATCH" ] ||
    die "dispatching to current patch ($CURRENTPATCH) makes no sense"

if [ $noact = 1 ]; then
    stg-fold-files-from "$CURRENTPATCH" -n "$@"
else
    stg goto "$TOPATCH"
    stg-fold-files-from "$CURRENTPATCH" "$@"
    stg refresh
    stg goto "$CURRENTPATCH"
fi