https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Vcs back: it finds the younger revision where a command success.
* vcs/lib/vcs/back.rb: New. Based on prcs_back (LrdeTools).
* vcs/lib/vcs/app.rb: Exit 1 if the app catch an exception.
* vcs/lib/vcs/script.rb: Let the SystemExit exception go through this
method.
app.rb | 1 +
back.rb | 36 ++++++++++++++++++++++++++++++++++++
script.rb | 2 ++
3 files changed, 39 insertions(+)
Index: vcs/lib/vcs/app.rb
--- vcs/lib/vcs/app.rb (revision 260)
+++ vcs/lib/vcs/app.rb (working copy)
@@ -121,6 +121,7 @@
logger.debug { err = ex.long_pp ; "Backtrace enabled:" }
err = ex.inspect if err.empty?
logger.error { err }
+ exit 1
end
end
Index: vcs/lib/vcs/script.rb
--- vcs/lib/vcs/script.rb (revision 260)
+++ vcs/lib/vcs/script.rb (working copy)
@@ -14,6 +14,8 @@
def script! ( files=[], options={} )
begin
eval(files.join(' '))
+ rescue SystemExit => ex
+ raise ex
rescue Exception => ex
logger.error { 'Vcs#script: during the client execution' }
logger.error { ex.long_pp }
Index: vcs/lib/vcs/back.rb
--- vcs/lib/vcs/back.rb (revision 0)
+++ vcs/lib/vcs/back.rb (revision 0)
@@ -0,0 +1,36 @@
+# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
+# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
+# License:: Gnu General Public License.
+# Revision:: $Id$
+
+class Vcs
+ # This command take a command as argument and search the last revision where
+ # this command success.
+ #
+ # Example:
+ # * this dummy example success only if the revision is equal to 0 modulo X
+ # * replace X by the success revision and Y by a greater revision
+ # vcs-svn back -r Y vcs-svn script 'exit(rev.read.to_i % X)'
+ def back! ( files=[], options={} )
+ sub_vcs = sub_vcs_with_name('checkout-4-vcs-back')
+ dir = TempPath.new('checkout-dir-4-vcs-back')
+ cmd = files.to_cmd
+ cmd.dir = dir
+ rev = options[:revision] || revision.read.chomp
+ raise ArgumentError, "Just integers are supported for revisions" if rev !~
/^\d+$/
+ rev = rev.to_i
+ target_url = url.read.chomp
+ while not rev.zero?
+ sub_vcs.checkout([target_url, dir], :quiet => true, :revision => rev)
+ data = cmd.system
+ data.display if options[:verbose]
+ if data.status.success?
+ logger.info { "Your command success on revision #{rev}"}
+ break
+ else
+ logger.warn { "Your command fail on revision #{rev}" }
+ end
+ rev -= 1
+ end
+ end
+end # class Vcs
\ No newline at end of file
Property changes on: vcs/lib/vcs/back.rb
___________________________________________________________________
Name: svn:keywords
+ Id