rakelib/scm.rb
changeset 88 112075e99cef
parent 85 6d918f722075
child 102 fc572bd895f2
--- a/rakelib/scm.rb	Sun Nov 27 22:57:33 2016 +0000
+++ b/rakelib/scm.rb	Sun Dec 04 22:21:22 2016 +0000
@@ -147,6 +147,13 @@
         end
         hg.pull('staging')
       end
+      if repository.upstream then        
+        if not paths.has_key? 'upstream'           
+          paths['upstream'] = "#{repository.upstream}/#{directory.gsub('/', separator)}"
+          hg.paths = paths
+        end
+        hg.pull('upstream')
+      end
       if not paths.has_key? 'canonical'
         paths['canonical'] = "#{repository.canonical}/#{directory.gsub('/', separator)}"
         hg.paths = paths
@@ -251,25 +258,31 @@
     separator = kwargs[:separator] || '.'
     revision =  kwargs[:revision] 
     
-    paths = { 'default' => "#{repository.upstream}/#{directory.gsub('/', separator)}",
-              'canonical' => "#{repository.canonical}/#{directory.gsub('/', separator)}" }            
+    paths = { 'canonical' => "#{repository.canonical}/#{directory.gsub('/', separator)}" }            
+    if repository.upstream then
+      paths['upstream'] = "#{repository.upstream}/#{directory.gsub('/', separator)}"
+    end
     if repository.staging then
       paths['staging'] = "#{repository.staging}/#{directory.gsub('/', separator)}"
     end
+
     
     begin
       if repository.staging then
-        hg = HG::Repository.clone(paths['staging'], root / directory, noupdate: true)
+        paths['default'] = paths['staging']
+        hg = HG::Repository.clone(paths['staging'], root / directory, noupdate: true)        
         hg.paths = paths
-        hg.pull('default')  
+        hg.pull('upstream') if paths['upstream'] 
+        hg.pull('canonical')
+      elsif repository.upstream then
+        paths['default'] = paths['upstream']
+        hg = HG::Repository.clone(paths['upstream'], root / directory, noupdate: true)        
+        hg.paths = paths
+        hg.pull('canonical')
       else
-        hg = HG::Repository.clone(paths['default'], root / directory, noupdate: true)
+        hg = HG::Repository.clone(paths['canonical'], root / directory, noupdate: true)
         hg.paths = paths
       end
-      
-      if paths['default'] != paths['canonical'] then
-        hg.pull('canonical')
-      end
       # If revision is not specified, then look for bookmark
       # `master`. If it exist, then check out `master`. If it 
       # does not, then checkout tip or throw an error.