Skip to content

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

@edbrannin

Description

@edbrannin

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)!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions