703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
|
/*
** Resolves a patch-command remote system name, accounting for patch
** aliases.
**
** If a VVAR table entry matching name='patch-alias:$zKey' is found,
** the corresponding value is returned, else a fossil_strdup() of zKey
** is returned.
*/
static char * patch_resolve_remote(const char *zKey){
char * zAlias = db_text(0, "SELECT value FROM vvar "
"WHERE name = 'patch-alias:' || %Q",
zKey);
return zAlias ? zAlias : fossil_strdup(zKey);
}
|
|
>
|
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
|
/*
** Resolves a patch-command remote system name, accounting for patch
** aliases.
**
** If a VVAR table entry matching name='patch-alias:$zKey' is found,
** the corresponding value is returned, else a fossil_strdup() of zKey
** is returned. The caller is responsible for passing the resulting
** string to fossil_free().
*/
static char * patch_resolve_remote(const char *zKey){
char * zAlias = db_text(0, "SELECT value FROM vvar "
"WHERE name = 'patch-alias:' || %Q",
zKey);
return zAlias ? zAlias : fossil_strdup(zKey);
}
|
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
|
}
}else if( 0==strcmp("add", zArg) ){
/* alias add localName remote */
verify_all_options();
if( 6!=g.argc ){
usage("alias add localName remote");
}
db_unprotect(PROTECT_CONFIG);
db_multi_exec("REPLACE INTO vvar (name, value) "
"VALUES ('patch-alias:%q', %Q)",
g.argv[4], g.argv[5]);
db_protect_pop();
}else if( 0==strcmp("rm", zArg) ){
/* alias rm */
const int fAll = 0!=find_option("all", 0, 0);
verify_all_options();
if( g.argc<5 ){
usage("alias rm [-all] [aliasGlob [...aliasGlobN]]");
}
db_unprotect(PROTECT_CONFIG);
if( 0!=fAll ){
db_multi_exec("DELETE FROM vvar WHERE name GLOB 'patch-alias:*'");
}else{
Stmt q;
int i;
db_prepare(&q, "DELETE FROM vvar WHERE name "
"GLOB 'patch-alias:' || :pattern");
for(i = 4; i < g.argc; ++i){
db_bind_text(&q, ":pattern", g.argv[i]);
db_step(&q);
db_reset(&q);
}
db_finalize(&q);
}
db_protect_pop();
}else{
usage_patch_alias:
usage("alias ls|list|add|rm ...");
}
}else
if( strncmp(zCmd, "apply", n)==0 ){
char *zIn;
|
<
<
<
|
<
>
<
|
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
|
}
}else if( 0==strcmp("add", zArg) ){
/* alias add localName remote */
verify_all_options();
if( 6!=g.argc ){
usage("alias add localName remote");
}
db_multi_exec("REPLACE INTO vvar (name, value) "
"VALUES ('patch-alias:%q', %Q)",
g.argv[4], g.argv[5]);
}else if( 0==strcmp("rm", zArg) ){
/* alias rm */
const int fAll = 0!=find_option("all", 0, 0);
if( fAll ? g.argc<4 : g.argc<5 ){
usage("alias rm [-all] [aliasGlob [...aliasGlobN]]");
}
verify_all_options();
if( 0!=fAll ){
db_multi_exec("DELETE FROM vvar WHERE name GLOB 'patch-alias:*'");
}else{
Stmt q;
int i;
db_prepare(&q, "DELETE FROM vvar WHERE name "
"GLOB 'patch-alias:' || :pattern");
for(i = 4; i < g.argc; ++i){
db_bind_text(&q, ":pattern", g.argv[i]);
db_step(&q);
db_reset(&q);
}
db_finalize(&q);
}
}else{
usage_patch_alias:
usage("alias ls|list|add|rm ...");
}
}else
if( strncmp(zCmd, "apply", n)==0 ){
char *zIn;
|