rakelib/workflow.rake
changeset 138 2507036dfee8
parent 137 e665031cade7
parent 127 664296ccdb4a
child 241 481556cfa16d
--- a/rakelib/workflow.rake	Fri Aug 11 09:23:06 2017 +0200
+++ b/rakelib/workflow.rake	Fri Aug 11 09:59:28 2017 +0200
@@ -18,6 +18,7 @@
   end
 
   def push(remote, user, pass, review_only, push_bookmark)
+    has_changes = false
     hg_repositories do |pkg, hg|
       opts = {
           :user => user,
@@ -41,33 +42,48 @@
       # mainly beacuse there are on separate protected repositories 
       # not accessible without a special setup. Sigh...
       if ((pkg.name == 'stx:stc') or (pkg.name == 'stx:librun')) and ((remote_used == 'upstream') or (remote_used == 'canonical'))
-        puts ''
-        puts "== Skipping push of #{pkg.name} - you must push manually =="
-        puts ''
+        if !review_only
+          puts ''
+          puts "== Skipping push of #{pkg.name} - you must push manually =="
+          puts''
+        end
       else
         if review_only
           opts[:rev] = '.'
           remote_url = hg.paths[remote_used] || remote_used
           bookmark = hg.bookmark
-          puts ''
-          puts "== changes going to #{remote_url} =="
-          puts ''
-          hg.outgoing(remote_used, **opts)
-          puts ''
-          puts "Will update bookmark '#{bookmark}" if push_bookmark and bookmark
-          puts '===================================='
-          puts ''
+          hg.outgoing(remote_used, **opts) do | status, stdout |
+            case status.exitstatus
+            when 0          
+              puts ''
+              puts "== changes going to #{remote_url} =="
+              STDOUT.print stdout
+              puts "Will update bookmark '#{bookmark}" if push_bookmark and bookmark
+              puts '===================================='
+              has_changes = true
+            when 1
+              # nothing
+            else        
+              raise Exception.new("Failed to do 'outgoing' from #{remote} (exit code #{status.exitstatus})")
+            end
+          end
         else
           (push_bookmark && bookmark) ? (opts[:bookmarks] = ['.']) : (opts[:rev] = '.') # bookmark can be uninitialized
           hg.push(remote_used, **opts)
+          has_changes = true
         end
       end
     end
+    has_changes
   end
 
   desc 'Display changes to be pushed to upstream repositores (use it to review what workflow:push-upstream would do)'
   task :'out-upstream', :user, :pass do |t, args|
-    push('upstream', args[:user], args[:pass], true, false)
+    RakeFileUtils.verbose(false) do
+      has_changes = push('upstream', args[:user], args[:pass], true, false)
+      puts 'No changes to be pushed to upstream repositories' unless has_changes
+      exit(has_changes ? 0 : 1 )
+    end
   end
   task :'out-upstream' => :'setup'
 
@@ -80,7 +96,11 @@
 
   desc 'Display changes to be pushed to staging repositores (use it to review what workflow:push-staging would do)'
   task :'out-staging', :user, :pass do |t, args|
-    push('staging', args[:user], args[:pass], true, true)
+    RakeFileUtils.verbose(false) do
+      has_changes = push('staging', args[:user], args[:pass], true, true)
+      puts 'No changes to be pushed to staging repositories' unless has_changes
+      exit(has_changes ? 0 : 1 )
+    end
   end
   task :'out-staging' => :'setup'