* code for task #3100.

This commit is contained in:
wangyidong
2017-08-21 16:00:42 +08:00
parent 2e798743cf
commit fa707a1464
4 changed files with 36 additions and 14 deletions
+2 -1
View File
@@ -18,7 +18,8 @@ $config->git->encodings = 'utf-8';
$config->git->client = '';
$i = 1;
$config->git->repos[$i]['path'] = '';
$config->git->repos[$i]['path'] = '';
$config->git->repos[$i]['encoding'] = 'utf-8';
/*
$i ++;
+26 -6
View File
@@ -426,13 +426,23 @@ class gitModel extends model
exec("{$this->client} config core.quotepath false");
$subPath = substr($path, strlen($repo->path));
if($subPath{0} == '/' or $subPath{0} == '\\') $subPath = substr($subPath, 1);
$encodings = explode(',', $this->config->git->encodings);
foreach($encodings as $encoding)
{
$encoding = trim($encoding);
if($encoding == 'utf-8') continue;
$subPath = helper::convertEncoding($subPath, 'utf-8', $encoding);
if($subPath) break;
}
exec("$this->client rev-list -n 2 $revision -- $subPath", $lists);
if(count($lists) == 2) list($nowRevision, $preRevision) = $lists;
$cmd = "$this->client diff $preRevision $nowRevision -- $subPath";
$cmd = "$this->client diff $preRevision $nowRevision -- $subPath 2>&1";
$diff = `$cmd`;
$encodings = isset($repo->encodings) ? $repo->encodings : $this->config->svn->encodings;
if($encodings or $encodings != 'utf-8') $diff = helper::convertEncoding($diff, $encodings);
$encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8';
if($encoding and $encoding != 'utf-8') $diff = helper::convertEncoding($diff, $encoding);
return $diff;
}
@@ -457,13 +467,23 @@ class gitModel extends model
$subPath = substr($path, strlen($repo->path));
if($subPath{0} == '/' or $subPath{0} == '\\') $subPath = substr($subPath, 1);
$encodings = explode(',', $this->config->git->encodings);
foreach($encodings as $encoding)
{
$encoding = trim($encoding);
if($encoding == 'utf-8') continue;
$subPath = helper::convertEncoding($subPath, 'utf-8', $encoding);
if($subPath) break;
}
chdir($repo->path);
exec("{$this->client} config core.quotepath false");
$cmd = "$this->client show $revision:$subPath";
$cmd = "$this->client show $revision:$subPath 2>&1";
$code = `$cmd`;
$encodings = isset($repo->encodings) ? $repo->encodings : $this->config->git->encodings;
if($encodings or $encodings != 'utf-8') $code = helper::convertEncoding($code, $encodings);
$encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8';
if($encoding and $encoding != 'utf-8') $code = helper::convertEncoding($code, $encoding);
return $code;
}
+1
View File
@@ -21,6 +21,7 @@ $config->svn->client = '';
$i = 1;
$config->svn->repos[$i]['path'] = '';
$config->svn->repos[$i]['encoding'] = 'utf-8';
$config->svn->repos[$i]['username'] = '';
$config->svn->repos[$i]['password'] = '';
+7 -7
View File
@@ -388,7 +388,7 @@ class svnModel extends model
foreach($encodings as $encoding)
{
if($encoding == 'utf-8') continue;
$result = @iconv($encoding, 'utf-8', $comment);
$result = helper::convertEncoding($comment, $encoding)
if($result) return $result;
}
@@ -417,11 +417,11 @@ class svnModel extends model
$url = str_replace('%2F', '/', urlencode($url));
$url = str_replace('%3A', ':', $url);
$cmd = $this->client . " diff -r $oldRevision:$revision $url";
$cmd = $this->client . " diff -r $oldRevision:$revision $url 2>&1";
$diff = `$cmd`;
$encodings = isset($repo->encodings) ? $repo->encodings : $this->config->svn->encodings;
if($encodings or $encodings != 'utf-8') $diff = helper::convertEncoding($diff, $encodings);
$encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8';
if($encoding and $encoding != 'utf-8') $diff = helper::convertEncoding($diff, $encoding);
return $diff;
}
@@ -447,11 +447,11 @@ class svnModel extends model
$url = str_replace('%2F', '/', urlencode($url));
$url = str_replace('%3A', ':', $url);
$cmd = $this->client . " cat $url@$revision";
$cmd = $this->client . " cat $url@$revision 2>&1";
$code = `$cmd`;
$encodings = isset($repo->encodings) ? $repo->encodings : $this->config->svn->encodings;
if($encodings or $encodings != 'utf-8') $code = helper::convertEncoding($code, $encodings);
$encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8';
if($encoding and $encoding != 'utf-8') $code = helper::convertEncoding($code, $encoding);
return $code;
}