From: Baris Metin Date: Wed, 11 May 2011 20:22:15 +0000 (-0400) Subject: fix tagging for modules in subdirs. X-Git-Tag: 5.0-rc23~53 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ed9ed274f14942da8c0c9737b64ab401f543d4c1;p=build.git fix tagging for modules in subdirs. --- diff --git a/module-tools.py b/module-tools.py index e7c17c16..6d8ade41 100755 --- a/module-tools.py +++ b/module-tools.py @@ -173,7 +173,7 @@ class SvnRepository: for line in out.split('\n'): if line.startswith("Repository Root:"): root = line.split()[2].strip() - return "%s/%s" % (root, self.name()) + return "%s/%s" % (root, self.pathname()) @classmethod def checkout(cls, remote, local, options, recursive=False): @@ -266,7 +266,7 @@ class GitRepository: def gitweb(self): c = Command("git show | grep commit | awk '{print $2;}'", self.options) out = self.__run_in_repo(c.output_of).strip() - return "http://git.onelab.eu/?p=%s.git;a=commit;h=%s" % (self.name(), out) + return "http://git.onelab.eu/?p=%s.git;a=commit;h=%s" % (self.pathname(), out) def repo_root(self): c = Command("git remote show origin", self.options) @@ -473,7 +473,8 @@ class Module: def __init__ (self,module_spec,options): # parse module spec - self.name, branch_or_tagname, module_type = self.parse_module_spec(module_spec) + self.pathname, branch_or_tagname, module_type = self.parse_module_spec(module_spec) + self.name = os.path.basename(self.pathname) if module_type == "branch": self.branch=branch_or_tagname @@ -484,7 +485,7 @@ class Module: self.name = svn_to_git_name(self.name) self.options=options - self.module_dir="%s/%s"%(options.workdir,self.name) + self.module_dir="%s/%s"%(options.workdir,self.pathname) self.repository = None self.build = None @@ -509,11 +510,11 @@ class Module: def friendly_name (self): if hasattr(self,'branch'): - return "%s:%s"%(self.name,self.branch) + return "%s:%s"%(self.pathname,self.branch) elif hasattr(self,'tagname'): - return "%s@%s"%(self.name,self.tagname) + return "%s@%s"%(self.pathname,self.tagname) else: - return self.name + return self.pathname @classmethod def git_remote_dir (cls, name): @@ -621,8 +622,8 @@ that for other purposes than tagging""" % options.workdir print 'Checking for',self.module_dir if not os.path.isdir (self.module_dir): - if Repository.has_moved_to_git(self.name, Module.config): - self.repository = GitRepository.checkout(self.git_remote_dir(self.name), + if Repository.has_moved_to_git(self.pathname, Module.config): + self.repository = GitRepository.checkout(self.git_remote_dir(self.pathname), self.module_dir, self.options) else: @@ -634,7 +635,7 @@ that for other purposes than tagging""" % options.workdir self.repository = Repository(self.module_dir, self.options) if self.repository.type == "svn": # check if module has moved to git - if Repository.has_moved_to_git(self.name, Module.config): + if Repository.has_moved_to_git(self.pathname, Module.config): Command("rm -rf %s" % self.module_dir, self.options).run_silent() self.init_module_dir() # check if we have the required branch/tag @@ -689,7 +690,7 @@ that for other purposes than tagging""" % options.workdir if level2: return level2[0] - raise Exception, 'Cannot guess specfile for module %s -- patterns were %s or %s'%(self.name,pattern1,pattern2) + raise Exception, 'Cannot guess specfile for module %s -- patterns were %s or %s'%(self.pathname,pattern1,pattern2) def all_specnames (self): level1=glob("%s/*.spec" % self.module_dir) @@ -858,7 +859,7 @@ that for other purposes than tagging""" % options.workdir # brute-force : change uncommented lines that define -SVNPATH else: if self.options.verbose: - print 'Searching for -SVNPATH or -GITPATH lines referring to /%s/\n\tin %s .. '%(self.name,tagsfile), + print 'Searching for -SVNPATH or -GITPATH lines referring to /%s/\n\tin %s .. '%(self.pathname,tagsfile), pattern="\A\s*%s-(SVNPATH|GITPATH)\s*(=|:=)\s*(?P[^\s]+)/%s[^\s]+"\ %(self.name,self.name) matcher_module=re.compile(pattern) @@ -867,7 +868,7 @@ that for other purposes than tagging""" % options.workdir if attempt: if line.find("-GITPATH") >= 0: modulepath = "%s-GITPATH"%self.name - replacement = "%-32s:= %s/%s.git@%s\n"%(modulepath,attempt.group('url_main'),self.name,newname) + replacement = "%-32s:= %s/%s.git@%s\n"%(modulepath,attempt.group('url_main'),self.pathname,newname) else: modulepath = "%s-SVNPATH"%self.name replacement = "%-32s:= %s/%s/tags/%s\n"%(modulepath,attempt.group('url_main'),self.name,newname) @@ -944,7 +945,7 @@ that for other purposes than tagging""" % options.workdir # checking for diffs diff_output = self.repository.diff_with_tag(old_tag_name) if len(diff_output) == 0: - if not prompt ("No pending difference in module %s, want to tag anyway"%self.name,False): + if not prompt ("No pending difference in module %s, want to tag anyway"%self.pathname,False): return # side effect in trunk's specfile @@ -1094,7 +1095,7 @@ n: move to next file"""%locals() if self.options.list: if diff_output: - print self.name + print self.pathname else: thename=self.friendly_name() do_print=False