Edgewall Software
Modify

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#12843 closed enhancement (fixed)

Quote cloned ticket description

Reported by: anonymous Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: ticket system Version:
Severity: normal Keywords: bitesized ticketclone
Cc: Branch:
Release Notes:

The cloned ticket description is quoted when cloning a ticket.

API Changes:

Description

Cloning a ticket or ticket comment adds this to the description:

Copied from [ticket:123#comment:456]:
----
Unquoted description or comment

Replying instead adds this:

Replying to [comment:456 User Name]:
> Quoted description or comment

That seems much more helpful.

The cloning functionality be changed to add something like this:

Copied from comment:456:ticket:123 by User Name:
> Quoted description or comment

Attachments (0)

Change History (9)

comment:1 by Ryan J Ollos, 2 years ago

Keywords: bitesized ticketclone added

comment:2 by Ryan J Ollos, 2 years ago

Milestone: 1.3.2
Owner: set to Ryan J Ollos
Status: newassigned

comment:3 by Ryan J Ollos, 2 years ago

comment:4 by anonymous, 2 years ago

Very nice! But please also change same thing in addCloneFromComments.

While you are at it, can you remove the (ugly and (annoying) unbalanced parentheses around the summary on line 83? Thank you!

comment:6 by Ryan J Ollos, 2 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to trunk in r16106.

in reply to:  3 comment:7 by Jun Omae, 2 years ago

Replying to Ryan J Ollos:

Proposed changes for #12842 and #12843 in log:rjollos.git:t12843_ticket_clone_improvements.

I split on \r?\n because splitlines does the same: trunk/trac/ticket/web_ui.py@15943:1646#L1638.

I think we should see unicode.splitlines rather than str.splitlines.

Also, \r is one of line boundaries in str.splitlines() but /\r?\n/ doesn't match \r.

>>> 'aaaa\rbbbb\nccccc\r\ndddd'.splitlines()
['aaaa', 'bbbb', 'ccccc', 'dddd']
Last edited 2 years ago by Jun Omae (previous) (diff)

comment:8 by Jun Omae, 2 years ago

Trivial thing: unnecessary extra \n> would be appended if description and comment are ended with newline.

> "Line 1\r\nLine 2\r\nLine 3\r\n".split(/\r?\n/).join('\n> ')
'Line 1\n> Line 2\n> Line 3\n> '
                           ^^^^
  • tracopt/ticket/htdocs/ticketclone.coffee

     
    6969        _("(part of #%(ticketid)s) %(summary)s",
    7070          ticketid: old_values.id, summary: old_values.summary)
    7171      addField cform, 'description',
    72         _("Copied from [%(source)s]:\n> %(description)s",
     72        _("Copied from [%(source)s]:\n%(description)s",
    7373          source: "ticket:#{old_values.id}#comment:#{c.cnum}",
    74           description: c.comment.split(/\r?\n/).join('\n> '))
     74          description: quoteText(c.comment))
    7575
    7676      btns.prepend cform
    7777
     
    8282  addField clone, 'summary',
    8383    _("%(summary)s (cloned)", summary: old_values.summary)
    8484  addField clone, 'description',
    85     _("Cloned from #%(id)s:\n> %(description)s\n",
     85    _("Cloned from #%(id)s:\n%(description)s",
    8686      id: old_values.id,
    87       description: old_values.description.split(/\r?\n/).join('\n> '))
     87      description: quoteText(old_values.description))
    8888  $('#ticket .description .searchable').before(clone)
    8989  # clone from comment
    9090  if old_values? and changes?
    9191    addCloneFromComments (c for c in changes when c.cnum? and
    9292                          c.comment and c.permanent)
     93
     94
     95quoteText = (text) ->
     96  if text
     97    length = text.length
     98    pattern = /\r\n|[\r\n\u000b\u000c\u001c\u001d\u001e\u0085\u2028\u2029]/g
     99    repl = (match, offset) ->
     100      if match.length + offset != length then '\n> ' else ''
     101    '> ' + text.replace(pattern, repl) + '\n'
     102  else
     103    return ''
Last edited 2 years ago by Jun Omae (previous) (diff)

comment:9 by Ryan J Ollos, 2 years ago

Thanks for the patch. It works well. Committed in r16121.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.