Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: vcs_info Mercurial backend branch name display



Greg Klanderman <gak <at> klanderman.net> writes:
> Looks like you have a spurious 'if' there..

No, that is correct. It initially tries to obtain the branch name by
invoking hg (line 54) -- only if the user has opted to allow invoking
hg. If it still doesn't know the branch name and a file containing the
name is readable, it will pull it from the file (line 59). Finally, if
we still don't know the branch it defaults to "default" (line 64).

It could be refactored to the following if you feel this is more
readable:

# If the user doesn't opt to invoke hg we can still get the current branch
if [[ -z ${r_branch} ]] ; then
    if [[ -r ${branchfile} ]] ; then
        r_branch=$(< ${branchfile})
    else
        # If we still don't know the branch it's safe to assume default
        r_branch="default"
    fi
fi



Messages sorted by: Reverse Date, Date, Thread, Author