Merge branch 'master' of ssh://arlpc64/home/josh/files
This commit is contained in:
commit
dee5aec5b4
42
bash_aliases
42
bash_aliases
@ -17,25 +17,6 @@ alias grep='grep --color=auto'
|
|||||||
alias grepnosvn='grep --color=auto --exclude-dir=".svn"'
|
alias grepnosvn='grep --color=auto --exclude-dir=".svn"'
|
||||||
alias egrepnosvn='egrep --color=auto --exclude-dir=".svn"'
|
alias egrepnosvn='egrep --color=auto --exclude-dir=".svn"'
|
||||||
alias gvim='gvim --remote-tab-silent'
|
alias gvim='gvim --remote-tab-silent'
|
||||||
alias svnst='svn st | grep -v "^X" | grep -v "^\$"'
|
|
||||||
alias svn-root="svn info | grep '^URL: ' | sed -e 's/^URL: //' -re 's/\/(trunk|tags|branches)\>.*//'"
|
|
||||||
function svn-branch()
|
|
||||||
{
|
|
||||||
# do from anywhere in a working copy of the repository
|
|
||||||
# usage: svn-branch branch-name -m "comment"
|
|
||||||
local branch_name="$1"
|
|
||||||
shift 1
|
|
||||||
svn copy `svn-root`/trunk `svn-root`/branches/"$branch_name" "$@"
|
|
||||||
}
|
|
||||||
function svn-merge-branch()
|
|
||||||
{
|
|
||||||
# usage: svn-merge-branch branch-name branch-dir -m "comment"
|
|
||||||
local branch_name="$1"
|
|
||||||
local branch_dir="$2"
|
|
||||||
shift 2
|
|
||||||
local branch_rev=$(svn log --stop-on-copy `svn-root`/branches/"$branch_name" | egrep -A1 -- '-{50}' | egrep '^r[0-9]+' | tail -n 1 | sed -re 's/^r([0-9]+).*/\1/')
|
|
||||||
svn merge -r${branch_rev}:HEAD `svn-root`/branches/"$branch_name""$branch_dir" "$@"
|
|
||||||
}
|
|
||||||
alias cribbage='cribbage -r'
|
alias cribbage='cribbage -r'
|
||||||
alias backgammon='backgammon -r -pb'
|
alias backgammon='backgammon -r -pb'
|
||||||
# put 'cattodo' in $PROMPT_COMMAND to use
|
# put 'cattodo' in $PROMPT_COMMAND to use
|
||||||
@ -104,29 +85,12 @@ function git-config-joshs()
|
|||||||
git config --global core.excludesfile ${HOME}/.gitignore
|
git config --global core.excludesfile ${HOME}/.gitignore
|
||||||
git config --global core.pager 'less -FRXi'
|
git config --global core.pager 'less -FRXi'
|
||||||
}
|
}
|
||||||
function svn()
|
|
||||||
{
|
|
||||||
local subcommand="$1"
|
|
||||||
local realsvn=$(which svn 2>/dev/null)
|
|
||||||
local colorsvn=$(which colorsvn 2>/dev/null)
|
|
||||||
local colordiff=$(which colordiff 2>/dev/null)
|
|
||||||
if [[ "$realsvn" == "" ]]; then
|
|
||||||
echo "Subversion not found in \$PATH"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [[ "$subcommand" == "diff" && "$colordiff" != "" ]]; then
|
|
||||||
${realsvn} "$@" | ${colordiff}
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [[ "$colorsvn" != "" ]]; then
|
|
||||||
${colorsvn} "$@"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
${realsvn} "$@"
|
|
||||||
}
|
|
||||||
function svn-contributors()
|
function svn-contributors()
|
||||||
{
|
{
|
||||||
svn log -q "$@" | grep -Ev '^-{30}' | cut -d '|' -f2 | awk '{ print $1 }' | sort | uniq -c | sort -n
|
svn log -q "$@" | grep -Ev '^-{30}' | cut -d '|' -f2 | awk '{ print $1 }' | sort | uniq -c | sort -n
|
||||||
}
|
}
|
||||||
|
if [[ "$(which jsvn)" != "" ]]; then
|
||||||
|
alias svn='jsvn'
|
||||||
|
fi
|
||||||
|
|
||||||
# local
|
# local
|
||||||
|
81
jsvn
Executable file
81
jsvn
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Josh's SVN wrapper script
|
||||||
|
# Recommend putting in path as 'jsvn' or something other than 'svn' and
|
||||||
|
# making an alias svn='jsvn'
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
from subprocess import *
|
||||||
|
|
||||||
|
PATH = os.environ['PATH'].split(os.pathsep)
|
||||||
|
|
||||||
|
def findInPath(cmd):
|
||||||
|
for p in PATH:
|
||||||
|
full_path = os.path.join(p, cmd)
|
||||||
|
if os.path.exists(full_path):
|
||||||
|
return full_path
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def getSVNURL(svn):
|
||||||
|
for line in Popen([svn, 'info'], stdout=PIPE).communicate()[0].split('\n'):
|
||||||
|
m = re.match('^URL:\s*(.*?)\s*$', line)
|
||||||
|
if m is not None:
|
||||||
|
return m.group(1)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def getSVNRoot(svn):
|
||||||
|
url = getSVNURL(svn)
|
||||||
|
parts = url.split('/')
|
||||||
|
for i in range(0, len(parts)):
|
||||||
|
if parts[i] in ('trunk', 'tags', 'branches'):
|
||||||
|
return '/'.join(parts[:i-1])
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def getSVNTopLevel(svn):
|
||||||
|
url = getSVNURL(svn)
|
||||||
|
parts = url.split('/')
|
||||||
|
for i in range(0, len(parts)):
|
||||||
|
if parts[i] == 'trunk' or i > 0 and parts[i-1] in ('tags', 'branches'):
|
||||||
|
return '/'.join(parts[:i+1])
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
realsvn = findInPath('svn')
|
||||||
|
colorsvn = findInPath('colorsvn')
|
||||||
|
colordiff = findInPath('colordiff')
|
||||||
|
|
||||||
|
if realsvn == '':
|
||||||
|
sys.stderr.write("Error: 'svn' not found in path\n")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if len(argv) >= 1 and argv[0] == "branch":
|
||||||
|
if len(argv) < 2:
|
||||||
|
sys.stderr.write("Must supply branch name\n")
|
||||||
|
return 2
|
||||||
|
branch_name = argv[1]
|
||||||
|
origin = getSVNTopLevel(realsvn)
|
||||||
|
root = getSVNRoot(realsvn)
|
||||||
|
if origin == '' or root == '':
|
||||||
|
sys.stderr.write("Could not determine origin/root URL\n")
|
||||||
|
return 1
|
||||||
|
comment = "Created '%s' branch" % branch_name
|
||||||
|
branch_path = root + '/branches/' + branch_name
|
||||||
|
Popen([realsvn, 'copy', origin, branch_path, '-m', comment]).wait()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if len(argv) >= 1 and argv[0] == "diff" and colordiff != '':
|
||||||
|
diff_out = Popen([realsvn] + argv, stdout=PIPE).stdout
|
||||||
|
Popen([colordiff], stdin=diff_out).wait()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if colorsvn != '':
|
||||||
|
Popen([colorsvn] + argv).wait()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
Popen([realsvn] + argv).wait()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main(sys.argv[1:]))
|
Loading…
x
Reference in New Issue
Block a user