[Checkins] SVN: keas.build/branches/new-product-generation-in-branch-release/ - feature: added -i --independent-branches option. This option will force

Roger Ineichen cvs-admin at zope.org
Fri Dec 14 00:41:18 UTC 2012


Log message for revision 128641:
  - feature: added -i --independent-branches option. This option will force
    to check if the last release was made from the same branch we are
    releasing from. This is required if you develop a new software generation
    in a branch which is independent from the trunk. Previous version of
    keas.build where only able to handle branch releases as bug fix releases
    and didn't make sure that we don't mix trunk and branch releases. Now with
    the -i option we force that all released packages will be made or reused
    based on the current trunk or branch (-b trunk)
  
  - added more logging infos for find or skip next version which makes is simpler
    to see what's going on

Changed:
  U   keas.build/branches/new-product-generation-in-branch-release/CHANGES.txt
  U   keas.build/branches/new-product-generation-in-branch-release/src/keas/build/base.py
  U   keas.build/branches/new-product-generation-in-branch-release/src/keas/build/package.py

-=-
Modified: keas.build/branches/new-product-generation-in-branch-release/CHANGES.txt
===================================================================
--- keas.build/branches/new-product-generation-in-branch-release/CHANGES.txt	2012-12-14 00:21:21 UTC (rev 128640)
+++ keas.build/branches/new-product-generation-in-branch-release/CHANGES.txt	2012-12-14 00:41:18 UTC (rev 128641)
@@ -4,9 +4,19 @@
 0.2.3 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- feature: added -i --independent-branches option. This option will force
+  to check if the last release was made from the same branch we are
+  releasing from. This is required if you develop a new software generation
+  in a branch which is independent from the trunk. Previous version of
+  keas.build where only able to handle branch releases as bug fix releases
+  and didn't make sure that we don't mix trunk and branch releases. Now with
+  the -i option we force that all released packages will be made or reused
+  based on the current trunk or branch (-b trunk)
 
+- added more logging infos for find or skip next version which makes is simpler
+  to see what's going on
 
+
 0.2.2 (2011-08-29)
 ------------------
 

Modified: keas.build/branches/new-product-generation-in-branch-release/src/keas/build/base.py
===================================================================
--- keas.build/branches/new-product-generation-in-branch-release/src/keas/build/base.py	2012-12-14 00:21:21 UTC (rev 128640)
+++ keas.build/branches/new-product-generation-in-branch-release/src/keas/build/base.py	2012-12-14 00:41:18 UTC (rev 128641)
@@ -324,6 +324,11 @@
     help="When specified, this branch will be always used.")
 
 parser.add_option(
+    "-i", "--independent-branches", action="store_true",
+    dest="independent", metavar="INDEPENDENT", default=False,
+    help="When specified, the system makes sure the last release is based on the given branch.")
+
+parser.add_option(
     "--no-upload", action="store_true",
     dest="noUpload", default=False,
     help="When set, the generated configuration files are not uploaded.")

Modified: keas.build/branches/new-product-generation-in-branch-release/src/keas/build/package.py
===================================================================
--- keas.build/branches/new-product-generation-in-branch-release/src/keas/build/package.py	2012-12-14 00:21:21 UTC (rev 128640)
+++ keas.build/branches/new-product-generation-in-branch-release/src/keas/build/package.py	2012-12-14 00:41:18 UTC (rev 128641)
@@ -222,9 +222,11 @@
         return branches
 
     def hasChangedSince(self, version, branch):
-        # setup.py gets changed on the branch after the tag is created, so
-        # that the branch always has a later revision. So let's check the
-        # source directory instead.
+        # check if svn revision gets changed on the branch after the tag
+        # was created, so that the branch always has a later revision. Note
+        # that our last release was updating the version in setup.py which also
+        # forces a change after adding the tag. So let's check the source
+        # directory instead.
         branchUrl = self.getBranchURL(branch) + '/src'
         tagUrl = self.getTagURL(version)
         changed = self.getRevision(branchUrl)[1] > self.getRevision(tagUrl)[1]
@@ -234,6 +236,33 @@
                 branch, version))
         return changed
 
+    def isLastReleaseFromBranch(self, version, branch):
+        # check if the dev marked version in setup.py from the given branch
+        # compares with our version we will guess. If so, this means no
+        # other branch was used for release this package.
+        pyURL = '%ssetup.py' % self.getBranchURL(branch)
+        req = urllib2.Request(pyURL)
+        if self.packageIndexUsername:
+            base64string = base64.encodestring(
+                '%s:%s' % (self.packageIndexUsername,
+                           self.packageIndexPassword))[:-1]
+            req.add_header("Authorization", "Basic %s" % base64string)
+        setuppy = urllib2.urlopen(req).read()
+        nextVersion = re.search("version ?= ?'(.*)',", setuppy)
+        if not nextVersion:
+            logger.error("No version =  found in setup.py, cannot update!")
+            # prevent mess up, force ensure new release
+            return False
+        else:
+            nextVersion = nextVersion.groups()[0]
+            setupVersion = '%sdev' % base.guessNextVersion(version)
+            if setupVersion == nextVersion:
+                return True
+            else:
+                logger.info("Last release %s wasn't released from branch %r " % (
+                    version, branch))
+                return False
+
     def createRelease(self, version, branch):
         logger.info('Creating release %r for %r from branch %r' %(
             version, self.pkg, branch))
@@ -299,7 +328,7 @@
         else:
             logger.warn('Unknown uploadType: ' + self.uploadType)
 
-        # 5. Update the start branch to the next devel version
+        # 5. Update the start branch to the next development (dev) version
         if not self.options.noBranchUpdate:
             logger.info("Updating branch version metadata")
             # 5.1. Check out the branch.
@@ -391,23 +420,44 @@
                 defaultVersion = forceVersion
 
         if versions and not defaultVersion:
-            # 3.2. If the branch was specified, check whether it changed since
-            # the last release.
-            changed = False
-            if self.options.branch:
-                logger.info('Checking for changes since version %s; please wait...', versions[-1])
-                changed = self.hasChangedSince(
-                    versions[-1], self.options.branch)
-                if not changed:
-                    logger.info("No changes detected.")
+            if self.options.nextVersion:
+                # 3.2. If the branch was specified, check whether it changed
+                # since the last release or if independent is set, if the last
+                # release is based on the current branch
+                changed = False
+                if self.options.branch:
+                    logger.info("Checking for changes since version %s; please "
+                                "wait...", versions[-1])
+                    changed = self.hasChangedSince(versions[-1],
+                        self.options.branch)
+                    if self.options.independent and not changed:
+                        # only check if not already marked as changed
+                        logger.info("Checking if last release is based on "
+                                    "branch %s; please wait...",
+                                    self.options.branch)
+                        if not self.isLastReleaseFromBranch(versions[-1],
+                            self.options.branch):
+                            changed = True
+                    if not changed:
+                        logger.info("No changes detected.")
+                else:
+                    logger.info("Not checking for changes since version %s "
+                                "because no -b or --use-branch was specified.",
+                                versions[-1])
+                # 3.3. If the branch changed and the next version should be
+                # suggested, let's find the next version.
+                if changed:
+                    defaultVersion = base.guessNextVersion(versions[-1])
+                else:
+                    defaultVersion = versions[-1]
             else:
-                logger.info("Not checking for changes since version %s because no branch was specified.", versions[-1])
-            # 3.3. If the branch changed and the next version should be
-            # suggested, let's find the next version.
-            if self.options.nextVersion and changed:
-                defaultVersion = base.guessNextVersion(versions[-1])
-            else:
+                logger.info("Not checking for changes because -n or "
+                            "--next-version was not used")
                 defaultVersion = versions[-1]
+        else:
+            logger.info(
+                "Not checking for changes because --force-version was used")
+            
         branch = self.options.branch
         while True:
             version = base.getInput(



More information about the checkins mailing list