monitor nodemanager branch 1.8
[build.git] / module-tools.py
index 7881b18..37ed751 100755 (executable)
@@ -330,7 +330,7 @@ that for other purposes than tagging"""%topdir
             Module.prompt_config()
             print "Checking ...",
             Command("svn co -N %s %s"%(Module.config['svnpath'],topdir),options).run_fatal()
-            Command("svn co -N %s/%s %s/%s"%(Module.config['svnpath'],
+            Command("svn co %s/%s %s/%s"%(Module.config['svnpath'],
                                              Module.config['build'],
                                              topdir,
                                              Module.config['build']),options).run_fatal()
@@ -364,11 +364,13 @@ that for other purposes than tagging"""%topdir
         if not os.path.isdir (self.module_dir):
             raise Exception, 'Cannot find %s - check module name'%self.module_dir
 
-    def init_subdir (self,fullpath):
+    def init_subdir (self,fullpath, deep=False):
         if self.options.verbose:
             print 'Checking for',fullpath
+        opt=""
+        if not deep: opt="-N"
         if not os.path.isdir (fullpath):
-            self.run_fatal("svn update -N %s"%fullpath)
+            self.run_fatal("svn update %s %s"%(opt,fullpath))
 
     def revert_subdir (self,fullpath):
         if self.options.fast_checks:
@@ -385,15 +387,15 @@ that for other purposes than tagging"""%topdir
             return
         if self.options.verbose:
             print 'Updating',fullpath
-        self.run_fatal("svn update -N %s"%fullpath)
+        self.run_fatal("svn update %s"%fullpath)
 
     def init_edge_dir (self):
         # if branch, edge_dir is two steps down
         if hasattr(self,'branch'):
-            self.init_subdir("%s/branches"%self.module_dir)
+            self.init_subdir("%s/branches"%self.module_dir,deep=False)
         elif hasattr(self,'tagname'):
-            self.init_subdir("%s/tags"%self.module_dir)
-        self.init_subdir(self.edge_dir())
+            self.init_subdir("%s/tags"%self.module_dir,deep=False)
+        self.init_subdir(self.edge_dir(),deep=True)
 
     def revert_edge_dir (self):
         self.revert_subdir(self.edge_dir())
@@ -405,15 +407,21 @@ that for other purposes than tagging"""%topdir
         attempt="%s/%s.spec"%(self.edge_dir(),self.name)
         if os.path.isfile (attempt):
             return attempt
-        else:
-            pattern="%s/*.spec"%self.edge_dir()
-            try:
-                return glob(pattern)[0]
-            except:
-                raise Exception, 'Cannot guess specfile for module %s -- pattern was %s'%(self.name,pattern)
+        pattern1="%s/*.spec"%self.edge_dir()
+        level1=glob(pattern1)
+        if level1:
+            return level1[0]
+        pattern2="%s/*/*.spec"%self.edge_dir()
+        level2=glob(pattern2)
+        if level2:
+            return level2[0]
+        raise Exception, 'Cannot guess specfile for module %s -- patterns were %s or %s'%(self.name,pattern1,pattern2)
 
     def all_specnames (self):
-        return glob("%s/*.spec"%self.edge_dir())
+        level1=glob("%s/*.spec"%self.edge_dir())
+        if level1: return level1
+        level2=glob("%s/*/*.spec"%self.edge_dir())
+        return level2
 
     def parse_spec (self, specfile, varnames):
         if self.options.verbose:
@@ -889,7 +897,7 @@ c: cat the current tag file
 n: move to next file"""%locals()
 
             if prompt("Want to review changes on tags files",False):
-                tagsdict = dict ( [ (x, 'todo') for tagsfile in tagsfiles ] )
+                tagsdict = dict ( [ (x, 'todo') for x in tagsfiles ] )
                 default_answer='d'
             else:
                 break
@@ -981,17 +989,24 @@ will be based on latest tag %s and *not* on the current trunk"""%(self.name,bran
         f.write("Branch %s for module %s created (as new trunk) from tag %s\n"%(new_trunk_name,self.name,latest_tag_name))
         f.close()
 
-        # we're done, let's commit the stuff
+        # review the renumbering changes in trunk
         command="svn diff %s"%self.edge_dir()
-        self.run_prompt("Review changes in trunk",command)
-        command="svn copy --file %s %s %s"%(tmp,self.edge_url(),branch_url)
+        self.run_prompt("Review (renumbering) changes in trunk",command)
+        # create branch
+        command="svn copy --file %s %s %s"%(tmp,tag_url,branch_url)
         self.run_prompt("Create branch",command)
+        # commit trunk
         command="svn commit --file %s %s"%(tmp,self.edge_dir())
         self.run_prompt("Commit trunk",command)
+        # create initial tag for the new trunk
         new_tag_url=self.tag_url(spec_dict)
-        command="svn copy --file %s %s %s"%(tmp,self.edge_url(),new_tag_url)
+        command="svn copy --file %s %s %s"%(tmp,tag_url,new_tag_url)
         self.run_prompt("Create initial tag in trunk",command)
         os.unlink(tmp)
+        # print message about SVNBRANCH
+        print """You might now wish to review your tags files
+Please make sure you mention as appropriate 
+%s-SVNBRANCH := %s""" %(self.name,branch_name)
 
 ##############################
 class Package:
@@ -1207,6 +1222,8 @@ class Release:
 class Main:
 
     module_usage="""Usage: %prog [options] module_desc [ .. module_desc ]
+Revision: $Revision$
+
 module-tools : a set of tools to manage subversion tags and specfile
   requires the specfile to either
   * define *version* and *taglevel*
@@ -1332,7 +1349,7 @@ Branches:
                           help="skip safety checks, such as svn updates -- use with care")
 
         # default verbosity depending on function - temp
-        verbose_modes= ['tag','sync']
+        verbose_modes= ['tag', 'sync', 'branch']
         
         if mode not in verbose_modes:
             parser.add_option("-v","--verbose", action="store_true", dest="verbose", default=False,