Patchwork [STABLE] mq: restrict generated patch name to 75 characters (issue5117)

login
register
mail settings
Submitter Pierre-Yves David
Date March 9, 2016, 10:25 p.m.
Message ID <a9c9d62a1d662b5693b6.1457562351@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/13730/
State Accepted
Headers show

Comments

Pierre-Yves David - March 9, 2016, 10:25 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1457562068 0
#      Wed Mar 09 22:21:08 2016 +0000
# Branch stable
# Node ID a9c9d62a1d662b5693b61a3a27a8e0bf3d301cb3
# Parent  b7e192240c41db8d02419b7bcd2be9a2b6194023
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r a9c9d62a1d66
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.
Matt Mackall - March 9, 2016, 11:11 p.m.
On Wed, 2016-03-09 at 22:25 +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1457562068 0
> #      Wed Mar 09 22:21:08 2016 +0000
> # Branch stable
> # Node ID a9c9d62a1d662b5693b61a3a27a8e0bf3d301cb3
> # Parent  b7e192240c41db8d02419b7bcd2be9a2b6194023
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r
> a9c9d62a1d66
> mq: restrict generated patch name to 75 characters (issue5117)

Queued for stable, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1115,10 +1115,11 @@  class queue(object):
 
     def makepatchname(self, 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('_')
+        namebase = namebase[:75] # avoid too long name (issue5117)
         if namebase:
             try:
                 self.checkreservedname(namebase)
             except error.Abort:
                 namebase = fallbackname
diff --git a/tests/test-mq-qimport.t b/tests/test-mq-qimport.t
--- a/tests/test-mq-qimport.t
+++ b/tests/test-mq-qimport.t
@@ -329,5 +329,14 @@  check reserved patch names
   $ hg qap
   1.diff__1
   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