Edgewall Software
Modify

Opened 11 years ago

Closed 7 years ago

#10527 closed enhancement (fixed)

Mercurial bookmarks as properties in browser

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Milestone: plugin - mercurial
Component: plugin/mercurial Version: 0.13dev
Severity: normal Keywords: bookmarks
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

It would be nice if the TracMercurial plugin would show bookmarks as properties on TracChangeset pages.

This seems quite simple:

  • backend.py

     
    174174
    175175    def match_property(self, name, mode):
    176176        return (name.startswith('hg-') and
    177                 name[3:] in ('Parents', 'Children', 'Tags', 'Branch') and
     177                name[3:] in ('Parents', 'Children', 'Tags', 'Branch',
     178                             'Bookmarks') and
    178179                mode == 'revprop') and 4 or 0
    179180   
    180181    def render_property(self, name, mode, context, props):
     
    11891190        tags = self.get_tags()
    11901191        if len(tags):
    11911192            properties['hg-Tags'] = (self.repos, tags)
     1193        bookmarks = self.ctx.bookmarks()
     1194        if len(bookmarks):
     1195            properties['hg-Bookmarks'] = (self.repos, bookmarks)
    11921196        for k, v in self.ctx.extra().iteritems():
    11931197            if k != 'branch':
    11941198                properties['hg-' + k] = (self.repos, v)

Unfortunately there is a catch: Changeset pages are cached, but modifying a bookmark currently does not invalidate that cache.

Attachments (2)

T10527-trac-bookmarks-API.diff (4.4 KB ) - added by Peter Suter 7 years ago.
T10527-mercurial-plugin-bookmarks-API.diff (628 bytes ) - added by Peter Suter 7 years ago.

Download all attachments as: .zip

Change History (12)

in reply to:  description comment:1 by Christian Boos, 10 years ago

Keywords: bookmarks added
Version: 0.13dev

Replying to psuter:

It would be nice if the TracMercurial plugin would show bookmarks as properties on

As properties, and also in the TracBrowser view, same as we do for tags and branches (in blue?).

Unfortunately there is a catch: Changeset pages are cached, but modifying a bookmark currently does not invalidate that cache.

What about adding all the properties in the mix?

In the meantime, I already added the above in [f261cc084df2/mercurial-plugin].

comment:2 by pbuck@…, 10 years ago

need to catch lack of bookmarks (if extension not configured in HG). Suggest something like

  try:
    bookmarks = self.ctx.bookmarks()
  except AttributeError:
    bookmarks = []

… I don't have bookmarks enabled, so I can't say if this is good otherwise.

comment:3 by Christian Boos, 10 years ago

Oops, didn't see (or paid attention to) the above comment, and now we have #10908 :-(

comment:4 by pykler@…, 10 years ago

Should bookmarks appear under the dropdown for branches and tags, it doesn't for me and following the code does not seem to point that it would.

Since bookmarks are lightweight branches it would be nice if this is possible.

in reply to:  4 comment:5 by anonymous, 7 years ago

Replying to pykler@…:

Should bookmarks appear under the dropdown for branches and tags, it doesn't for me and following the code does not seem to point that it would.

Looks like changeset:d1913701fd5b/mercurial-plugin implemented this.

I would love to also see the bookmarks in the TracRevisionLog, similar to branch heads and tags.

by Peter Suter, 7 years ago

comment:6 by Peter Suter, 7 years ago

The first patch for Trac itself adds a new API method Changeset.get_bookmarks() and uses it to show bookmarks as blue labels on the revision log, browser pages and timeline (just like Changeset.get_tags()).

The second patch for the mercurial-plugin simply implements that API.

Should I open a new ticket for the first patch targeting Trac 1.1.5?

comment:7 by Peter Suter, 7 years ago

Owner: set to Peter Suter
Status: newassigned

in reply to:  6 comment:8 by Ryan J Ollos, 7 years ago

Replying to psuter:

Should I open a new ticket for the first patch targeting Trac 1.1.5?

That seems like a good idea so that we have an API Changes entry for 1.1.5.

comment:9 by Peter Suter, 7 years ago

Right, I created #11995 for that.

comment:10 by Peter Suter, 7 years ago

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Peter Suter to the specified user.

Add Comment


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