svn: /web/doc-editor/trunk/php/ File.php
| From: | Yannick Torres | Date: | Fri, 07 May 2010 22:26:07 +0000 |
| Subject: | svn: /web/doc-editor/trunk/php/ File.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-1840@lists.php.net to get a copy of this message | ||
yannick Fri, 07 May 2010 22:26:07 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=299130
Log:
When we display the diff of a patch for a new file, we display only 'This is a new file.'
Changed paths:
U web/doc-editor/trunk/php/File.php
Modified: web/doc-editor/trunk/php/File.php
===================================================================
--- web/doc-editor/trunk/php/File.php 2010-05-07 22:21:04 UTC (rev 299129)
+++ web/doc-editor/trunk/php/File.php 2010-05-07 22:26:07 UTC (rev 299130)
@@ -358,6 +358,8 @@
$appConf = $am->appConf;
$project = $am->project;
+ $output = array();
+
if( $type == 'vcs' ) {
$output = VCSFactory::getInstance()->diff(
@@ -368,19 +370,24 @@
} elseif( $type == 'file' || $type == 'patch' ) {
$ext = ( $options['type'] == 'patch' ) ? '.' .
$options['uniqID'] . '.patch' : '.new';
- $cmd = 'cd
'.$appConf[$project]['vcs.path'].$this->lang.$this->path.'; '
- .'diff -u '.$this->name.' '.$this->name.$ext;
+
+ // If this patch is for new file, we only display "This is a new file."
+ if( $type == 'patch' &&
!is_file($appConf[$project]['vcs.path'].$this->lang.$this->path.$this->name) ) {
+ return '<div style="size: 10px;
text-align:center;margin-top:10px;">This is a new file.</div>';
+ } else {
- $output = array();
- $trial_threshold = 3;
- while ($trial_threshold-- > 0) {
- $output = array();
- exec($cmd, $output);
- if (strlen(trim(implode('', $output))) != 0) break;
+ $cmd = 'cd
'.$appConf[$project]['vcs.path'].$this->lang.$this->path.'; '
+ .'diff -u '.$this->name.' '.$this->name.$ext;
+
+ $trial_threshold = 3;
+ while ($trial_threshold-- > 0) {
+ $output = array();
+ exec($cmd, $output);
+ if (strlen(trim(implode('', $output))) != 0) break;
+ }
}
}
-
$output = htmlentities(join("\n", $output), ENT_QUOTES, 'UTF-8');
$match = array();
preg_match_all('/@@([^@]+)@@(.*?)(?=@@|\z)/si', $output, $match);