# HG changeset patch # User Matt Mackall # Date 1451319108 21600 # Node ID a801d331a0222e22525b17bfb778180b87de67d6 # Parent dbfaf361c062e4c5a084925f827d11cf95e4a253# Parent 1be02894dd6fdc489b90c784456f82d8e7f95178 merge with stable diff -r dbfaf361c062 -r a801d331a022 hgext/mq.py --- 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) diff -r dbfaf361c062 -r a801d331a022 mercurial/cmdutil.py --- 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: diff -r dbfaf361c062 -r a801d331a022 mercurial/crecord.py --- 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() diff -r dbfaf361c062 -r a801d331a022 tests/test-mq-qimport.t --- 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