4d7402d28abf

Merge.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 04 Oct 2016 10:49:19 +0000
parents 804a341f819b (current diff) 8dd04e954ca9 (diff)
children 5334581e231a
branches/tags (none)
files prompt.py

Changes

diff -r 804a341f819b -r 4d7402d28abf prompt.py
--- a/prompt.py	Tue Oct 04 10:49:13 2016 +0000
+++ b/prompt.py	Tue Oct 04 10:49:19 2016 +0000
@@ -40,10 +40,24 @@
     cache = path.join(repo.root, CACHE_PATH, kind)
     c_tmp = cache + '.temp'
 
-    # This is kind of a hack and I feel a little bit dirty for doing it.
-    IGNORE = open('NUL:','w') if subprocess.mswindows else open('/dev/null','w')
+    popenargs = ['hg', kind, '--quiet']
+    remote_path = repo.ui.config('prompt', 'remote')
+    if remote_path is not None:
+        popenargs.append(remote_path)
 
-    subprocess.call(['hg', kind, '--quiet'], stdout=file(c_tmp, 'w'), stderr=IGNORE)
+    null_path = 'NUL:' if subprocess.mswindows else '/dev/null'
+    with open(null_path, 'w') as null_fp:
+        with open(c_tmp, 'w') as stdout_fp:
+            exit_code = subprocess.call(popenargs, stdout=stdout_fp, stderr=null_fp)
+
+    if exit_code not in (0, 1): # (changesets_found, changesets_not_found)
+        msg = "hg-prompt error: "
+        if remote_path: # Failure likely due to bad remote. Is 255 a valid check?
+            msg += "Can't access remote '%s'" % remote_path
+        else:
+            msg += "Error attempting 'hg %s'" % kind
+        print msg
+
     os.rename(c_tmp, cache)
     return
 
@@ -376,7 +390,7 @@
                 tip = head
                 break
 
-        return _with_groups(m.groups(), '^') if current_rev != repo[tip] else ''
+        return _with_groups(m.groups(), '^') if current_rev.children() else ''
 
 
     if opts.get("angle_brackets"):