Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3281294
hgsprintf.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
hgsprintf.php
View Options
<?php
/**
* Format a Mercurial revset expression. Supports the following conversions:
*
* %s Symbol
* Escapes a Mercurial symbol, like a branch or bookmark name.
*
* %R Rrraw Rreferrrence / Rrrrevset
* Passes text through unescaped (e.g., an already-escaped revset).
*/
function
hgsprintf
(
$pattern
/* , ... */
)
{
$args
=
func_get_args
(
)
;
return
xsprintf
(
'xsprintf_mercurial'
,
null
,
$args
)
;
}
/**
* @{function:xsprintf} callback for Mercurial encoding.
*/
function
xsprintf_mercurial
(
$userdata
,
&
$pattern
,
&
$pos
,
&
$value
,
&
$length
)
{
$type
=
$pattern
[
$pos
]
;
switch
(
$type
)
{
case
's'
:
// If this is symbol only has "safe" alphanumeric latin characters,
// and is at least one character long, we can let it through without
// escaping it. This tends to produce more readable commands.
if
(
preg_match
(
'(^[a-zA-Z0-9]+\z)'
,
$value
)
)
{
$value
=
$value
;
}
else
{
$value
=
"'"
.
addcslashes
(
$value
,
"'\\"
)
.
"'"
;
}
break
;
case
'R'
:
$type
=
's'
;
break
;
}
$pattern
[
$pos
]
=
$type
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Mar 23, 20:33 (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1115521
Default Alt Text
hgsprintf.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment