Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15472651
D21515.id51214.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D21515.id51214.diff
View Options
diff --git a/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php b/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
@@ -189,7 +189,7 @@
$head_refs = $this->discoverStreamAncestry(
new PhabricatorGitGraphStream($repository, $commit),
$commit,
- $publisher->shouldPublishRef($ref));
+ $publisher->isPermanentRef($ref));
$this->didDiscoverRefs($head_refs);
@@ -507,9 +507,9 @@
}
/**
- * Sort branches so we process permanent branches first. This makes the
- * whole import process a little cheaper, since we can publish these commits
- * the first time through rather than catching them in the refs step.
+ * Sort refs so we process permanent refs first. This makes the whole import
+ * process a little cheaper, since we can publish these commits the first
+ * time through rather than catching them in the refs step.
*
* @task internal
*
@@ -523,7 +523,7 @@
$head_refs = array();
$tail_refs = array();
foreach ($refs as $ref) {
- if ($publisher->shouldPublishRef($ref)) {
+ if ($publisher->isPermanentRef($ref)) {
$head_refs[] = $ref;
} else {
$tail_refs[] = $ref;
diff --git a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
@@ -100,7 +100,7 @@
$this->setPermanentFlagOnCommits($this->permanentCommits);
}
- $save_cursors = $this->getCursorsForUpdate($all_cursors);
+ $save_cursors = $this->getCursorsForUpdate($repository, $all_cursors);
if ($this->newPositions || $this->deadPositions || $save_cursors) {
$repository->openTransaction();
@@ -121,17 +121,19 @@
}
}
- private function getCursorsForUpdate(array $cursors) {
+ private function getCursorsForUpdate(
+ PhabricatorRepository $repository,
+ array $cursors) {
assert_instances_of($cursors, 'PhabricatorRepositoryRefCursor');
+ $publisher = $repository->newPublisher();
+
$results = array();
foreach ($cursors as $cursor) {
- $ref_type = $cursor->getRefType();
- $ref_name = $cursor->getRefName();
-
- $is_permanent = $this->isPermanentRef($ref_type, $ref_name);
+ $diffusion_ref = $cursor->newDiffusionRepositoryRef();
+ $is_permanent = $publisher->isPermanentRef($diffusion_ref);
if ($is_permanent == $cursor->getIsPermanent()) {
continue;
}
@@ -259,6 +261,7 @@
$ref_type,
array $all_closing_heads) {
$repository = $this->getRepository();
+ $publisher = $repository->newPublisher();
// NOTE: Mercurial branches may have multiple branch heads; this logic
// is complex primarily to account for that.
@@ -341,7 +344,8 @@
$this->markPositionNew($new_position);
}
- if ($this->isPermanentRef($ref_type, $name)) {
+ $diffusion_ref = head($refs)->newDiffusionRepositoryRef();
+ if ($publisher->isPermanentRef($diffusion_ref)) {
// See T13284. If this cursor was already marked as permanent, we
// only need to publish the newly created ref positions. However, if
@@ -404,14 +408,6 @@
}
}
- private function isPermanentRef($ref_type, $ref_name) {
- if ($ref_type !== PhabricatorRepositoryRefCursor::TYPE_BRANCH) {
- return false;
- }
-
- return $this->getRepository()->isBranchPermanentRef($ref_name);
- }
-
/**
* Find all ancestors of a new closing branch head which are not ancestors
* of any old closing branch head.
diff --git a/src/applications/repository/query/PhabricatorRepositoryPublisher.php b/src/applications/repository/query/PhabricatorRepositoryPublisher.php
--- a/src/applications/repository/query/PhabricatorRepositoryPublisher.php
+++ b/src/applications/repository/query/PhabricatorRepositoryPublisher.php
@@ -38,6 +38,10 @@
return !$this->getCommitHoldReasons($commit);
}
+ public function isPermanentRef(DiffusionRepositoryRef $ref) {
+ return !$this->getRefImpermanentReasons($ref);
+ }
+
/* -( Hold Reasons )------------------------------------------------------- */
public function getRepositoryHoldReasons() {
@@ -59,18 +63,8 @@
$repository = $this->getRepository();
$reasons = $this->getRepositoryHoldReasons();
- if (!$ref->isBranch()) {
- $reasons[] = self::HOLD_REF_NOT_BRANCH;
- } else {
- $branch_name = $ref->getShortName();
-
- if (!$repository->shouldTrackBranch($branch_name)) {
- $reasons[] = self::HOLD_UNTRACKED;
- }
-
- if (!$repository->isBranchPermanentRef($branch_name)) {
- $reasons[] = self::HOLD_NOT_PERMANENT_REF;
- }
+ foreach ($this->getRefImpermanentReasons($ref) as $reason) {
+ $reasons[] = $reason;
}
return $reasons;
@@ -89,4 +83,25 @@
return $reasons;
}
+ public function getRefImpermanentReasons(DiffusionRepositoryRef $ref) {
+ $repository = $this->getRepository();
+ $reasons = array();
+
+ if (!$ref->isBranch()) {
+ $reasons[] = self::HOLD_REF_NOT_BRANCH;
+ } else {
+ $branch_name = $ref->getShortName();
+
+ if (!$repository->shouldTrackBranch($branch_name)) {
+ $reasons[] = self::HOLD_UNTRACKED;
+ }
+
+ if (!$repository->isBranchPermanentRef($branch_name)) {
+ $reasons[] = self::HOLD_NOT_PERMANENT_REF;
+ }
+ }
+
+ return $reasons;
+ }
+
}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
--- a/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryRefCursor.php
@@ -88,6 +88,12 @@
return mpull($this->getPositions(), 'getCommitIdentifier');
}
+ public function newDiffusionRepositoryRef() {
+ return id(new DiffusionRepositoryRef())
+ ->setRefType($this->getRefType())
+ ->setShortName($this->getRefName());
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 6, 3:18 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7723915
Default Alt Text
D21515.id51214.diff (6 KB)
Attached To
Mode
D21515: Separate "shouldPublishRef()" from "isPermanentRef()" and set "IMPORTED_PERMANENT" more narrowly
Attached
Detach File
Event Timeline
Log In to Comment