cococo111111 / svnx

Automatically exported from code.google.com/p/svnx
0 stars 0 forks source link

Show whether a working copy needs commit/update #155

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In the list of working copies, add a tag so that I can see if there are files 
that needs updates. See my (quick and dirty) geektools script that does the 
same for me if I place my working copies in the specified directories below:

---
#!/bin/sh

parse_svn_status() {
    local REV=$(                # get svn revision number
        svn info "$1" 2>/dev/null | grep Revision | sed -e 's/Revision: //'
    )
    [ "$REV" ] || return        # stop now if not a working copy

    local STATUS=(              # create an array

        # svn status items (second column is always ' ', 'C', or 'M')
        $( svn st "$1" | grep '^[^ ][ CM]' | \

        # first column only, filter duplicates
        sed -Ee 's/^(.).*$/\1/' | awk 'x[$0]++ == 0' )
    )

    [ "$STATUS" ] || return

    echo "$1 (${STATUS[*]})"
}

alldirs() {
for file in *; do
    if [ -d "$file" ]; then
#   echo "Checking:" "$file"
    parse_svn_status "$file";
    fi
done
}

echo "Subversion Dirty Working Copies"
echo ""
echo "Research:"
echo "---------"
pushd /Users/msv/Documents/Research >>/dev/null
alldirs
echo ""
echo "Teaching:"
echo "---------"
pushd /Users/msv/Documents/Teaching >>/dev/null
alldirs
echo ""
pushd /Users/msv/Documents/ >>/dev/null
parse_svn_status "Personal"

popd >>/dev/null
popd >>/dev/null
popd >>/dev/null

---

Original issue reported on code.google.com by mikael.s...@gmail.com on 20 Jan 2012 at 12:32

GoogleCodeExporter commented 9 years ago
How about this little ditty — it works on multiple WCs & folders of WCs (or 
sym-links to WCs) and actually can show updates for WCs.

> svn_wcs --help
Summarise status of Subversion working copies.
Usage: svn_wcs [options] [directories…]
    -u [--show-updates]       : get update info from repository
    -v [--ignore-unversioned] : don’t show info for unversioned files
    -x [--ignore-externals]   : ignore externals definitions
    -wc [--working-copies]    : directories are working copies
    [directories…]            : WCs or directories containing WCs
    If no directory is specified then . is used.

----->8----->8----->8----->8----->8----->8----->8-----
#!/bin/bash -e
# Summarise status of Subversion Working Copies
# Usage: svn_wcs [--show-updates] [--ignore-unversioned] [--ignore-externals] 
[-wc] [dir…]

opts=; col1='[^ ]'
case "$1" in -h|--help) echo "Summarise status of Subversion working copies.
Usage: ${0##*/} [options] [directories…]
    -u [--show-updates]       : get update info from repository
    -v [--ignore-unversioned] : don’t show info for unversioned files
    -x [--ignore-externals]   : ignore externals definitions
    -wc [--working-copies]    : directories are working copies
    [directories…]            : WCs or directories containing WCs
    If no directory is specified then . is used."; exit;; esac
case "$1" in -u|--show-updates) opts='--show-updates'; shift;; esac
case "$1" in -v|--ignore-unversioned) col1='[^ \?]'; shift;; esac
case "$1" in -x|--ignore-externals) opts+=' --ignore-externals'; shift;; esac
case "$1" in -wc|--working-copies) wc=1; shift;; esac
if [ $# = 0 ]; then set -- .; fi

function Stat() {
    local w="$PWD"
    for d in "$@"; do cd "$w"
        if [ -d "$d" ]; then
            cd "$d"; rev=`svnversion || echo 'exported'`
            if [ "$rev" != exported ]; then
                if [ ${#PWD} -gt $L ]; then L=${#PWD}; fi
                if [ ${#rev} -gt $R ]; then R=${#rev}; fi
                dirs[i]="$PWD"
                revs[$((i++))]="$rev"
            fi
        fi
    done
}

dirs=; revs=; i=0; L=8; R=3; S='          '; S="$S$S$S$S"; S="$S$S$S$S$S"
if [ "$wc" ]
    then Stat "$@"
    else d0="$PWD"; for r in "$@"; do cd "$d0"; cd "$r"; Stat *; done
fi 2> /dev/null

Sed="s/^($col1)...... .*/\1/p"$'\ns/^.([^ ])..... .*/\\1/p\n/^........\\* 
/i\\\n*'
i=0; for dir in ${dirs[*]}; do
    cd "$dir"; rev="${revs[$((i++))]}"
    st=`svn st --non-interactive $up | sed -Ene "$Sed" | sort -r | uniq | tr -d '\n'`
    printf "%s%s   r%s%s   %s\n" "$dir" "${S::$((L-${#dir}))}" \
           $rev "${S::$((R-${#rev}))}" "${st:-✓}"
done 2> /dev/null

----->8----->8----->8----->8----->8----->8----->8-----

Original comment by chris...@gmail.com on 1 Mar 2012 at 2:30

GoogleCodeExporter commented 9 years ago
Certainly. Much nicer too.

Thus: it appears to be relatively easy to get the desired information. Now all 
that is needed is a column in the working copies window that shows this 
information.

Original comment by mikael.s...@gmail.com on 1 Mar 2012 at 9:02