mailr23344 - in /branches/frame_order_cleanup: ./ version.py


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

Header


Content

Posted by edward on May 22, 2014 - 18:12:
Author: bugman
Date: Thu May 22 18:12:52 2014
New Revision: 23344

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

........
  r23343 | bugman | 2014-05-22 18:10:32 +0200 (Thu, 22 May 2014) | 4 lines
  
  Added git-svn support for the relax version information module.
  
  This allows the subversion revision number and repository URL to be 
displayed on program startup, so
  that it is stored in log files.  This is very useful for debugging purposes.
........

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

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu May 22 18:12:52 2014
@@ -1 +1 @@
-/trunk:1-23340
+/trunk:1-23343

Modified: branches/frame_order_cleanup/version.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/version.py?rev=23344&r1=23343&r2=23344&view=diff
==============================================================================
--- branches/frame_order_cleanup/version.py     (original)
+++ branches/frame_order_cleanup/version.py     Thu May 22 18:12:52 2014
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2009-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2009-2014 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -27,6 +27,7 @@
 
 # Python module imports.
 from os import F_OK, access, sep
+from re import search
 PIPE, Popen = None, None
 if dep_check.subprocess_module:
     from subprocess import PIPE, Popen
@@ -46,32 +47,36 @@
     """
 
     # Does the base directory exist (i.e. is this a checked out copy).
-    if not access(status.install_path+sep+'.svn', F_OK):
+    if not access(status.install_path+sep+'.svn', F_OK) and not 
access(status.install_path+sep+'.git', F_OK):
         return
 
     # Python 2.3 and earlier.
     if Popen == None:
         return
 
-    # Try to run 'svn info'.
+    # 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()
 
-    # Errors.
-    if pipe.stderr.readlines():
-        return
+            # Split up the line.
+            row = line.split()
 
-    # Loop over the output lines.
-    for line in pipe.stdout.readlines():
-        # Decode Python 3 byte arrays.
-        if hasattr(line, 'decode'):
-            line = line.decode()
+            # The revision.
+            if len(row) and row[0] == 'Revision:':
+                return str(row[1])
 
-        # 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('git svn find-rev $(git rev-parse HEAD)', 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():
+            if search('^[0-9]', line):
+                return str(line[:-1])
 
 
 def url():
@@ -82,32 +87,36 @@
     """
 
     # Does the base directory exist (i.e. is this a checked out copy).
-    if not access(status.install_path+sep+'.svn', F_OK):
+    if not access(status.install_path+sep+'.svn', F_OK) and not 
access(status.install_path+sep+'.git', F_OK):
         return
 
     # Python 2.3 and earlier.
     if Popen == None:
         return
 
-    # Try to run 'svn info'.
+    # 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()
 
-    # Errors.
-    if pipe.stderr.readlines():
-        return
+            # Split up the line.
+            row = line.split()
 
-    # Loop over the output lines.
-    for line in pipe.stdout.readlines():
-        # Decode Python 3 byte arrays.
-        if hasattr(line, 'decode'):
-            line = line.decode()
+            # The revision.
+            if len(row) and row[0] == 'URL:':
+                return str(row[1])
 
-        # Split up the line.
-        row = line.split()
-
-        # The revision.
-        if len(row) and row[0] == 'URL:':
-            return str(row[1])
+    # Try git-svn, reading the output if there are no errors.
+    pipe = Popen('git svn info --url', 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():
+            if search('^svn', line):
+                return str(line[:-1])
 
 
 def version_full():




Related Messages


Powered by MHonArc, Updated Thu May 22 18:20:02 2014