[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Getting HEAD revision number from a URL

From: <pkahn_at_connected.com>
Date: 2004-10-27 01:39:50 CEST

If you are trying to convert HEAd into a number, why not do this
svn log --revision HEAD URL

I do this via the WebDav method...

I have a python script that does just that so I can get HEAD and flip it
into a number for later use...

    def __executeSVN(self, argList, failureText):
        """
        __executeSVN(argList, failureText) - executes svn with
            argList of arguments. Users failureText to search
            log for issues. failureText may be REGEX
        """
        # Prep - generate temp file
        status = True
        logPath = CCuFile.getTempPath()
        
        action = 'svn %s >> %s 2>&1' % (' '.join(argList), logPath)
        # Execute
        os.system(action)
        
        # Check - Log File
        if (not os.path.exists(logPath) or not os.path.isfile(logPath)):
            raise SCMException('log file [%s] for command [%s] not
generated.' % \
                (logPath, action) )
                
        # Process - Log File
        logFp = open(logPath,'r')
        try:
            for line in logFp.readlines():
                if (re.search(failureText, line, re.I)):
                    status = False
        finally:
            logFp.close()

        if status:
            os.unlink(logPath)
            logPath = None
            
        return (status, logPath)

    def convertHeadToRevision(self, reposRootUrl):
        """
        convertHeadToRevision(reposRootUrl) - converts head
        to revision #. Only works if repository root url is
        used because the head can be changed in any branch beneath
        it. If the branch queired isn't the head, the result is
        blank
        """
        errors = r'-+'
        (result, logPath) = self.__executeSVN(['log --revision
HEAD',reposRootUrl], errors)
        if result:
            raise SCMException('no data returned. %s is not valid URL or
repos root' % reposRootUrl)

        fp = open(logPath, 'r')
        revision = None
        try:
            for line in fp.readlines():
                match = re.compile(r'^r([0-9]+)').match(line)
                if None != match:
                    revision = match.group(1)
        finally:
            fp.close()
            os.unlink(logPath)
        return revision

-----Original Message-----
From: Krebs, Steven [mailto:steven.krebs@intel.com]
Sent: Tuesday, October 26, 2004 6:22 PM
To: Scott Palmer
Cc: Subversion Users
Subject: RE: Getting HEAD revision number from a URL

When I do svn log -q URI I have to have a working copy, I would like to
query various repositories without having to have a local working copy.

In my case I have 4 separate repositories (source, eval, deploy and
docs). Each over a Gigabyte of data, and I want a script to determine
what the current HEAD revision of each is without having a working copy.

C:\>svn log -q -v HEAD svn://itplab-svnsvr.dp.intel.com/source
svn: '.' is not a working copy

C:\>svn log -q -v HEAD svn://itplab-svnsvr.dp.intel.com/eval
svn: '.' is not a working copy

C:\>svn log -q -v HEAD svn://itplab-svnsvr.dp.intel.com/deploy
svn: '.' is not a working copy

C:\>svn log -q -v HEAD svn://itplab-svnsvr.dp.intel.com/docs
svn: '.' is not a working copy

Steve

-----Original Message-----
From: Scott Palmer [mailto:scott.palmer@2connected.org]
Sent: Tuesday, October 26, 2004 5:05 AM
To: Subversion Users
Subject: Re: Getting HEAD revision number from a URL

I just wanted this for ease of use. E.g. why have svnversion when you
can parse the output of 'svn info' ? Seems the same reasons would
make 'svnversion URL' preferable to parsing the output of 'svn log -q
URL'.

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Oct 27 01:41:04 2004

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.