Modify

Ticket #195 (closed defect: fixed)

Opened 4 years ago

Last modified 2 years ago

SvnLastRevisionTask fails if Subversion is localized (Spanish)

Reported by: penyaskito Owned by: arnoschn
Priority: major Milestone: 2.3.1
Component: phing-tasks-ext Version: 2.3.0
Keywords: Cc:

Description

SvnLastRevisionTask fails if Subversion is localized, at least in Spanish. The output of svn info is:

Revisión: 10

but Phing expects to be:

Rev: 10

Attachments

Change History

comment:1 Changed 4 years ago by penyaskito

Sorry, the line from svn status that we want is the last changed revisión in the current dir, so respectively:

Last Changed Rev: 10
Revisión del último cambio: 10

comment:2 Changed 4 years ago by penyaskito

This wasn't as easy as I thought because of the unicode characters (ó) in the output. RegExps seems to not work fine with Unicode characters, after testing with:

/Rev[.*]?/u'

Revisión doesn't match.

After searching a lot, the easiest way is removing that characters before the regexp. If anyone has not a better solution, I'll do this way. Anyway, this should be problematic with more languages.

comment:3 Changed 4 years ago by mrook

  • Status changed from new to closed
  • Resolution set to wontfix

I don't think we really want to adapt Phing to the large number of languages SVN supports, closing for now.

comment:4 Changed 4 years ago by arnoschn

Hi guys,

I have a fix for the localization problem, since we came across the same problem in Xinc:

SvnLastRevisionTask.php

....

function main()
	{
		$this->setup('info');
		
		/**
		 * run in xml mode, allows us to retrieve workingcopy info in 
		 * a unified xml format, so we dont have to fight with internationalized
		 * versions of svn info output
		 */
		$output = $this->run(array('--xml'));
		try 
		{
			$xml = new SimpleXMLElement($output);
			/**
			 * walk the xml towards the last commit element
			 */
			$commits = $xml->xpath('/info/entry/commit');
			if (count($commits)>0) {
				$commit = $commits[0];
				/**
				 * get the attributes of the commit element
				 */
				$attributes = $commit->attributes();
				$this->project->setProperty($this->getPropertyName(), $attributes->revision);
			} else {
				throw new BuildException("Failed to parse the output of 'svn info'.");
			}
			
		}
		catch (Exception $e)
		{
			throw new BuildException("Failed to parse the output of 'svn info'.");
		}
	}
....

If you agree I can commit the change into the trunk. Dont know if its interesting to apply the patch to older versions?

Arno

comment:5 Changed 4 years ago by arnoschn

  • Status changed from closed to reopened
  • Resolution wontfix deleted

comment:6 Changed 4 years ago by arnoschn

  • Owner changed from hans to arnoschn
  • Status changed from reopened to new

comment:7 Changed 4 years ago by arnoschn

(In [335]) Refs #195: switching to parse xml output from svn info (svn info --xml). more reliable than any localized string output.

comment:8 Changed 4 years ago by arnoschn

(In [335]) Refs #195: switching to parse xml output from svn info (svn info --xml). more reliable than any localized string output.

comment:9 Changed 4 years ago by arnoschn

  • Status changed from new to closed
  • Resolution set to fixed

comment:10 Changed 2 years ago by anonymous

I'm using Phing version 2.3.3 but i still don't have the fix. In my SvnLastRevisionTask I have

 function main()
        {
                $this->setup('info');

                $output = $this->run();

                if (preg_match('/Rev:[\s]+([\d]+)/', $output, $matches))
                {
                        $this->project->setProperty($this->getPropertyName(), $matches[1]);
                }
                else
                {
                        throw new BuildException("Failed to parse the output of 'svn info'.");
                }
        }

Isn't this fix supposed to be in ping 2.3.1 ?

comment:11 Changed 2 years ago by mrook

The fix didnt make it into the 2.3 releases, it is included in the 2.4.0 release candidates.

View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.