Bash-Prompt-Builder icon indicating copy to clipboard operation
Bash-Prompt-Builder copied to clipboard

hg branch shows error from cat if .hg/branch does not exist yet

Open edbrannin opened this issue 13 years ago • 1 comments

Steps to repro:

  1. Use these settings and PS1="\$(${dvcs_function})\[$COLOR_RESET\] \h:\W \u\$ "
  2. $ hg init empty
  3. 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)!

edbrannin avatar Sep 24 '11 15:09 edbrannin

confirmed, will fix

AndrewRayCode avatar Sep 26 '11 19:09 AndrewRayCode