Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7188826
ArcanistWorkingCopyStateRef.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
ArcanistWorkingCopyStateRef.php
View Options
<?php
final
class
ArcanistWorkingCopyStateRef
extends
ArcanistRef
{
private
$rootDirectory
;
public
function
getRefIdentifier
()
{
// TODO: This could check attached hardpoints and render something more
// insightful.
return
pht
(
'Working Copy State'
);
}
public
function
defineHardpoints
()
{
return
array
(
'commitRef'
=>
array
(
'type'
=>
'ArcanistCommitRef'
,
),
'branchRef'
=>
array
(
'type'
=>
'ArcanistBranchRef'
,
),
'revisionRefs'
=>
array
(
'type'
=>
'ArcanistRevisionRef'
,
'vector'
=>
true
,
),
);
}
public
function
setRootDirectory
(
$root_directory
)
{
$this
->
rootDirectory
=
$root_directory
;
return
$this
;
}
public
function
getRootDirectory
()
{
return
$this
->
rootDirectory
;
}
public
function
attachBranchRef
(
ArcanistBranchRef
$branch_ref
)
{
return
$this
->
attachHardpoint
(
'branchRef'
,
$branch_ref
);
}
public
function
getBranchRef
()
{
return
$this
->
getHardpoint
(
'branchRef'
);
}
public
function
setCommitRef
(
ArcanistCommitRef
$commit_ref
)
{
return
$this
->
attachHardpoint
(
'commitRef'
,
$commit_ref
);
}
public
function
getCommitRef
()
{
return
$this
->
getHardpoint
(
'commitRef'
);
}
public
function
getRevisionRefs
()
{
return
$this
->
getHardpoint
(
'revisionRefs'
);
}
public
function
getRevisionRef
()
{
if
(
$this
->
hasAmbiguousRevisionRefs
())
{
throw
new
Exception
(
pht
(
'State has multiple ambiguous revisions refs.'
));
}
$refs
=
$this
->
getRevisionRefs
();
if
(
$refs
)
{
return
head
(
$refs
);
}
return
null
;
}
public
function
hasAmbiguousRevisionRefs
()
{
return
(
count
(
$this
->
getRevisionRefs
())
>
1
);
}
protected
function
canReadHardpoint
(
$hardpoint
)
{
switch
(
$hardpoint
)
{
case
'commitRef'
:
// If we have a branch ref, we can try to read the commit ref from the
// branch ref.
if
(
$this
->
hasAttachedHardpoint
(
'branchRef'
))
{
if
(
$this
->
getBranchRef
()->
hasAttachedHardpoint
(
'commitRef'
))
{
return
true
;
}
}
break
;
}
return
false
;
}
protected
function
readHardpoint
(
$hardpoint
)
{
switch
(
$hardpoint
)
{
case
'commitRef'
:
return
$this
->
getBranchRef
()->
getCommitRef
();
}
return
parent
::
readHardpoint
(
$hardpoint
);
}
protected
function
mergeHardpoint
(
$hardpoint
,
array
$src
,
array
$new
)
{
if
(
$hardpoint
==
'revisionRefs'
)
{
$src
=
mpull
(
$src
,
null
,
'getID'
);
$new
=
mpull
(
$new
,
null
,
'getID'
);
foreach
(
$new
as
$id
=>
$ref
)
{
if
(
isset
(
$src
[
$id
]))
{
foreach
(
$ref
->
getSources
()
as
$source
)
{
$src
[
$id
]->
addSource
(
$source
);
}
}
else
{
$src
[
$id
]
=
$ref
;
}
}
return
array_values
(
$src
);
}
return
parent
::
mergeHardpoint
(
$hardpoint
,
$src
,
$new
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jul 8, 08:32 (13 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
810481
Default Alt Text
ArcanistWorkingCopyStateRef.php (2 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline
Log In to Comment