c1951892314592295b0d5865f8ef5c72f360d6d0

Author
Victor Torres <vpaivatorres@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Use default branch on recently created Mercurial repository. (#4985)

After `hg init` command, sometimes Mercurial does not create `.hg/branch` file so we'll use 'default' as fallback, which is the master branch in Mercurial repositories.

Signed-off-by: Marc Cornellà <marc.cornella@live.com>

Diff

 1diff --git a/plugins/branch/branch.plugin.zsh b/plugins/branch/branch.plugin.zsh
 2index a1e9ca31be4fbe016fa8470294868b5f4ceae294..2e5659bdf5b5e7da839c502503b20a7786d26f88 100644
 3--- a/plugins/branch/branch.plugin.zsh
 4+++ b/plugins/branch/branch.plugin.zsh
 5@@ -17,7 +17,12 @@ function branch_prompt_info() {
 6     # Mercurial repository
 7     if [[ -d "${current_dir}/.hg" ]]
 8     then
 9-      echo '☿' $(<"$current_dir/.hg/branch")
10+      if [[ -f "$current_dir/.hg/branch" ]]
11+      then
12+        echo '☿' $(<"$current_dir/.hg/branch")
13+      else
14+        echo '☿ default'
15+      fi
16       return;
17     fi
18     # Defines path as parent directory and keeps looking for :)