changeset 27533:a801d331a022

merge with stable
author Matt Mackall <mpm@selenic.com>
date Mon, 28 Dec 2015 10:11:48 -0600
parents dbfaf361c062 (current diff) 1be02894dd6f (diff)
children 88b32dcc25b6
files hgext/mq.py mercurial/cmdutil.py mercurial/crecord.py
diffstat 4 files changed, 45 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun Dec 27 23:55:54 2015 +0900
+++ b/hgext/mq.py	Mon Dec 28 10:11:48 2015 -0600
@@ -396,10 +396,12 @@
 class AbortNoCleanup(error.Abort):
     pass
 
-def makepatchname(existing, title):
+def makepatchname(existing, title, fallbackname):
     """Return a suitable filename for title, adding a suffix to make
     it unique in the existing list"""
     namebase = re.sub('[\s\W_]+', '_', title.lower()).strip('_')
+    if not namebase:
+        namebase = fallbackname
     name = namebase
     i = 0
     while name in existing:
@@ -2111,7 +2113,8 @@
 
                     if not patchname:
                         patchname = makepatchname(self.fullseries,
-                            repo[r].description().split('\n', 1)[0])
+                            repo[r].description().split('\n', 1)[0],
+                            '%d.diff' % r)
                     checkseries(patchname)
                     self.checkpatchname(patchname, force)
                     self.fullseries.insert(0, patchname)
--- a/mercurial/cmdutil.py	Sun Dec 27 23:55:54 2015 +0900
+++ b/mercurial/cmdutil.py	Mon Dec 28 10:11:48 2015 -0600
@@ -66,7 +66,7 @@
     what kind of filtering they are doing: reverting, committing, shelving, etc.
     *operation* has to be a translated string.
     """
-    usecurses =  ui.configbool('experimental', 'crecord', False)
+    usecurses = crecordmod.checkcurses(ui)
     testfile = ui.config('experimental', 'crecordtest', None)
     oldwrite = setupwrapcolorwrite(ui)
     try:
--- a/mercurial/crecord.py	Sun Dec 27 23:55:54 2015 +0900
+++ b/mercurial/crecord.py	Mon Dec 28 10:11:48 2015 -0600
@@ -31,25 +31,30 @@
 # locale encoding correctly.  --immerrr
 locale.setlocale(locale.LC_ALL, '')
 
-# os.name is one of: 'posix', 'nt', 'dos', 'os2', 'mac', or 'ce'
-if os.name == 'posix':
+try:
     import curses
     import fcntl
     import termios
-else:
+    curses.error
+    fcntl.ioctl
+    termios.TIOCGWINSZ
+except ImportError:
     # I have no idea if wcurses works with crecord...
     try:
         import wcurses as curses
+        curses.error
     except ImportError:
-        # wcurses is not shipped on Windows by default
-        pass
+        # wcurses is not shipped on Windows by default, or python is not
+        # compiled with curses
+        curses = False
 
-try:
-    curses
-except NameError:
-    if os.name != 'nt':  # Temporary hack to get running on Windows again
-        raise error.Abort(
-            _('the python curses/wcurses module is not available/installed'))
+def checkcurses(ui):
+    """Return True if the user wants to use curses
+
+    This method returns True if curses is found (and that python is built with
+    it) and that the user has the correct flag for the ui.
+    """
+    return curses and ui.configbool('experimental', 'crecord', False)
 
 _origstdout = sys.__stdout__ # used by gethw()
 
--- a/tests/test-mq-qimport.t	Sun Dec 27 23:55:54 2015 +0900
+++ b/tests/test-mq-qimport.t	Mon Dec 28 10:11:48 2015 -0600
@@ -290,3 +290,26 @@
   $ cd ..
 
   $ killdaemons.py
+
+check patch name generation for non-alpha-numeric summary line
+
+  $ cd repo
+
+  $ hg qpop -a -q
+  patch queue now empty
+  $ hg qseries -v
+  0 U imported_patch_b_diff
+  1 U 0
+  2 U this-name-is-better
+  3 U url.diff
+
+  $ echo bb >> b
+  $ hg commit -m '==++--=='
+
+  $ hg qimport -r tip
+  $ hg qseries -v
+  0 A 1.diff
+  1 U imported_patch_b_diff
+  2 U 0
+  3 U this-name-is-better
+  4 U url.diff