Mercurial log template and parseLog pattern modification.
Added a template for getting a controlled log; in parseLog, changed the regular expression to match the pattern used in the template (fixes issues 507 and 508).
This commit is contained in:
parent
be39d72d3c
commit
5fc3a987de
1
AUTHORS
1
AUTHORS
@ -14,6 +14,7 @@ Much appreciated contributors (in alphabetical order):
|
|||||||
David Feeney
|
David Feeney
|
||||||
Patrick Georgi <patrick.georgi@coresystems.de>
|
Patrick Georgi <patrick.georgi@coresystems.de>
|
||||||
Ciaran Gultnieks
|
Ciaran Gultnieks
|
||||||
|
Matías Halles <matias@halles.cl>
|
||||||
Julien Issler
|
Julien Issler
|
||||||
Jerry <lxb429@gmail.com> - Chinese translation
|
Jerry <lxb429@gmail.com> - Chinese translation
|
||||||
Benjamin Jorand <benjamin.jorand@gmail.com> - Mercurial support
|
Benjamin Jorand <benjamin.jorand@gmail.com> - Mercurial support
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
- Sort the project list by the display name of the project (issue 477)
|
- Sort the project list by the display name of the project (issue 477)
|
||||||
- Project creation form now has a short description field as well (issue 479)
|
- Project creation form now has a short description field as well (issue 479)
|
||||||
- Add more file extensions supported by our in-tree prettify version (issues 490 and 567)
|
- Add more file extensions supported by our in-tree prettify version (issues 490 and 567)
|
||||||
|
- Improve the parsing of hg's log output (issues 507 and 508)
|
||||||
- Do not clean `<ins>` and `<del>` HTML markup from user input (issue 509)
|
- Do not clean `<ins>` and `<del>` HTML markup from user input (issue 509)
|
||||||
- Improve HTML validation by switching from `strict` to `transitional` DOCTYPE (issue 511)
|
- Improve HTML validation by switching from `strict` to `transitional` DOCTYPE (issue 511)
|
||||||
- Ignore XML parsing problems when trying to retrieve commit messages for svn (issue 518)
|
- Ignore XML parsing problems when trying to retrieve commit messages for svn (issue 518)
|
||||||
|
@ -27,10 +27,13 @@
|
|||||||
*/
|
*/
|
||||||
class IDF_Scm_Mercurial extends IDF_Scm
|
class IDF_Scm_Mercurial extends IDF_Scm
|
||||||
{
|
{
|
||||||
|
protected $hg_log_template;
|
||||||
|
|
||||||
public function __construct($repo, $project=null)
|
public function __construct($repo, $project=null)
|
||||||
{
|
{
|
||||||
$this->repo = $repo;
|
$this->repo = $repo;
|
||||||
$this->project = $project;
|
$this->project = $project;
|
||||||
|
$this->hg_log_template = "'".'changeset: {rev}:{node|short}\nauthor: {author}\ndate: {date|isodate}\nfiles: {files}\n{desc}\n'."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRepositorySize()
|
public function getRepositorySize()
|
||||||
@ -336,10 +339,14 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
if (!$this->isValidRevision($commit)) {
|
if (!$this->isValidRevision($commit)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$tmpl = ($getdiff) ?
|
$tmpl = ($getdiff)
|
||||||
Pluf::f('hg_path', 'hg').' log -p -r %s -R %s' : Pluf::f('hg_path', 'hg').' log -r %s -R %s';
|
? Pluf::f('hg_path', 'hg').' log -p -r %s -R %s --template %s'
|
||||||
|
: Pluf::f('hg_path', 'hg').' log -r %s -R %s --template %s';
|
||||||
$cmd = sprintf($tmpl,
|
$cmd = sprintf($tmpl,
|
||||||
escapeshellarg($commit), escapeshellarg($this->repo));
|
escapeshellarg($commit),
|
||||||
|
escapeshellarg($this->repo),
|
||||||
|
$this->hg_log_template);
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
||||||
self::exec('IDF_Scm_Mercurial::getCommit', $cmd, $out);
|
self::exec('IDF_Scm_Mercurial::getCommit', $cmd, $out);
|
||||||
@ -356,7 +363,7 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
$log[] = $line;
|
$log[] = $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out = self::parseLog($log, 6);
|
$out = self::parseLog($log, 4);
|
||||||
$out[0]->diff = implode("\n", $change);
|
$out[0]->diff = implode("\n", $change);
|
||||||
return $out[0];
|
return $out[0];
|
||||||
}
|
}
|
||||||
@ -381,11 +388,11 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
*/
|
*/
|
||||||
public function getChangeLog($commit='tip', $n=10)
|
public function getChangeLog($commit='tip', $n=10)
|
||||||
{
|
{
|
||||||
$cmd = sprintf(Pluf::f('hg_path', 'hg').' log -R %s -l%s ', escapeshellarg($this->repo), $n, $commit);
|
$cmd = sprintf(Pluf::f('hg_path', 'hg').' log -R %s -l%s --template %s', escapeshellarg($this->repo), $n, $this->hg_log_template, $commit);
|
||||||
$out = array();
|
$out = array();
|
||||||
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
$cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
|
||||||
self::exec('IDF_Scm_Mercurial::getChangeLog', $cmd, $out);
|
self::exec('IDF_Scm_Mercurial::getChangeLog', $cmd, $out);
|
||||||
return self::parseLog($out, 6);
|
return self::parseLog($out, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -421,7 +428,7 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$match = array();
|
$match = array();
|
||||||
if (preg_match('/(\S+)\s*:\s*(.*)/', $line, $match)) {
|
if (preg_match('/^(\S+):\s*(.*)/', $line, $match)) {
|
||||||
$match[1] = strtolower($match[1]);
|
$match[1] = strtolower($match[1]);
|
||||||
if ($match[1] == 'user') {
|
if ($match[1] == 'user') {
|
||||||
$c['author'] = $match[2];
|
$c['author'] = $match[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user