Sunday, April 15, 2007

lab 76 - using svn with gcode projects

NAME

This is not a typical lab, instead are some suggestions to work with svn repos (the ones provided by gcode); like inferno-lab or the rest of Inferno related projects at gcode.

NOTES

To work with svn the easiest way is to install subversion under the host os and write a wrapper to have the svn command available under Inferno, like:

cat > $home/dis/sh/svn << EOF
#!/dis/sh
load std

wdir=`{hp `{pwd}}
if {~ $emuhost Nt}{
 os -d $wdir svn $* | tr -d '
'
}{
 os -d $wdir svn $* 
}
EOF
The svn script relies in hp, to convert the Inferno paths to host paths, so here is hp:
cat > $home/dis/sh/hp << EOF
#!/dis/sh.dis
# convert a inferno path to valid host path for os(1)
load std

if {no $*}{
 echo 'usage: hp  # to get host path'
}

if {~ $emuhost Nt}{
 fn slashpath () { sed 's|\\|\\\\|g'; }
 # put two where there's one
 emuroot=`{echo $emuroot | slashpath | slashpath}
 
 for p in $* {
  cleanname -d `{pwd} $p | sed -n '
  /^\/n\// {s|/n/(.)/|\1:\\\\|p; q;}
  s|^|'^$emuroot^'|p;'
 }
}{
 # host letters subst
 # hls="{ns | sed -n '/#U.+/ s|^bind -. ''#U(.*)'' (.*)|s\|\2\|\1/\|p|p'}

 for p in $* {
  cleanname -d `{pwd} $p | sed -n '
  /^\/n\// {s|/n/local/|/|p; '^$hls^'; q;}
  s|^|'^$emuroot^'|p;'
 }
}
EOF
After giving them executable permission
% chmod u+x $home/dis/sh/svn
% chmod u+x $home/dis/sh/hp
and binding with bind(1) $home/dis/sh to /dis,
% bind -b $home/dis/sh /dis
this line can be added to your profile, to have them available when sh starts. After this commands under $home/dis/sh can be executed as any other sh(1) shell command available under /dis. To make an example now one can checkout inferno-lab running:
% svn checkout http://inferno-lab.googlecode.com/svn/trunk/ inferno-lab
And the same for the rest of svn commands, to check the status, diffs and commits. Good luck

FILES

svn, the original svn from acme-sac.
hp, the initial hp.

No comments: