merge stable in default

authorDavid Douard <david.douard@logilab.fr>
changeset60c0dd913f22
branchdefault
phasepublic
hiddenno
parent revision#c27a1eb98cab [lib] do not swallow exception with ``--traceback`` (closes #89337), #f13bb3187194 merge stable into default
child revision#3db520bf9455 [qt/hgrepoview] try probable encodings rather than just impose one (author, commit msg)
files modified by this revision
hgviewlib/application.py
hgviewlib/curses/__init__.py
hgviewlib/curses/application.py
hgviewlib/hggraph.py
hgviewlib/hgpatches/mqsupport.py
hgviewlib/hgpatches/scmutil.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1330684066 -3600
# Fri Mar 02 11:27:46 2012 +0100
# Node ID 60c0dd913f22a569a78a024273c920f03cabc7d6
# Parent f13bb318719475cf958dcaf66f3311cda7f50bc7
# Parent c27a1eb98cab82f1ca1eca82639cbc1ec52dd16d
merge stable in default

diff --git a/hgviewlib/application.py b/hgviewlib/application.py
@@ -118,16 +118,20 @@
1      if not opts.interface or opts.interface == 'qt':
2          try:
3              from hgviewlib.qt4.application import HgViewQtApplication as Application
4              opts.interface = 'qt'
5          except ImportError:
6 +            if '--traceback' in sys.argv:
7 +                raise
8              pass
9      if not opts.interface or opts.interface in ('raw', 'curses'):
10          try:
11              from hgviewlib.curses.application import HgViewUrwidApplication as Application
12              opts.interface = 'raw'
13          except ImportError:
14 +            if '--traceback' in sys.argv:
15 +                raise
16              pass
17      if not opts.interface:
18          fnerror('No interface found')
19      if not Application:
20          fnerror('Interface is not available: %s' % opts.interface)
diff --git a/hgviewlib/curses/__init__.py b/hgviewlib/curses/__init__.py
@@ -15,10 +15,24 @@
21  # this program.  If not, see <http://www.gnu.org/licenses/>.
22 
23  """
24  console interface for hgview.
25  """
26 +
27 +# disable lazy import for urwid
28 +from mercurial import demandimport
29 +demandimport.ignore.extend([
30 +    'urwid.html_fragment', 'urwid.tests', 'urwid', 'urwid.escape',
31 +    'urwid.command_map', 'urwid.signals', 'urwid.version', 'urwid.util',
32 +    'urwid.display_common', 'urwid.font', 'urwid.old_str_util',
33 +    'urwid.lcd_display', 'urwid.raw_display', 'urwid.split_repr',
34 +    'urwid.listbox', 'urwid.decoration', 'urwid.widget', 'urwid.graphics',
35 +    'urwid.wimp', 'urwid.container', 'urwid.web_display',
36 +    'urwid.curses_display', 'urwid.text_layout', 'urwid.compat',
37 +    'urwid.main_loop', 'urwid.monitored_list', 'urwid.__init__',
38 +    'urwid.vterm_test', 'urwid.treetools', 'urwid.canvas', 'urwid.vterm'])
39 +
40  # use __all__ in the corresponding modules
41  # pylint: disable-msg=W0401
42  from hgviewlib.curses.utils import *
43  from hgviewlib.curses.exceptions import *
44  from hgviewlib.curses.widgets import *
diff --git a/hgviewlib/curses/application.py b/hgviewlib/curses/application.py
@@ -113,11 +113,11 @@
45              # get all events on every files.
46              # Ignore files that shall be ignored be mercurial
47              # Also ignore hg-checkexec* files that are created by mercurial
48              # to check available file status.
49              for fname in self.read_events():
50 -                if fname.startswith('hg-checkexec'):
51 +                if fname.startswith(('hg-checkexec', 'hg-checklink')):
52                      break
53                  if self.repo.dirstate._dirignore(fname):
54                      break
55              else:
56              # use the urwid mainloop to schedule the screen refreshing in 0.2s
diff --git a/hgviewlib/hggraph.py b/hgviewlib/hggraph.py
@@ -452,12 +452,12 @@
57          ctx = self.repo.changectx(rev)
58          filesize = 0
59          try:
60              fctx = ctx.filectx(filename)
61              filesize = fctx.size() # compute size here to lookup data securely
62 -        except LookupError:
63 -            fctx = None # may happen for renamed files or mq patch ?
64 +        except (LookupError, OSError):
65 +            fctx = None # may happen for renamed/removed files or mq patch ?
66 
67          if isbfile(filename):
68              data = "[bfile]\n"
69              if fctx:
70                  data = fctx.data()
diff --git a/hgviewlib/hgpatches/mqsupport.py b/hgviewlib/hgpatches/mqsupport.py
@@ -247,11 +247,14 @@
71      def oldpath(self):
72          return self._oldpath
73 
74      def files(self):
75          """List of modified files"""
76 -        return tuple(path for path in (self._path, self._oldpath) if path)
77 +        return tuple(path for path in (self._path, self._oldpath)
78 +                     if path and not os.devnull.endswith(path))
79 +    # note endswith is used as the complete path have been cut
80 +    # (expecting ``a/`` at the beginning of path)
81 
82      def data(self):
83          """ return the patch hunks"""
84          return self._data
85      __str__ = data
diff --git a/hgviewlib/hgpatches/scmutil.py b/hgviewlib/hgpatches/scmutil.py
@@ -19,7 +19,7 @@
86  try:
87      from mercurial.scmutil import match
88  except ImportError:
89      from mercurial import cmdutil
90      def match(ctx, *args, **kwargs):
91 -        cmdutil.match(ctx._repo, *args, **kwargs)
92 +        return cmdutil.match(ctx._repo, *args, **kwargs)
93