~launchpad-pqm/launchpad/devel

11636.1.1 by Henning Eggers
Extracted find-changed-files.
1
#!/bin/bash
2
#
11636.1.4 by Henning Eggers
Hm, yummy dogfood\!
3
# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
11636.1.1 by Henning Eggers
Extracted find-changed-files.
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
#
6
# Determine the changed files in Bazaar piplines, looms and plain branches.
7
8
bzr() {
9
    # PYTHONPATH may point to the ./lib directory in the launchpad tree. This
10
    # directory includes a bzrlib. When this script calls bzr, we want it to
11
    # use the system bzrlib, not the one in the launchpad tree.
12
    PYTHONPATH='' `which bzr` "$@"
13
}
14
15
bzr diff > /dev/null
16
diff_status=$?
17
if [ $diff_status -eq 0 ] ; then
18
    # No uncommitted changes in the tree.
19
    bzr status | grep "^Current thread:" > /dev/null
20
    if [ $? -eq 0 ] ; then
21
        # This is a loom, lint changes relative to the lower thread.
22
        rev_option="-r thread:"
23
    elif [ "$(bzr pipes | sed -n -e "/^\\*/q;p" | wc -l)" -gt 0 ]; then
24
        # This is a pipeline with at least one pipe before the
25
        # current, lint changes relative to the previous pipe
26
        rev_option="-r ancestor::prev"
27
    else
28
        # Lint changes relative to the parent.
29
        rev=`bzr info | sed \
30
            '/parent branch:/!d; s/ *parent branch: /ancestor:/'`
31
        rev_option="-r $rev"
32
    fi
33
elif [ $diff_status -eq 1 ] ; then
34
    # Uncommitted changes in the tree, return those files.
35
    rev_option=""
36
else
37
    # bzr diff failed
38
    exit 1
39
fi
40
# Extract filename from status line.  Strip the @ that mark symlinks.
41
files=`bzr st --short $rev_option |
42
    sed -e '/^.[MN]/!d; s/.* //' -e 's/@$//'`
43
44
echo $files
45