lib/update.hg
branchdns-new
changeset 612 51270237a6ff
parent 605 26a307558602
child 618 a756f317d083
equal deleted inserted replaced
611:52d058780506 612:51270237a6ff
     2 #
     2 #
     3 # HG wrappers
     3 # HG wrappers
     4 
     4 
     5 ## Run `hg ...` within $REPO.
     5 ## Run `hg ...` within $REPO.
     6 function hg {
     6 function hg {
     7     cmd $HG "${HG_ARGS[@]}" "$@"
     7     local repo=$1; shift
       
     8     cmd $HG -R "$repo" "${HG_ARGS[@]}" "$@"
     8 }
     9 }
     9 
    10 
    10 ## Does the repo have local modifications?
    11 ## Does the repo have local modifications?
    11 function hg_modified {
    12 function hg_modified {
    12     hg id | grep -q '+'
    13     hg $1 id | grep -q '+'
    13 }
    14 }
    14 
    15 
    15 ## Output possible -u flag for commit.
    16 ## Output possible -u flag for commit.
    16 function hg_user {
    17 function hg_user {
    17     if [ ${SUDO_USER:-} ]; then
    18     if [ ${SUDO_USER:-} ]; then
    27 }
    28 }
    28 
    29 
    29 ## Show changes in repo
    30 ## Show changes in repo
    30 #   hg_diff     [path ...]
    31 #   hg_diff     [path ...]
    31 function hg_diff {
    32 function hg_diff {
    32     hg diff "$@"
    33     local repo=$1; shift
       
    34     hg $repo diff "$@"
    33 }
    35 }
    34 
    36 
    35 ## Commit changes in repo, with given message:
    37 ## Commit changes in repo, with given message:
    36 #
    38 #
    37 #   hg_commit   $msg
    39 #   hg_commit   $msg
    38 #
    40 #
    39 # Automatically determines possible -u to use when running with sudo.
    41 # Automatically determines possible -u to use when running with sudo.
    40 function hg_commit {
    42 function hg_commit {
    41     local msg=$1; shift
    43     local repo=$1
       
    44     local msg=$2
    42     local user_opt=$(hg_user)
    45     local user_opt=$(hg_user)
    43     local msg_opt=
    46     local msg_opt=
    44 
    47 
    45     [ $msg ] && msg_opt=('-m' "$msg")
    48     [ $msg ] && msg_opt=('-m' "$msg")
    46     
    49     
    47     debug "$user_opt: $msg"
    50     debug "$user_opt: $msg"
    48     hg commit ${user_opt[@]} ${msg_opt[@]}
    51     hg $repo commit ${user_opt[@]} ${msg_opt[@]}
    49 }
    52 }
    50 
       
    51