Bash-Prompt-Builder
Bash-Prompt-Builder copied to clipboard
hg branch shows error from cat if .hg/branch does not exist yet
Steps to repro:
- Use these settings and
PS1="\$(${dvcs_function})\[$COLOR_RESET\] \h:\W \u\$ "
- $ hg init empty
- cd empty
Expected:
(default) Ed-Brannins-MacBook-Pro:empty ed$
Observed:
cat: /Users/ed/tmp/empty/.hg/branch: No such file or directory
() Ed-Brannins-MacBook-Pro:empty ed$
I tried replacing this line:
# If we are in mercurial ...
if [ -n \"\$_hg_dir\" ]; then
hgBranch=\`cat \"\$_hg_dir/.hg/branch\"\`
with this one:
# If we are in mercurial ...
if [ -n \"\$_hg_dir\" ]; then
hgBranch=`hg branch`
...but now I get this upon opening a new shell, which is why this isn't a pull request:
abort: no repository found in '/Users/ed' (.hg not found)!
confirmed, will fix