]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Update SRCREV fetcher code to cope better with multiple SCM packages
authorRichard Purdie <richard@openedhand.com>
Tue, 13 Nov 2007 23:03:21 +0000 (23:03 +0000)
committerRichard Purdie <richard@openedhand.com>
Tue, 13 Nov 2007 23:03:21 +0000 (23:03 +0000)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3145 311d38ba-8fff-0310-9ca6-ca027cbcb966

bitbake/lib/bb/fetch/__init__.py
bitbake/lib/bb/fetch/git.py
bitbake/lib/bb/fetch/svn.py

index d9dfc7402d08e6d574752b02c764d6dca655ab2a..4da92110ef7614d9e30d7661a461f8c7b03646bd 100644 (file)
@@ -194,6 +194,7 @@ def get_srcrev(d):
         return "SRCREVINACTION"
 
     scms = []
+
     # Only call setup_localpath on URIs which suppports_srcrev() 
     urldata = init(bb.data.getVar('SRC_URI', d, 1).split(), d, False)
     for u in urldata:
@@ -365,6 +366,34 @@ class Fetch(object):
         return data.getVar("SRCDATE", d, 1) or data.getVar("CVSDATE", d, 1) or data.getVar("DATE", d, 1)
     getSRCDate = staticmethod(getSRCDate)
 
+    def srcrev_internal_helper(ud, d):
+        """
+        Return:
+            a) a source revision if specified
+           b) True if auto srcrev is in action
+           c) False otherwise
+        """
+
+        if 'rev' in ud.parm:
+            return ud.parm['rev']
+
+        if 'tag' in ud.parm:
+            return ud.parm['tag']
+
+        rev = None
+        if 'name' in ud.parm:
+            pn = data.getVar("PN", d, 1)
+            rev = data.getVar("SRCREV_pn-" + pn + "_" + ud.parm['name'], d, 1)
+        if not rev:
+            rev = data.getVar("SRCREV", d, 1)
+        if not rev:
+            return False
+        if rev is "SRCREVINACTION":
+            return True
+        return rev
+
+    srcrev_internal_helper = staticmethod(srcrev_internal_helper)
+
     def try_mirror(d, tarfn):
         """
         Try to use a mirrored version of the sources. We do this
@@ -454,7 +483,7 @@ class Fetch(object):
 
         pd = persist_data.PersistData(d)
         key = self._revision_key(url, ud, d)
-        latest_rev = self.latest_revision(url, ud, d)
+        latest_rev = self._build_revision(url, ud, d)
         last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev")
         count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count")
 
index cdd5a1090c684c37aa455b7e294b0f145cccedf2..5984818f9e4bfa3607448ff3ac50ae196bcf3324 100644 (file)
@@ -50,13 +50,14 @@ class Git(Fetch):
         if 'protocol' in ud.parm:
             ud.proto = ud.parm['protocol']
 
-        tag = data.getVar("SRCREV", d, 1)
-        if 'tag' in ud.parm:
-            ud.tag = ud.parm['tag']
-        elif tag is "SRCREVINACTION":
-            ud.tag = self.latest_revision(url, ud, d)
-        else:
-            ud.tag = tag            
+        tag = Fetch.srcrev_internal_helper(ud, d)
+        if tag is True:
+            ud.tag = self.latest_revision(url, ud, d)  
+        elif tag:
+            ud.tag = tag
+
+        if not ud.tag:
+            ud.tag = self.latest_revision(url, ud, d)  
 
         if ud.tag == "master":
             ud.tag = self.latest_revision(url, ud, d)
@@ -132,3 +133,5 @@ class Git(Fetch):
         output = runfetchcmd("git ls-remote %s://%s%s" % (ud.proto, ud.host, ud.path), d, True)
         return output.split()[0]
 
+    def _build_revision(self, url, ud, d):
+        return ud.tag        
index c3cebc390d336db01e9c8dba2da02054f1190ddb..5e5b31b3adf8a1f7233a89ea5870d644729dc571 100644 (file)
@@ -70,10 +70,11 @@ class Svn(Fetch):
             if "DATE" in pv:
                 ud.revision = ""
             else:
-                rev = data.getVar("SRCREV", d, 1)
-                if rev is "SRCREVINACTION":
-                    rev = self.latest_revision(url, ud, d)
-                if rev:
+                rev = Fetch.srcrev_internal_helper(ud, d)
+                if rev is True:
+                    ud.revision = self.latest_revision(url, ud, d)
+                    ud.date = ""
+                elif rev:
                     ud.revision = rev
                     ud.date = ""
                 else:
@@ -195,8 +196,9 @@ class Svn(Fetch):
     def _sortable_revision(self, url, ud, d):
         """
         Return a sortable revision number which in our case is the revision number
-        (use the cached version to avoid network access)
         """
 
-        return self.latest_revision(url, ud, d)
+        return self._build_revision(url, ud, d)
 
+    def _build_revision(self, url, ud, d):
+        return ud.revision