Author: bugman Date: Fri Oct 9 18:47:46 2009 New Revision: 9707 URL: http://svn.gna.org/viewcvs/relax?rev=9707&view=rev Log: Merged revisions 9706 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r9706 | bugman | 2009-10-09 18:47:13 +0200 (Fri, 09 Oct 2009) | 3 lines Added a function to get the SVN URL. ........ Modified: branches/bmrb/ (props changed) branches/bmrb/version.py Propchange: branches/bmrb/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Oct 9 18:47:46 2009 @@ -1,1 +1,1 @@ -/1.3:1-9703 +/1.3:1-9706 Modified: branches/bmrb/version.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/version.py?rev=9707&r1=9706&r2=9707&view=diff ============================================================================== --- branches/bmrb/version.py (original) +++ branches/bmrb/version.py Fri Oct 9 18:47:46 2009 @@ -58,3 +58,31 @@ # The revision. if row[0] == 'Revision:': return row[1] + + +def get_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('.svn', F_OK): + return + + # Try to run 'svn info'. + pipe = Popen('svn info', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) + + # Errors. + if pipe.stderr.readlines(): + return + + # Loop over the output lines. + for line in pipe.stdout.readlines(): + # Split up the line. + row = split(line) + + # The revision. + if row[0] == 'URL:': + return row[1]