Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12928 closed enhancement (fixed)

Suggest Mercurial bookmarks

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Component: WikiAutoCompletePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

  • wikiautocomplete/web_ui.py

    diff -r fb04791b695e -r 8006a52d8581 wikiautocomplete/web_ui.py
    a b  
    147147                                rev = repos.short_rev(r[1])
    148148                                if str(rev).startswith(search_rev):
    149149                                    completions.append('%s%s@%s' % (reponame, path, rev))
     150
     151                        if type(repos).__name__ == 'MercurialRepository':
     152                            from mercurial.bookmarks import listbookmarks
     153                            for rev in listbookmarks(repos.repo):
     154                                if str(rev).startswith(search_rev):
     155                                    completions.append('%s%s@%s' % (reponame, path, rev))
     156
    150157                    else:
    151158                        dir, filename = path.rsplit('/', 1)
    152159                        if dir == '':

Attachments (0)

Change History (7)

comment:1 Changed 8 years ago by Peter Suter

Component: SELECT A HACKWikiAutoCompletePlugin
Owner: set to Peter Suter

comment:2 Changed 8 years ago by Jun Omae

We could use repos.get_quickjump_entries() for branches, tags and bookmarks in Git and Mercurial.

  • wikiautocomplete/web_ui.py

    diff --git a/wikiautocomplete/web_ui.py b/wikiautocomplete/web_ui.py
    index 6b7b7fb..06ed25c 100644
    a b class WikiAutoCompleteModule(Component): 
    163162                        path, search_rev = path.rsplit('@', 1)
    164163                        node = repos.get_node(path, repos.youngest_rev)
    165164                        if node.can_view(req.perm):
     165                            for category, name_, path_, rev in repos.get_quickjump_entries(None):
     166                                if path_ and path_ != '/':
     167                                    # skip 'trunk', 'branches/...', 'tags/...'
     168                                    continue
     169                                if ' ' in name_:
     170                                    # use first token, e.g. '1.0' from '1.0 (tip)'
     171                                    name_ = name_.split(' ', 1)[0]
     172                                if name_.startswith(search_rev):
     173                                    completions.append('%s/%s@%s' % (reponame, path, name_))
    166174                            for r in node.get_history(10):
    167175                                if str(r[1]).startswith(search_rev):
    168176                                    completions.append('%s/%s@%s' % (reponame, path, r[1]))

Also, I use - character in repository name. In this case, completion doesn't work.

  • wikiautocomplete/htdocs/js/wikiautocomplete.js

    diff --git a/wikiautocomplete/htdocs/js/wikiautocomplete.js b/wikiautocomplete/htdocs/js/wikiautocomplete.js
    index 2b14015..bcb282a 100644
    a b jQuery(document).ready(function($) { 
    6363        },
    6464
    6565        { // Source
    66             match: /\b(source:|log:)([\w/.]*(?:@\w*)?)$/,
     66            match: /\b(source:|log:)([^@\s]*(?:@\S*)?)$/,
    6767            search: function (term, callback) {
    6868                $.getJSON(wikiautocomplete_url + '/source', { q: term })
    6969                    .done(function (resp) { callback(resp); })

comment:3 in reply to:  2 Changed 8 years ago by Peter Suter

Also, I use - character in repository name. In this case, completion doesn't work.

Fixed in #12938, thanks!

comment:4 Changed 8 years ago by Peter Suter

Replying to jun66j5:

We could use repos.get_quickjump_entries() for branches, tags and bookmarks in Git and Mercurial.

Sounds nice. The entry names are a bit fragile:

  • Categories are translated in Mercurial (but not in Git or SVN).
  • Mercurial tags are joined so name == "FirstTag, SecondTag". (If one revision has multiple tags.)

Also there can be a lot of unimportant entries (e.g. due to old tags). I think the current revision number is much more useful. So maybe only suggest the names if at least one character is given? (Not a great solution.)

comment:5 Changed 8 years ago by Peter Suter

In 15956:

WikiAutoCompletePlugin: Suggest bookmarks etc.
Only if at least one character is already given, so by default the latest rev is shown first.
(see #12928)

comment:6 Changed 8 years ago by Peter Suter

Resolution: fixed
Status: newclosed

(Better ideas welcome.)

comment:7 Changed 8 years ago by Peter Suter

Somehow not all Mercurial bookmarks are shown.

Maybe because of t:ticket:12177?

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'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.