mq: restrict generated patch name to 75 characters (issue5117) stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 09 Mar 2016 22:21:08 +0000
branchstable
changeset 28388 b1d35e2e1af6
parent 28387 97175d9bf7cf
child 28389 9ab45fbe045e
mq: restrict generated patch name to 75 characters (issue5117) Super long first line in description lead to very long file name that windows is unhappy about. We restrict the name to 75 char to avoid the issue. 75 seems fine and leave some extra room for '__#' suffix in case of conflict. I does not seems worthwhile to add a dedicated config option to configure the length. It can be done in the future if there is an actual user demand for it.
hgext/mq.py
tests/test-mq-qimport.t
--- a/hgext/mq.py	Sun Mar 06 14:30:34 2016 -0500
+++ b/hgext/mq.py	Wed Mar 09 22:21:08 2016 +0000
@@ -1117,6 +1117,7 @@
         """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('_')
+        namebase = namebase[:75] # avoid too long name (issue5117)
         if namebase:
             try:
                 self.checkreservedname(namebase)
--- a/tests/test-mq-qimport.t	Sun Mar 06 14:30:34 2016 -0500
+++ b/tests/test-mq-qimport.t	Wed Mar 09 22:21:08 2016 +0000
@@ -331,3 +331,12 @@
   2.diff
   taken__2
 
+check very long patch name
+
+  $ hg qpop -qa
+  patch queue now empty
+  $ echo >> b
+  $ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+  $ hg qimport -r .
+  $ hg qap
+  abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg