mailr23375 - in /branches/frame_order_cleanup: ./ data_store/__init__.py info.py version.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on May 23, 2014 - 14:13:
Author: bugman
Date: Fri May 23 14:13:10 2014
New Revision: 23375

URL: http://svn.gna.org/viewcvs/relax?rev=23375&view=rev
Log:
Merged revisions 23373-23374 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r23373 | bugman | 2014-05-23 11:25:34 +0200 (Fri, 23 May 2014) | 7 lines
  
  Speed up for the version module when using a repository copy of the code.
  
  The repository revision and URL and now stored as module variables, so that 
the 'svn info' and
  'git svn info' commands are only run twice, once for the revision() 
function and once for the url()
  function.
........
  r23374 | bugman | 2014-05-23 12:11:36 +0200 (Fri, 23 May 2014) | 15 lines
  
  Large speed up for the relax start up times for svn and git-svn copies of 
the relax repository.
  
  The 'svn info' and 'git svn info' commands are now only executed once when 
the version module is
  first imported.  The revision() and url() functions have been merged into 
the repo_info() function
  and this is called when the module is imported.  This repo_info() function 
stores the repository
  revision and URL as the version.repo_revision and version.repo_url module 
variables.  It also
  catches if these variables are already set, so that multiple imports of the 
module do not cause the
  repository information to be looked up each time.
  
  Previously the revision() and url() functions where called every time a 
relax state or result file
  was created, hence for repository copies the 'svn info' or 'git svn info' 
commands were being called
  each time.  The functions were also called for each interpreter object 
instantiated, and for each
  import of the version module.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/data_store/__init__.py
    branches/frame_order_cleanup/info.py
    branches/frame_order_cleanup/version.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May 23 14:13:10 2014
@@ -1 +1 @@
-/trunk:1-23370
+/trunk:1-23374

Modified: branches/frame_order_cleanup/data_store/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/data_store/__init__.py?rev=23375&r1=23374&r2=23375&view=diff
==============================================================================
--- branches/frame_order_cleanup/data_store/__init__.py (original)
+++ branches/frame_order_cleanup/data_store/__init__.py Fri May 23 14:13:10 
2014
@@ -597,12 +597,10 @@
         top_element.setAttribute('version', version.version)
         top_element.setAttribute('time', asctime())
         top_element.setAttribute('file_version', "2")
-        rev = version.revision()
-        if rev:
-            top_element.setAttribute('revision', rev)
-        url = version.url()
-        if url:
-            top_element.setAttribute('url', url)
+        if version.repo_revision:
+            top_element.setAttribute('revision', version.repo_revision)
+        if version.repo_url:
+            top_element.setAttribute('url', version.repo_url)
 
         # Add all objects in the data store base object to the XML element.
         if all:

Modified: branches/frame_order_cleanup/info.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/info.py?rev=23375&r1=23374&r2=23375&view=diff
==============================================================================
--- branches/frame_order_cleanup/info.py        (original)
+++ branches/frame_order_cleanup/info.py        Fri May 23 14:13:10 2014
@@ -47,7 +47,7 @@
 
 # relax module imports.
 from status import Status; status = Status()
-from version import revision, url, version, version_full
+from version import repo_revision, repo_url, version, version_full
 
 
 def print_sys_info():
@@ -283,8 +283,8 @@
 
         # Program name and version - subversion code.
         if version == 'repository checkout':
-            text = "%s %s r%s" % (self.title, self.version, revision())
-            text2 = "%s" % (url())
+            text = "%s %s r%s" % (self.title, self.version, repo_revision)
+            text2 = "%s" % (repo_url)
             intro_string = intro_string + self.centre(text, 
status.text_width) + '\n' + self.centre(text2, status.text_width) + '\n\n'
 
         # Program name and version - official releases.

Modified: branches/frame_order_cleanup/version.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/version.py?rev=23375&r1=23374&r2=23375&view=diff
==============================================================================
--- branches/frame_order_cleanup/version.py     (original)
+++ branches/frame_order_cleanup/version.py     Fri May 23 14:13:10 2014
@@ -37,102 +37,55 @@
 
 
 version = "repository checkout"
+repo_revision = None
+repo_url = None
 
 
-def revision():
-    """Attempt to retrieve the SVN revision number, if this is a checked out 
copy.
+def repo_information():
+    """Determine the subversion revision number and URL from svn or git-svn 
copies of the repository."""
 
-    @return:    The SVN revision number, or None if unsuccessful.
-    @rtype:     None or str
-    """
+    # The global variables
+    global repo_revision
+    global repo_url
 
-    # Does the base directory exist (i.e. is this a checked out copy).
-    if not access(status.install_path+sep+'.svn', F_OK) and not 
access(status.install_path+sep+'.git', F_OK):
+    # The variables are already set, so do nothing.
+    if repo_revision != None or repo_url != None:
         return
 
     # Python 2.3 and earlier.
     if Popen == None:
         return
 
-    # Try to run 'svn info', reading the output if there are no errors.
-    pipe = Popen('svn info %s' % status.install_path, shell=True, 
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
-    if not pipe.stderr.readlines():
-        # Loop over the output lines.
-        for line in pipe.stdout.readlines():
-            # Decode Python 3 byte arrays.
-            if hasattr(line, 'decode'):
-                line = line.decode()
+    # The command to use.
+    cmd = None
+    if access(status.install_path+sep+'.svn', F_OK):
+        cmd = 'svn info %s' % status.install_path
+    elif access(status.install_path+sep+'.git', F_OK):
+        cmd = 'cd %s; git svn info' % status.install_path
 
-            # Split up the line.
-            row = line.split()
-
-            # The revision.
-            if len(row) and row[0] == 'Revision:':
-                return str(row[1])
-
-    # Try git-svn, reading the output if there are no errors.
-    pipe = Popen('cd %s; git svn info' % status.install_path, shell=True, 
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
-    if not pipe.stderr.readlines():
-        # Loop over the output lines.
-        for line in pipe.stdout.readlines():
-            # Decode Python 3 byte arrays.
-            if hasattr(line, 'decode'):
-                line = line.decode()
-
-            # Split up the line.
-            row = line.split()
-
-            # The revision.
-            if len(row) and row[0] == 'Revision:':
-                return str(row[1])
-
-
-def url():
-    """Attempt to retrieve the SVN URL, if this is a checked out copy.
-
-    @return:    The SVN URL, or None if unsuccessful.
-    @rtype:     None or str
-    """
-
-    # Does the base directory exist (i.e. is this a checked out copy).
-    if not access(status.install_path+sep+'.svn', F_OK) and not 
access(status.install_path+sep+'.git', F_OK):
+    # Not a repository copy, so do nothing.
+    if not cmd:
         return
 
-    # Python 2.3 and earlier.
-    if Popen == None:
-        return
+    # Open the pipe and run the command.
+    pipe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, 
close_fds=False)
 
-    # Try to run 'svn info', reading the output if there are no errors.
-    pipe = Popen('svn info %s' % status.install_path, shell=True, 
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
-    if not pipe.stderr.readlines():
-        # Loop over the output lines.
-        for line in pipe.stdout.readlines():
-            # Decode Python 3 byte arrays.
-            if hasattr(line, 'decode'):
-                line = line.decode()
+    # Loop over the output lines.
+    for line in pipe.stdout.readlines():
+        # Decode Python 3 byte arrays.
+        if hasattr(line, 'decode'):
+            line = line.decode()
 
-            # Split up the line.
-            row = line.split()
+        # Split up the line.
+        row = line.split()
 
-            # The revision.
-            if len(row) and row[0] == 'URL:':
-                return str(row[1])
+        # Store revision as the global variable.
+        if len(row) and row[0] == 'Revision:':
+            repo_revision = str(row[1])
 
-    # Try git-svn, reading the output if there are no errors.
-    pipe = Popen('cd %s; git svn info' % status.install_path, shell=True, 
stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False)
-    if not pipe.stderr.readlines():
-        # Loop over the output lines.
-        for line in pipe.stdout.readlines():
-            # Decode Python 3 byte arrays.
-            if hasattr(line, 'decode'):
-                line = line.decode()
-
-            # Split up the line.
-            row = line.split()
-
-            # The revision.
-            if len(row) and row[0] == 'URL:':
-                return str(row[1])
+        # Store URL as the global variable.
+        if len(row) and row[0] == 'URL:':
+            repo_url = str(row[1])
 
 
 def version_full():
@@ -147,15 +100,19 @@
 
     # Repository version.
     if ver == 'repository checkout':
-        # Get the SVN revision and URL.
-        svn_rev = revision()
-        svn_url = url()
+        # The global variables
+        global repo_revision
+        global repo_url
 
         # Change the version string.
-        if svn_rev:
-            ver = version + " r" + svn_rev
-        if svn_url:
-            ver = ver + " " + svn_url
+        if repo_revision != None:
+            ver = version + " r" + repo_revision
+        if repo_url != None:
+            ver = ver + " " + repo_url
 
     # Return the version.
     return ver
+
+
+# Fetch the repository information, if present.
+repo_information()




Related Messages


Powered by MHonArc, Updated Fri May 23 14:40:02 2014