Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: rubikitch <rubikitch-X+L+6nJQZ58h9ZMKESR00Q <at> public.gmane.org>
Subject: E-scripts for subversion!
Newsgroups: gmane.emacs.eev.devel
Date: Monday 16th January 2006 20:44:46 UTC (over 12 years ago)
From: "Eduardo Ochs" 
Subject: Re: [eev] How about Subversion?
Date: Fri, 30 Dec 2005 12:39:43 -0200

> The world needs a tutorial for subversion based on e-scripts!

Here is my e-script for subversion.
It is harmless because test svn repository is created in /tmp.

;;;; [2005/05/25] view-fline
(defun view-fline (fname &rest pos-spec-list)
  (apply 'find-fline fname pos-spec-list)
  (view-mode 1))
(defun view-anchor (fname &optional tag &rest rest)
  (apply 'find-anchor fname tag rest)
  (view-mode 1))

== Studying subversion

apti subversion subversion-tools
# (find-sh "svn help")
# (find-sh "svn help ls")
# (find-sh "svn help diff")

=== Creating repository

#
# 051029-svn-create
rm -rf /tmp/svn
mkdir /tmp/svn
svnadmin create --fs-type fsfs /tmp/svn
#

 (eevnow-at "051029-svn-create")
ls -l /tmp/svn | result
 (find-fline "/tmp/svn")
 (view-fline "/tmp/svn/README.txt")
svn ls file:///tmp/svn | result
svn ls file:///tmp/svn/trunk |& result

svn mkdir -m 'setup trunk' file:///tmp/svn/trunk
svn mkdir -m 'setup branches' file:///tmp/svn/branches
svn mkdir -m 'setup tags' file:///tmp/svn/tags
svn ls file:///tmp/svn/
svn ls file:///tmp/svn/trunk


# import
 (find-sh "svn help import ")
#
# (eevnow-bounded)
tmpdir
mkdir first
cd first
echo a > a.txt
echo b > b.txt
cd ..
svn import -m 'import first'  first file:///tmp/svn/trunk/first
tmpdir-clean
#

svn ls -R file:///tmp/svn

# checkout
#
# (eevnow-bounded)
tmpdir
svn co file:///tmp/svn/trunk/first
cd first
#

ls -alR | result-long
svn info | result-long

# modify
ls
echo A >> a.txt
svn diff
svn diff a.txt
svn update
svn stat
svn stat -u -v
svn commit -m 'added' a.txt
svn stat -u -v
svn log
svn log a.txt

# add
echo c > c.txt
svn stat -u -v
svn add c.txt
svn stat -u -v
svn commit -m 'added c.txt'
svn stat -u -v
svn log a.txt
svn log
svn log file:///tmp/svn/trunk/first

# rename file
ls c.* | assert_equal c.txt 
svn mv c.txt c.rd
svn stat -uv
ls
ls c.* | assert_equal c.rd 
svn commit -m 'mv c.txt c.rd'
svn stat -uv

# add directory
mkdir -p d1/d2
touch d1/d.txt d1/d2/e.txt
svn stat -uv
svn add d1
svn commit -m 'added d1/'
svn stat -uv

# rename directory
svn mv d1 dir
svn stat -uv
ls -d d1 | assert_equal d1/ 
svn commit -m 'mv d1 dir'
ls d1 | assert_equal '' 
svn update

# tag
svn update
 (find-sh "svn help copy")
svn copy -m 'v1_0' file:///tmp/svn/trunk/first file:///tmp/svn/tags/first/v1_0
svn ls file:///tmp/svn/tags/first
svn rm file:///tmp/svn/tags/v1_0


== Subversion Branches

project=mergetest
 (eevnow-at "051029-svn-create")
 (eevnow-at "051031-svn-init-project")
svn ls -R file:///tmp/svn/$project/trunk
 (eevnow-at "051031-svn-co")
echo a > a.txt
svn add a.txt
svn commit -m 'create a.txt'
branch=first-branch
svn copy file:///tmp/svn/$project/trunk file:///tmp/svn/$project/branches/$branch
-m 'tag: first-branch'
tmpdir-clean

 (eevnow-at "051031-svn-co-branch")
cat a.txt | assert_equal a
echo branch > a.txt
svn commit -m 'a.txt:in branch'
svn switch file:///tmp/svn/$project/trunk
cat a.txt | assert_equal a
echo trunk > a.txt
svn commit -m 'a.txt:in trunk'
svn switch file:///tmp/svn/$project/branches/$branch
cat a.txt | assert_equal branch
svn log -v a.txt
svn info
svn switch file:///tmp/svn/$project/trunk
mkdir d
svn add d
svn commit -m 'add: d'
svn info
cd d
svn info
cd ..
tmpdir-clean

#
# 051031-svn-co
tmpdir
svn co file:///tmp/svn/$project/trunk
$project
cd $project
pwd
ls -R
svn info
#

#
# 051031-svn-co-branch
tmpdir
svn co file:///tmp/svn/$project/branches/$branch
$project
cd $project
pwd
ls -R
svn info
#

#
# 051031-svn-init-project
tmpdir
mkdir $project
mkdir $project/trunk $project/tags $project/branches
svn import -m "create project: $project" $project file:///tmp/svn/$project
tmpdir-clean
#

== Automatic Property Addition

Setting svn:keywords attribute.
This is enabled when committing.

 (eevnow-at "051105-svn-attrs-test")
#
# (eevnow-bounded)
rename-config
create-repos
checkout-repos-tmpdir

cat id.txt | assert_equal '$Id: diary.rd,v 1.20 2005/12/20 14:19:18
rubikitch Exp rubikitch $'
svn propset svn:keywords Id id.txt
svn proplist -v id.txt | result
cat id.txt | assert_equal '$Id: diary.rd,v 1.20 2005/12/20 14:19:18
rubikitch Exp rubikitch $'
svn commit -m 'added id.txt'
cat id.txt | assert_match 'rubikitch' | result

teardown
#


 (eevnow-at "051105-svn-attrs-test")
#
# (eevnow-bounded)
rename-config
create-repos
checkout-repos-tmpdir

cat id.txt
svn propset svn:keywords Id id.txt
cat id.txt
svn commit -m 'added id.txt'
cat id.txt | assert_match 'rubikitch' | result
svn propdel svn:keywords  id.txt
cat id.txt | assert_match 'rubikitch' | result
svn commit -m 'removed id.txt'
svn update
cat id.txt | assert_match 'rubikitch' | result

teardown
#


Automatic propety.

 (eevnow-at "051105-svn-attrs-test")
#
# (eevnow-bounded)
rename-config
enable-keywords
create-repos
checkout-repos-tmpdir

cat id.txt | assert_match rubikitch | result
svn propget svn:keywords id.txt | assert_equal Id
svn proplist -v  id.txt | result

teardown

#

I added automatic property settings into the configuration file.

#
# (eestore-bounded)
[miscellany]
### Set global-ignores to a set of whitespace-delimited globs
### which Subversion will ignore in its 'status' output.
global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.elc
RCS CVS
### Set log-encoding to the default encoding for log messages
# log-encoding = latin1
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
# use-commit-times = yes
### Set enable-auto-props to 'yes' to enable automatic properties
### for 'svn add' and 'svn import', it defaults to 'no'.
### Automatic properties are defined in the section 'auto-props'.
enable-auto-props = yes

### Section for configuring automatic properties.
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match will be applied to the file.
### Note that auto-props functionality must be enabled, which
### is typically done by setting the 'enable-auto-props' option.
[auto-props]
*.c = svn:eol-style=native;svn:keywords=Id
*.rb = svn:eol-style=native;svn:keywords=Id
*.rd = svn:eol-style=native;svn:keywords=Id
*.rd.r = svn:eol-style=native;svn:keywords=Id
*.el = svn:eol-style=native;svn:keywords=Id
*.el.r = svn:eol-style=native;svn:keywords=Id
*.r = svn:eol-style=native;svn:keywords=Id
# *.cpp = svn:eol-style=native
# *.h = svn:eol-style=native
# *.dsp = svn:eol-style=CRLF
# *.dsw = svn:eol-style=CRLF
*.sh = svn:eol-style=native;svn:executable;svn:keywords=Id
*.txt = svn:eol-style=native;svn:keywords=Id
*.txt.r = svn:eol-style=native;svn:keywords=Id
# *.txt = svn:eol-style=native
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg
Makefile = svn:eol-style=native;svn:keywords=Id
Rakefile = svn:eol-style=native;svn:keywords=Id

#

# (find-fline "~/.subversion/config")


 (eevnow-at "051105-svn-attrs-test")
#
# (eevnow-bounded)
create-repos
checkout-repos-tmpdir

cat id.txt | assert_match rubikitch | result
svn propget svn:keywords id.txt | assert_equal Id
svn proplist -v  id.txt | result

teardown2
#



#
# 051105-svn-attrs-test
teardown () {
restore-config
rm -rf $svnroot
tmpdir-clean
}

teardown2 () {
rm -rf $svnroot
tmpdir-clean
}


rename-config () {
(cd ~/.subversion/;  mv config config.orig)
}
restore-config () {
(cd ~/.subversion/;  mv config.orig config)
}

enable-keywords () {
<<'%%%' > ~/.subversion/config
[miscellany]
enable-auto-props = yes
[auto-props]
*.txt = svn:keywords=Id
%%%
}
create-repos () {
svnroot=/tmp/svn
svnuri=file://$svnroot
rm -rf $svnroot
svnadmin create --fs-type=fsfs $svnroot

tmpdir
mkdir rubikitch
cd rubikitch
echo a > a.txt
echo b > b.txt
echo '$Id: diary.rd,v 1.20 2005/12/20 14:19:18 rubikitch Exp rubikitch $' >
id.txt
cd ..
svn import rubikitch $svnuri/rubikitch -m "import rubikitch"
tmpdir-clean
}

checkout-repos-tmpdir () {
tmpdir
svn co $svnuri/rubikitch
cd rubikitch
}

#



== Merge Testcase

Show the revision state graph using graphviz.
#
# (eevnow-bounded)
xzgv =(dot -Tpng =(<<%%%
digraph rev {
"1 r1" -> "2 r2" -> "3-1 r4" -> "3-2 r5"
"2 r2" -> "4-1 r6" -> "4-2 r7"
"3-2 r5" -> "4-2 r7"
}
%%%))
#

 (eevnow-at "051106-svn-merge-test")
create-repos # r1
checkout-trunk-tmpdir
cp 2 target.txt
do-commit # r2
make-branch # r3
cp 3-1 target.txt
do-commit # r4
cp 3-2 target.txt
do-commit # r5
tmpdir-clean

checkout-branch-tmpdir
cp 4-1 target.txt
do-commit # r6
svn diff -r 2:HEAD $trunkuri  # 4-2
svn merge -r 2:HEAD $trunkuri  # 4-2
assert_same_file 4-2 target.txt
do-commit
switch-to-trunk
assert_same_file 3-2 target.txt

teardown



#
# 051106-svn-merge-test
teardown () {
rm -rf $svnroot
tmpdir-clean
}

create-repos () {
svnroot=/tmp/svn
svnuri=file://$svnroot/rubikitch
trunkuri=$svnuri/trunk
branchuri=$svnuri/branches/my-branch
rm -rf $svnroot
svnadmin create --fs-type=fsfs $svnroot

tmpdir
mkdir -p rubikitch/trunk rubikitch/branches rubikitch/tags
cd rubikitch/trunk

# initial revision
<<'%%%' > 1
# correct these items.
0
1
%%%

# modified
<<'%%%' > 2
# correct these items.
0
1
2
%%%

# trunk: fixed typo
<<'%%%' > 3-1
# collect these items.
0
1
2
%%%

# trunk: added 3
<<'%%%' > 3-2
# collect these items.
0
1
2
3
%%%

# branch: 0 -> zero
<<'%%%' > 4-1
# correct these items.
zero
1
2
%%%

# merge 3-2 and 4-1
<<'%%%' > 4-2
# collect these items.
zero
1
2
3
%%%

cp 1 target.txt
cd ../..
svn import rubikitch $svnuri -m "import rubikitch"
tmpdir-clean
}

checkout-trunk-tmpdir () {
tmpdir
svn co $svnuri/trunk rubikitch
cd rubikitch
}

checkout-branch-tmpdir () {
tmpdir
svn co $svnuri/branches/my-branch rubikitch
cd rubikitch
}

make-branch () {
svn cp $trunkuri $branchuri -m 'made branch'
}

do-commit () {
svn commit -m 'commited'
}

switch-to-trunk () {
svn switch $trunkuri
}

#
 
CD: 4ms