Wrapper for command-line Subversion (svn) client with additional features
Some of initials ideas:
- Suppor for client-side pre- and post-operation hooks (pre-update, post-update and so on)
- Wrap some commands and add new abilities:
- Automatically use
colordiffforsvn diffif found - Client-side ignores for
svn statuscommand
- Automatically use
- Add "new" commands, like
svn stashfor client-side stashing changes and switches between them.
-
Edit
~/.bashrcand add new alias:alias svn="/path/to/svn-wrapper.sh $@"
-
Re-loging to system.
For deb-based distros (Debian, Ubuntu, Mint) you can edit ~/.bashrc_aliases instead of
~/.bashrc.
To activate svn stash command you should put svn-stash script to the one of directory under
PATH, for example: link it to /usr/local/bin:
sudo ln -s /path/to/svn-stash /usr/local/binTo use advanced coloring move (or make symlink) svn-color-filter.py to the PATH.
Dependency:
- colordiff (optional) - if found,
svn diffwill be use it and colorize diff output. - realpath (optional/required) - optional for wrapper, if found, local ignores will be work more proper from any tree location. Required for
svn stashfor proper work with binary and untracked files. - git (optional) - can be used by
svn stashfor stash versioning. - GNU awk (required)
- GNU coreutils (required)
- GNU grep (required)
- sed (required)
- file (required for
svn stash)
Most of required packages already presents on most Linux systems.
Currently supported hooks:
pre-updatepost-update <svn_exit_status>pre-commitpost-commit <svn_exit_status>pre-action <action>- generic hook, does not applied for actions above.post-action <action> <svn_exit_status>- generic hook, does not applied for actions above.
Hooks should be placed to the directory:
.svn/hooks
Hooks behaviour:
- If pre-hooks returns non-zero status, all operations aborts and
svncommand will not be called. - Post-hooks runs in any case, but arrives
svnreturn status as a first argument.
All hooks can see next env variables, setted by the parent script:
- $SVN - real subversion command
- $SVN_ROOT - root directory of the repository
- $HOOK_DIR - hooks directory
For additional info, see "samples/hooks" directory.
In some cases it is impossible to add new ignores to repository (I known, it is ugly!), local ignores solves this problem for end-user.
Ignores descriptions location:
.svn/ignores.txt
It is file with Basic Regex (BRE, see man 3 grep) one-per-line, that describes ignoring pattern. Empty lines
and lines starts with hash (#) skipped.
See "samples/ignores.txt" for example.
See "Output filtering" section for more details.
Allow to setup output filters for various svn commands. Uses for "Local ignores" feature (see above).
Currently filtering hard to customize, but customization is planed.
Now next type of filters is supported:
status- applied "Local ignores" featurelog- bypass toless -Rdiff- bypass tocolordiff --color=autoif foundother- bypass to output without changes
Initially stashing command based on https://github.com/bapt/svnstash implementation.
Currently major changes:
- Do not revert all untracked files by default
- Checkout stash revision before stash apply and update it back after: this solution allows to solve merge conflicts in interactive way. See
svn help patchfor more info. Note: only stashed files chekouted, it allows speed up process. - Support binary and untracked files for stashing.
- Use reference for access to the stashes in additional to name for some commands (
show,apply,pop,rm):@{#}, where#- number beginning from 1 - Updating existing stashes
- More clean VCS versioning
- Automatically calculate value for
svn path --strip #argument: LLVM requires value 2, some other distos - greater, but general - 1. - Bash completion
In plans:
- None. Seems all works as expected. Only issues fixes.
To setup Bash completion for svn stash, just include svn-stash.bash_completion from your ~/.bashrc:
. /path/to/svn-stash.bash_completionor copy to the /etc/bash_completion.d and re-login.
You can add any new svn sub-command by addting external program like:
svn-SUB_COMMAND_NAME
to the PATH.
For example, script "svn-stash" adds new sub-commmand "stash":
svn stash
Simple!
TODO: currently implemented for svn status and svn diff and hard-coded :-(