Check-in [41dda1b627]

The development has migrated to github


Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implement stash save -u
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:41dda1b62741319ade2345030285e448ea568cbd
User & Date: bapt 2013-06-21 09:39:20
Context
2013-06-21
10:05
Preliminary support for versionning the stash with git,hg,svn,fossil check-in: e7dbfc90bb user: bapt tags: trunk
09:39
Implement stash save -u check-in: 41dda1b627 user: bapt tags: trunk
09:35
Now remove unversionned file when saving check-in: c3d2bbcf1a user: bapt tags: trunk
Changes

Changes to stash.

52
53
54
55
56
57
58
59
60
61

62



63
64
65
66
67
68
69
svnrp=$(svn info 2>&1 | sed -n 's/Working Copy Root Path: \(.*\)/\1/p')
[ -d "${svnrp}" ] || err 1 "should be used inside a working copy"
[ -w "${svnrp}/.svn" ] || err 1 "no write access to ${svnrp}/.svn"
patchdir=${svnrp}/.svn/patches
mkdir -p "${patchdir}" || err 1 "Impossible to create the patch directory"

save() {
	[ $# -ge 1 ] || err 1 "Usage: stash save <name> [files...]"
	patch="${patchdir}/$1.patch"
	[ ! -f "${patch}" ] || err 1 "A patch named $1 already exists"

	shift



	files="$@"
	changes=$(svn st -q ${files})
	[ "${changes}" != "" ] || err 1 "No changes to save"
	svn diff --git ${files:-.} > "${patch}"
	svn revert --depth=infinity ${files:-.}
	svn st ${files} | awk '/^?/ { print $1 }' | xargs rm -f
	echo "stashed"







|

|
>
|
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
svnrp=$(svn info 2>&1 | sed -n 's/Working Copy Root Path: \(.*\)/\1/p')
[ -d "${svnrp}" ] || err 1 "should be used inside a working copy"
[ -w "${svnrp}/.svn" ] || err 1 "no write access to ${svnrp}/.svn"
patchdir=${svnrp}/.svn/patches
mkdir -p "${patchdir}" || err 1 "Impossible to create the patch directory"

save() {
	[ $# -ge 1 ] || err 1 "Usage: stash save [-u] <name> [files...]"
	patch="${patchdir}/$1.patch"
	shift
	if [ "$1" = "-u" ]; then
		shift
	else
		[ ! -f "${patch}" ] || err 1 "A patch named ${patch} already exists"
	fi
	files="$@"
	changes=$(svn st -q ${files})
	[ "${changes}" != "" ] || err 1 "No changes to save"
	svn diff --git ${files:-.} > "${patch}"
	svn revert --depth=infinity ${files:-.}
	svn st ${files} | awk '/^?/ { print $1 }' | xargs rm -f
	echo "stashed"