1. petsc
  2. PETSc
  3. petsc

Commits

Satish Balay  committed f4f4884

git change: update configure to support 'git' detection and git 'clone' detection

  • Participants
  • Parent commits 601f6b8
  • Branches master

Comments (0)

Files changed (4)

File config/BuildSystem/config/sourceControl.py

View file
   def setupHelp(self, help):
     import nargs
 
+    help.addArgument('SourceControl', '-with-git=<prog>', nargs.Arg(None, 'git','Specify the Git executable'))
     help.addArgument('SourceControl', '-with-hg=<prog>',  nargs.Arg(None, 'hg', 'Specify the Mercurial executable'))
     help.addArgument('SourceControl', '-with-cvs=<prog>', nargs.Arg(None, 'cvs', 'Specify the CVS executable'))
     help.addArgument('SourceControl', '-with-svn=<prog>', nargs.Arg(None, 'svn', 'Specify the Subversion executable'))
     return
 
+  def configureGit(self):
+    '''Find the Git executable'''
+    if 'with-git' in self.framework.argDB and self.framework.argDB['with-git'] == '0':
+      return
+    self.getExecutable(self.framework.argDB['with-git'], resultName = 'git')
+    if hasattr(self,'git'):
+      try:
+        self.gitversion = self.executeShellCommand(self.git + ' --version')
+      except: pass
+    return
+
   def configureMercurial(self):
     '''Find the Mercurial executable'''
     if 'with-hg' in self.framework.argDB and self.framework.argDB['with-hg'] == '0':
     return
 
   def configure(self):
+    self.executeTest(self.configureGit)
     self.executeTest(self.configureMercurial)
     self.executeTest(self.configureCVS)
     self.executeTest(self.configureSubversion)

File config/PETSc/utilities/petscdir.py

View file
 
   def configureInstallationMethod(self):
     if os.path.exists(os.path.join(self.dir,'bin','maint')):
-      self.logPrint('This is a Mercurial clone')
+      self.logPrint('bin/maint exits. This apppears to be a repository clone')
       self.isClone = 1
-      if os.path.exists(os.path.join(self.dir, '.hg')):
+      if os.path.exists(os.path.join(self.dir, '.git')):
+        if hasattr(self.sourceControl,'git'):
+          self.addDefine('VERSION_GIT','"'+os.popen("cd "+self.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%H").read()+'"')
+          self.addDefine('VERSION_DATE_GIT','"'+os.popen("cd "+self.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%aD").read()+'"')
+        else:
+          self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a Git clone - but git is not found in PATH********\n')
+      elif os.path.exists(os.path.join(self.dir, '.hg')):
         if hasattr(self.sourceControl,'hg'):
           self.addDefine('VERSION_HG','"'+os.popen(self.sourceControl.hg +" -R"+self.dir+" tip --template '{node}'").read()+'"')
           self.addDefine('VERSION_DATE_HG','"'+os.popen(self.sourceControl.hg +" -R"+self.dir+" tip --template '{date|date}'").read()+'"')
-          # Check version & date for buildsystem aswell
-          bs_dir = os.path.join(self.dir,'config','BuildSystem')
-          if os.path.exists(os.path.join(bs_dir,'.hg')):
-            self.addDefine('VERSION_BS_HG','"'+os.popen(self.sourceControl.hg +" -R"+bs_dir+" tip --template '{node}'").read()+'"')
-            self.addDefine('VERSION_BS_DATE_HG','"'+os.popen(self.sourceControl.hg + " -R"+bs_dir+" tip --template '{date|date}'").read()+'"')
         else:
           self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a mercurial clone - but hg is not found in PATH********\n')
       else:
-        self.logPrint('This Mercurial clone is obtained as a tarball as .hg dir does not exist!')
+        self.logPrint('This repository clone is obtained as a tarball as neither .hg nor .git dirs exist!')
     else:
-      self.logPrint('This is a tarball installation')
-      self.isClone = 0
-    if self.isClone and not os.path.exists(os.path.join(self.dir, 'bin', 'maint')):
-      raise RuntimeError('Your petsc-dev directory is broken, remove the entire directory and start all over again')
+      if os.path.exists(os.path.join(self.dir, '.git')) or os.path.exists(os.path.join(self.dir, '.hg')):
+        raise RuntimeError('Your petsc-dev directory is broken, remove the entire directory and start all over again')
+      else:
+        self.logPrint('This is a tarball installation')
+        self.isClone = 0
     return
 
   def configure(self):

File config/cmakegen.py

View file
   if MISTAKES:
     for m in MISTAKES:
       log.write(m + '\n')
-    raise RuntimeError('PETSc makefiles contain mistakes or files are missing on filesystem.\n%s\nPossible reasons:\n\t1. Files were deleted locally, try "hg update".\n\t2. Files were deleted from mercurial, but were not removed from makefile. Send mail to petsc-maint@mcs.anl.gov.\n\t3. Someone forgot "hg add" new files. Send mail to petsc-maint@mcs.anl.gov.' % ('\n'.join(MISTAKES)))
+    raise RuntimeError('PETSc makefiles contain mistakes or files are missing on filesystem.\n%s\nPossible reasons:\n\t1. Files were deleted locally, try "hg revert filename" or "git checkout filename".\n\t2. Files were deleted from repository, but were not removed from makefile. Send mail to petsc-maint@mcs.anl.gov.\n\t3. Someone forgot to "add" new files to the repository. Send mail to petsc-maint@mcs.anl.gov.' % ('\n'.join(MISTAKES)))
 
 if __name__ == "__main__":
   import optparse

File config/configure.py

View file
 
 def chkdosfiles():
   if not os.path.exists('/usr/bin/cygcheck.exe'): return
-  (status,output) = commands.getstatusoutput('hg showconfig paths.default')
-  if not status and output: return
+  if os.path.exists('.hg'):
+    (status,output) = commands.getstatusoutput('hg showconfig paths.default')
+    if not status and output: return
+  if os.path.exists('.git'):
+    (status,output) = commands.getstatusoutput('git rev-parse')
+    if not status: return
   # cygwin - but not a hg clone - so check files in bin dir
   (status,output) = commands.getstatusoutput('file bin/*')
   if status: