@@ -74,13 +74,14 @@ trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)";
7474# Option parsing
7575
7676# Options
77- shortopts=hpvV
78- longopts=help,repository ,verbose,version
77+ shortopts=hnvV
78+ longopts=help,dry-run ,verbose,version
7979
8080# Default values
8181MSG=" "
8282VERFILE=ietf/__init__.py
8383SETTINGS=ietf/settings.py
84+ do=" "
8485
8586if [ " $( uname) " = " Linux" ]; then
8687 args=$( getopt -o " $shortopts " --long " $longopts " -n ' $program' -- $SV " $@ " )
@@ -99,6 +100,7 @@ while true ; do
99100 case " $1 " in
100101 -h| --help) usage; exit ;; # Show this help, then exit
101102 -m| --message) MSG=$2 ; shift ;; # Specify a commit message
103+ -n| --dry-run) do=" echo" ;; # Show what would be done
102104 -v| --verbose) VERBOSE=1;; # Be more talkative
103105 -V| --version) version; exit ;; # Show program version, then exit
104106 --) shift ; break ;;
@@ -132,14 +134,20 @@ elif [ "${DIR%%/*}" = "branch" ]; then
132134 SRC=" branch/${tmp%%/* } " # keep first subdir under branch/
133135fi
134136
137+ note " "
138+ note " Releasing from $SRC "
139+
135140note " Locating the root of the working copy..."
136- while [ " $RDIR " ]; do
137- [ " $RDIR " = " $prev " ] && die " Internal error"
141+ while [ " ${ # DIR} " -gt " ${ # SRC} " ]; do
142+ [ " $DIR " = " $prev " ] && die " Internal error"
138143 cd ..
139144 note " now at $PWD "
140- prev=$RDIR
141- RDIR =${RDIR %/* }
145+ prev=$DIR
146+ DIR =${DIR %/* }
142147done
148+ if [ " $DIR " != " $SRC " ]; then
149+ die " Couldn't find the root of your '$SRC ' working copy"
150+ fi
143151
144152REPO=${REPO%/ } # remove trailing slash
145153SRC=${SRC#/ } # remove leading slash
@@ -150,50 +158,57 @@ VER="$(printf %d.%02d $MAJOR $MINOR)"
150158NEXT=$(( $MINOR + 1 ))
151159DEV=" $( printf %d.%02d-dev $MAJOR $NEXT ) "
152160
153- note " Verifying that the version doesn't already exist"
161+
162+ note " Verifying that version $VER doesn't already exist..."
154163svn info $REPO /tags/$VER 2>&1 | grep -q " Not a valid URL" || die " The tag '$VER ' already exists (or there was an error testing for it)."
164+ note " Ok"
165+
166+ note " Verifying there's no uncommitted changes..."
167+ $do svn st | grep " ^[AMCG] " && die " There seems to be uncommitted changes in this working copy"
155168
156- note " Update the version info in $VERFILE and make sure'\$ Rev\$ ' is Ok"
157- sed -i -r -e " /^__version__/s/\" [.0-9]+(-dev)?\" /\" $VER \" /" \
169+ note " \nUpdating the version info in $VERFILE and making sure'\$ Rev\$ ' is Ok"
170+ $do sed -i -r -e " /^__version__/s/\" [.0-9]+(-dev)?\" /\" $VER \" /" \
158171 -e " /^__rev__/s/\" .*\" /\"\$ Rev:\$\" /" \
159- $SRC / $ VERFILE
172+ $VERFILE
160173
161- note " Update the deployment settings in settings.py"
162- sed -i -r -e ' s/^DEBUG *= *.*$/DEBUG = False/' \
163- -e " s/^SERVER_MODE *= *.*\$ /SERVER_MODE = 'production'/" \
164- $SRC / $ SETTINGS
174+ note " \nUpdating the deployment settings in settings.py"
175+ $do sed -i -r -e ' s/^DEBUG *= *.*$/DEBUG = False/' \
176+ -e " s/^SERVER_MODE *= *.*\$ /SERVER_MODE = 'production'/" \
177+ $SETTINGS
165178
166- note " Committing version information for version $VER . $MSG "
167- svn commit $SRC / $ VERFILE $SRC / $SETTINGS -m " Set version info to release version $VER before branching. $MSG "
179+ note " \nCommitting version information for version $VER : $MSG "
180+ $do svn commit $VERFILE $SETTINGS -m " Set version info to release version $VER before branching. $MSG "
168181
169- note " Creating new tag 'tags/$VER ' from $SRC "
170- svn cp $REPO /$SRC $REPO /tags/$VER -m " Creating new tag 'tags/$VER ' from $SRC "
182+ note " \nCreating new tag 'tags/$VER ' from $SRC "
183+ $do svn cp $REPO /$SRC $REPO /tags/$VER -m " Creating new tag 'tags/$VER ' from $SRC "
171184
172- note " Updating version and revision info to indicate that the source and branch aren't releases"
173- sed -i -r -e " /^__version__/s/\" [0-9.]*\" /\" $DEV \" /" \
174- -e " /^__rev__/s/\"\\\$ Rev: (.*) \\\$\" /\"\$ Rev:\$ (dev) Latest release: Rev. \1 \" /" \
175- $SRC / $VERFILE
185+ note " \nUpdating version and revision info to indicate that the source and branch aren't releases"
186+ $do sed -i -r -e " /^__version__/s/\" [0-9.]*\" /\" $DEV \" /" \
187+ -e " /^__rev__/s/\"\\\$ Rev: (.*) \\\$\" /\"\$ Rev:\$ (dev) Latest release: Rev. \1 \" /" \
188+ $VERFILE
176189
177- note " Updating the deployment settings in settings.py to development mode"
178- sed -i -r -e ' s/^DEBUG *= *.*$/DEBUG = True/' \
179- -e " s/^SERVER_MODE *= *.*\$ /SERVER_MODE = 'development'/" \
180- $SRC / $ SETTINGS
190+ note " \nUpdating the deployment settings in settings.py to development mode"
191+ $do sed -i -r -e ' s/^DEBUG *= *.*$/DEBUG = True/' \
192+ -e " s/^SERVER_MODE *= *.*\$ /SERVER_MODE = 'development'/" \
193+ $SETTINGS
181194
195+ note " \nCommitting the updated version and deployment settings"
196+ $do svn commit $VERFILE $SETTINGS -m " Set version info and settings back to development mode"
182197
183198# if SRC is 'trunk', then also create a new branch
184199if [ $SRC = " trunk" ]; then
185200 if svn info $REPO /branch/$VER 2>&1 | grep -q " Not a valid URL" ; then
186- note " Creating new branch 'branch/$VER ' from $SRC "
187- svn cp $REPO /$SRC $REPO /branch/$VER -m " Creating new branch 'branch/$VER ' from $SRC "
201+ note " \nCreating new branch 'branch/$VER ' from $SRC "
202+ $do svn cp $REPO /$SRC $REPO /branch/$VER -m " Creating new branch 'branch/$VER ' from $SRC "
188203 fi
189204
190- note " Updating version and revision info on trunk"
191- sed -i -r -e " /^__version__/s/\" [0-9.]*\" /\" $MAJOR .xx-trunk\" /" \
192- -e " /^__rev__/s/\"\\\$ Rev: (.*) \\\$\" /\"\$ Rev:\$ (dev) Latest release: Rev. \1 \" /" \
193- $SRC / $VERFILE
205+ note " \nUpdating version and revision info on trunk"
206+ $do sed -i -r -e " /^__version__/s/\" [0-9.]*\" /\" $MAJOR .xx-trunk\" /" \
207+ -e " /^__rev__/s/\"\\\$ Rev: (.*) \\\$\" /\"\$ Rev:\$ (dev) Latest release: Rev. \1 \" /" \
208+ $VERFILE
194209
195210 note " Commit version information '$MAJOR .xx-trunk'"
196- svn commit $SRC / $ VERFILE $SRC / $SETTINGS -m " Set version of the trunk to $MAJOR .xx-trunk after branching off $VER "
211+ $do svn commit $VERFILE $SETTINGS -m " Set version of the trunk to $MAJOR .xx-trunk after branching off $VER "
197212fi
198213
199- svn update
214+ $do svn update
0 commit comments