[MediaWiki-commits] [Gerrit] Allow viewing all ref type commits - change (phabricator/phabricator)

2016-04-20 Thread Paladox (Code Review)
Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284517

Change subject: Allow viewing all ref type commits
..

Allow viewing all ref type commits

This allows us to view ref types such as refs/changes and refs/meta since
we use gerrit where we have the repo's but we carn't currently view all
commit since some are open and stored in refs/changes which phabricator
dosen't view yet, with this patch it lets us view those commits.

Change-Id: I7f8205651f717e98271f6f18c37730955f953d68
---
M src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
M src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
2 files changed, 70 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/phabricator/phabricator 
refs/changes/17/284517/1

diff --git 
a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php 
b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
index 1f17f5f..08d9e2d 100644
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
@@ -43,6 +43,10 @@
   $prefixes[] = 'refs/tags/';
 }
 
+if (!$this->isTag) {
+  $prefixes[] = 'refs/meta/';
+}
+
 $order = '-creatordate';
 
 $futures = array();
@@ -55,6 +59,7 @@
 }
 
 // Resolve all the futures first. We want to iterate over them in prefix
+
 // order, not resolution order.
 foreach (new FutureIterator($futures) as $prefix => $future) {
   $future->resolvex();
@@ -63,7 +68,6 @@
 $results = array();
 foreach ($futures as $prefix => $future) {
   list($stdout) = $future->resolvex();
-
   $stdout = rtrim($stdout);
   if (!strlen($stdout)) {
 continue;
@@ -103,7 +107,70 @@
   }
 }
 
-return $results;
+$prefixes_custom = array();
+
+if (!$this->isTag) {
+  $prefixes_custom[] = 'refs/changes/';
+}
+
+$futures_custom = array();
+foreach ($prefixes_custom as $prefix_custom) {
+  $futures_custom['refs/'] = $repository->getLocalCommandFuture(
+'for-each-ref --sort=%s --format=%s %s',
+$order,
+$this->getFormatString(),
+$prefix_custom);
+}
+
+// Resolve all the futures first. We want to iterate over them in prefix
+// order, not resolution order.
+foreach (new FutureIterator($futures_custom) as $prefix_custom => 
$future_custom) {
+  $future_custom->resolvex();
+}
+
+foreach ($futures_custom as $prefix_custom => $future_custom) {
+  list($stdout) = $future_custom->resolvex();
+
+  $stdout = rtrim($stdout);
+  if (!strlen($stdout)) {
+continue;
+  }
+
+  // NOTE: Although git supports --count, we can't apply any offset or
+  // limit logic until the very end because we may encounter a HEAD which
+  // we want to discard.
+
+  $lines = explode("\5", $stdout);
+  $lines = array_filter($lines);
+  foreach ($lines as $line) {
+$fields = $this->extractFields($line);
+
+$creator = $fields['creator'];
+$matches = null;
+if (preg_match('/^(.*) ([0-9]+) ([0-9+-]+)$/', $creator, $matches)) {
+  $fields['author'] = $matches[1];
+  $fields['epoch'] = (int)$matches[2];
+} else {
+  $fields['author'] = null;
+  $fields['epoch'] = null;
+}
+
+$commit = nonempty($fields['*objectname'], $fields['objectname']);
+
+$short = substr($fields['refname'], strlen($prefix_custom));
+if ($short == 'HEAD') {
+  continue;
+}
+
+$ref = id(new DiffusionRepositoryRef())
+  ->setShortName($short)
+  ->setCommitIdentifier($commit)
+  ->setRawFields($fields);
+
+$results[] = $ref;
+  }
+}
+   return $results;
   }
 
   /**
diff --git 
a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php 
b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
index 690f942..3fbbd53 100644
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -314,7 +314,7 @@
 // For bare working copies, we need this magic incantation.
 $future = $repository->getRemoteCommandFuture(
   'fetch origin %s --prune',
-  '+refs/heads/*:refs/heads/*');
+  '+refs/*:refs/*');
   } else {
 $future = $repository->getRemoteCommandFuture(
   'fetch --all --prune');

-- 
To view, visit https://gerrit.wikimedia.org/r/284517
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f8205651f717e98271f6f18c37730955f953d68
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/phabricator
Gerrit-Branch: wmf/dev
Gerrit-Owner: Paladox 

[MediaWiki-commits] [Gerrit] Allow viewing all ref type commits - change (phabricator/phabricator)

2016-04-14 Thread Paladox (Code Review)
Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/283573

Change subject: Allow viewing all ref type commits
..

Allow viewing all ref type commits

This allows us to view ref types such as refs/changes and refs/meta since
we use gerrit where we have the repo's but we carn't currently view all
commit since some are open and stored in refs/changes which phabricator
dosen't view yet, with this patch it lets us view those commits.

Change-Id: I4391793467dbbdd0d4f889970477203bd628ee18
---
M src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
M src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
2 files changed, 69 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/phabricator/phabricator 
refs/changes/73/283573/1

diff --git 
a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php 
b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
index 1f17f5f..7cc14df 100644
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php
@@ -43,6 +43,10 @@
   $prefixes[] = 'refs/tags/';
 }
 
+if (!$this->isTag) {
+  $prefixes[] = 'refs/meta/';
+}
+
 $order = '-creatordate';
 
 $futures = array();
@@ -55,6 +59,7 @@
 }
 
 // Resolve all the futures first. We want to iterate over them in prefix
+
 // order, not resolution order.
 foreach (new FutureIterator($futures) as $prefix => $future) {
   $future->resolvex();
@@ -63,7 +68,6 @@
 $results = array();
 foreach ($futures as $prefix => $future) {
   list($stdout) = $future->resolvex();
-
   $stdout = rtrim($stdout);
   if (!strlen($stdout)) {
 continue;
@@ -102,8 +106,70 @@
 $results[] = $ref;
   }
 }
+$prefixes_custom = array();
 
-return $results;
+if (!$this->isTag) {
+  $prefixes_custom[] = 'refs/changes/';
+}
+
+$futures_custom = array();
+foreach ($prefixes_custom as $prefix_custom) {
+  $futures_custom['refs/'] = $repository->getLocalCommandFuture(
+'for-each-ref --sort=%s --format=%s %s',
+$order,
+$this->getFormatString(),
+$prefix_custom);
+}
+
+// Resolve all the futures first. We want to iterate over them in prefix
+// order, not resolution order.
+foreach (new FutureIterator($futures_custom) as $prefix_custom => 
$future_custom) {
+  $future_custom->resolvex();
+}
+
+foreach ($futures_custom as $prefix_custom => $future_custom) {
+  list($stdout) = $future_custom->resolvex();
+
+  $stdout = rtrim($stdout);
+  if (!strlen($stdout)) {
+continue;
+  }
+
+  // NOTE: Although git supports --count, we can't apply any offset or
+  // limit logic until the very end because we may encounter a HEAD which
+  // we want to discard.
+
+  $lines = explode("\n", $stdout);
+  // $lines = array_filter($lines);
+  foreach ($lines as $line) {
+$fields = $this->extractFields($line);
+
+$creator = $fields['creator'];
+$matches = null;
+if (preg_match('/^(.*) ([0-9]+) ([0-9+-]+)$/', $creator, $matches)) {
+  $fields['author'] = $matches[1];
+  $fields['epoch'] = (int)$matches[2];
+} else {
+  $fields['author'] = null;
+  $fields['epoch'] = null;
+}
+
+$commit = nonempty($fields['*objectname'], $fields['objectname']);
+
+$short = substr($fields['refname'], strlen($prefix_custom));
+if ($short == 'HEAD') {
+  continue;
+}
+
+$ref = id(new DiffusionRepositoryRef())
+  ->setShortName($short)
+  ->setCommitIdentifier($commit)
+  ->setRawFields($fields);
+
+$results[] = $ref;
+  }
+}
+   return $results;
   }
 
   /**
diff --git 
a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php 
b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
index 690f942..3fbbd53 100644
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -314,7 +314,7 @@
 // For bare working copies, we need this magic incantation.
 $future = $repository->getRemoteCommandFuture(
   'fetch origin %s --prune',
-  '+refs/heads/*:refs/heads/*');
+  '+refs/*:refs/*');
   } else {
 $future = $repository->getRemoteCommandFuture(
   'fetch --all --prune');

-- 
To view, visit https://gerrit.wikimedia.org/r/283573
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4391793467dbbdd0d4f889970477203bd628ee18
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/phabricator
Gerrit-Branch: 

[MediaWiki-commits] [Gerrit] Allow viewing all ref type commits - change (phabricator/phabricator)

2016-04-13 Thread Paladox (Code Review)
Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/283208

Change subject: Allow viewing all ref type commits
..

Allow viewing all ref type commits

This allows us to view ref types such as refs/changes and refs/meta since
we use gerrit where we have the repo's but we carn't currently view all
commit since some are open and stored in refs/changes which phabricator
dosen't view yet, with this patch it lets us view those commits.

Change-Id: I4391793467dbbdd0d4f889970477203bd628ee18
---
M src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/phabricator/phabricator 
refs/changes/08/283208/1

diff --git 
a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php 
b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
index 690f942..3fbbd53 100644
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -314,7 +314,7 @@
 // For bare working copies, we need this magic incantation.
 $future = $repository->getRemoteCommandFuture(
   'fetch origin %s --prune',
-  '+refs/heads/*:refs/heads/*');
+  '+refs/*:refs/*');
   } else {
 $future = $repository->getRemoteCommandFuture(
   'fetch --all --prune');

-- 
To view, visit https://gerrit.wikimedia.org/r/283208
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4391793467dbbdd0d4f889970477203bd628ee18
Gerrit-PatchSet: 1
Gerrit-Project: phabricator/phabricator
Gerrit-Branch: production
Gerrit-Owner: Paladox 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits