D4462: narrow: use util.readfile() and improve error message using --narrowspec

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Fri Sep 7 08:40:34 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4062bbb1d10f: narrow: use util.readfile() and improve error message using --narrowspec (authored by pulkit, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D4462?vs=10742&id=10829#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4462?vs=10742&id=10829

REVISION DETAIL
  https://phab.mercurial-scm.org/D4462

AFFECTED FILES
  hgext/narrow/narrowcommands.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py
+++ b/hgext/narrow/narrowcommands.py
@@ -84,12 +84,12 @@
         filepath = os.path.join(pycompat.getcwd(), narrowspecfile)
         ui.status(_("reading narrowspec from '%s'\n") % filepath)
         try:
-            fp = open(filepath, 'rb')
-        except IOError:
-            raise error.Abort(_("file '%s' not found") % filepath)
+            fdata = util.readfile(filepath)
+        except IOError as inst:
+            raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
+                              (filepath, encoding.strtolocal(inst.strerror)))
 
-        includes, excludes, profiles = sparse.parseconfig(ui, fp.read(),
-                                                          'narrow')
+        includes, excludes, profiles = sparse.parseconfig(ui, fdata, 'narrow')
         if profiles:
             raise error.Abort(_("cannot specify other files using '%include' in"
                                 " narrowspec"))



To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list