by
Changes to 4 files · Browse files at fcadbfb1d6bd Showing diff from parent ecbe2d08b7f9 5cf3e36d5c10 Diff from another changeset...
|
|
@@ -10,8 +10,7 @@ import gtk
import traceback
-from mercurial import ui, util
-from hgext import bookmarks
+from mercurial import ui, util, commands
from tortoisehg.util.i18n import _
from tortoisehg.util import hglib, i18n, settings
@@ -20,12 +19,10 @@
TYPE_ADDREMOVE = 1
TYPE_RENAME = 2
-TYPE_CURRENT = 3
RESPONSE_ADD = 1
RESPONSE_REMOVE = 2
RESPONSE_RENAME = 3
-RESPONSE_CURRENT = 4
RESPONSE_MOVE = 5
class BookmarkDialog(gtk.Dialog):
@@ -50,8 +47,6 @@ self.add_button(_('Remove'), RESPONSE_REMOVE)
elif type == TYPE_RENAME:
self.add_button(_('Rename'), RESPONSE_RENAME)
- elif type == TYPE_CURRENT:
- self.add_button(_('Set Current'), RESPONSE_CURRENT)
else:
raise _('unexpected type: %s') % type
self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
@@ -72,40 +67,25 @@ table.add_row(label, self._bookmarklistbox, padding=False)
## add entry
- if type == TYPE_CURRENT:
- entry = None
- else:
- entry = gtk.Entry()
- if type == TYPE_ADDREMOVE:
- self._rev_input = entry
- entry.set_width_chars(12)
- entry.set_text(rev)
- label = _('Revision:')
- elif type == TYPE_RENAME:
- self._name_input = entry
- label = _('New Name:')
- table.add_row(label, entry, padding=False)
-
- # Option to make new bookmark the active one
- trackcurrent = self.repo.ui.configbool('bookmarks', 'track.current')
- if type == TYPE_ADDREMOVE and trackcurrent:
- check = gtk.CheckButton(_('Make new/moved bookmark current'))
- self.opt_newcurrent = check
- check.set_sensitive(hglib.is_rev_current(self.repo, rev))
- table.add_row(None, check)
-
+ entry = gtk.Entry()
+ if type == TYPE_ADDREMOVE:
+ self._rev_input = entry
+ entry.set_width_chars(12)
+ entry.set_text(rev)
+ label = _('Revision:')
+ elif type == TYPE_RENAME:
+ self._name_input = entry
+ label = _('New Name:')
+ table.add_row(label, entry, padding=False)
+
# signal handlers
self.connect('response', self.dialog_response)
self._bookmark_input.connect('activate', self.entry_activated, type)
- if entry:
- entry.connect('activate', self.entry_activated, type)
+ entry.connect('activate', self.entry_activated, type)
if type == TYPE_ADDREMOVE:
self._bookmark_input.connect('changed', self.bookmark_changed)
- if trackcurrent:
- self._rev_input.connect('changed', self.rev_changed)
# prepare to show
- self.load_settings()
if type == TYPE_ADDREMOVE:
self.set_add_move_button_sensitivity()
self._refresh(clear=False)
@@ -120,28 +100,15 @@ self._bookmarkslist.clear()
# add bookmarks to drop-down list
- bookmarks = hglib.get_repo_bookmarks(self.repo)
- bookmarks.sort()
- for bookmarkname in bookmarks:
- if bookmarkname != 'tip':
- self._bookmarkslist.append([bookmarkname])
+ marks = self.repo._bookmarks.keys()
+ marks.sort()
+ for mark in marks:
+ self._bookmarkslist.append([mark])
# clear bookmark name input
if clear:
self._bookmark_input.set_text('')
- def load_settings(self):
- if hasattr(self, 'opt_newcurrent'):
- newcurrent = self.settings.get_value('newcurrent', False)
- self.opt_newcurrent.set_active(newcurrent)
-
- def store_settings(self):
- if hasattr(self, 'opt_newcurrent'):
- newcurrent = self.opt_newcurrent.get_active()
- self.settings.set_value('newcurrent', newcurrent)
-
- self.settings.write()
-
def dialog_response(self, dialog, response_id):
# Add button
if response_id == RESPONSE_ADD:
@@ -155,12 +122,9 @@ # Rename button
elif response_id == RESPONSE_RENAME:
self._do_rename_bookmark()
- # Set Current button
- elif response_id == RESPONSE_CURRENT:
- self._do_current_bookmark()
# Close button or closed by the user
elif response_id in (gtk.RESPONSE_CLOSE, gtk.RESPONSE_DELETE_EVENT):
- self.store_settings()
+ self.settings.write()
self.destroy()
return # close dialog
else:
@@ -176,8 +140,6 @@ self.response(RESPONSE_MOVE)
elif type == TYPE_RENAME:
self.response(RESPONSE_RENAME)
- elif type == TYPE_CURRENT:
- self.response(RESPONSE_CURRENT)
else:
raise _('unexpected type: %s') % type
@@ -190,13 +152,13 @@
def set_add_move_button_sensitivity(self):
mark = self._bookmark_input.get_text()
- if mark in hglib.get_repo_bookmarks(self.repo):
+ if mark in self.repo._bookmarks:
self._button_add.set_sensitive(False)
self._button_move.set_sensitive(True)
else:
self._button_add.set_sensitive(True)
self._button_move.set_sensitive(False)
-
+
def _do_add_bookmark(self):
# gather input data
@@ -215,10 +177,6 @@ self._add_hg_bookmark(name, rev)
dialog.info_dialog(self, _('Bookmarking completed'),
_('Bookmark "%s" has been added') % name)
- if (hasattr(self, 'opt_newcurrent') and
- self.opt_newcurrent.get_property('sensitive') and
- self.opt_newcurrent.get_active()):
- self._current_hg_bookmark(name)
self._refresh()
except util.Abort, inst:
dialog.error_dialog(self, _('Error in bookmarking'), str(inst))
@@ -245,10 +203,6 @@ self._move_hg_bookmark(name, rev)
dialog.info_dialog(self, _('Bookmarking completed'),
_('Bookmark "%s" has been moved') % name)
- if (hasattr(self, 'opt_newcurrent') and
- self.opt_newcurrent.get_property('sensitive') and
- self.opt_newcurrent.get_active()):
- self._current_hg_bookmark(name)
self._refresh()
except util.Abort, inst:
dialog.error_dialog(self, _('Error in bookmarking'), str(inst))
@@ -315,69 +269,27 @@ traceback.format_exc())
return False
- def _do_current_bookmark(self):
- # gather input data
- name = self._bookmark_input.get_text()
-
- # verify input
- if name == '':
- dialog.error_dialog(self, _('Bookmark input is empty'),
- _('Please enter bookmark name'))
- self._bookmark_input.grab_focus()
- return False
-
- # set current bookmark
- try:
- self._current_hg_bookmark(name)
- dialog.info_dialog(self, _('Bookmarking completed'),
- _('Bookmark "%s" has been made current') %
- name)
- self._refresh()
- except util.Abort, inst:
- dialog.error_dialog(self, _('Error in bookmarking'), str(inst))
- return False
- except:
- dialog.error_dialog(self, _('Error in bookmarking'),
- traceback.format_exc())
- return False
-
def _add_hg_bookmark(self, name, revision):
- if name in hglib.get_repo_bookmarks(self.repo):
+ repo = self.repo
+ if name in repo._bookmarks:
raise util.Abort(_('a bookmark named "%s" already exists') % name)
-
- bookmarks.bookmark(ui=ui.ui(),
- repo=self.repo,
- rev=revision,
- mark=name)
+ commands.bookmark(repo.ui, repo, name, revision, True)
def _move_hg_bookmark(self, name, revision):
- if name not in hglib.get_repo_bookmarks(self.repo):
+ repo = self.repo
+ if name not in repo._bookmarks:
raise util.Abort(_('No bookmark named "%s" exists') % name)
- bookmarks.bookmark(ui=ui.ui(),
- repo=self.repo,
- rev=revision,
- mark=name,
- force=True)
-
+ commands.bookmark(repo.ui, repo, name, revision, True)
+
def _remove_hg_bookmark(self, name):
- if not name in hglib.get_repo_bookmarks(self.repo):
+ repo = self.repo
+ if not name in repo._bookmarks:
raise util.Abort(_("Bookmark '%s' does not exist") % name)
-
- bookmarks.bookmark(ui=ui.ui(),
- repo=self.repo,
- mark=name,
- delete=True)
+ commands.bookmark(repo.ui, repo, name, None, True, True)
def _rename_hg_bookmark(self, name, new_name):
- if new_name in hglib.get_repo_bookmarks(self.repo):
+ repo = self.repo
+ if new_name in repo._bookmarks:
raise util.Abort(_('a bookmark named "%s" already exists') %
new_name)
- bookmarks.bookmark(ui=ui.ui(),
- repo=self.repo,
- mark=new_name,
- rename=name)
-
- def _current_hg_bookmark(self, name):
- if name not in hglib.get_repo_bookmarks(self.repo):
- raise util.Abort(_('No bookmark named "%s" exists') % name)
- bookmarks.setcurrent(self.repo, name)
+ commands.bookmark(repo.ui, repo, new_name, None, True, False, name)
|
@@ -55,11 +55,13 @@ self.graphdata = graphdata
self.revisions, self.parents = {}, {}
self.wcparents, self.tagrevs, self.branchtags = [], [], {}
+ self.bookmarkrevs = []
self.refresh()
def refresh(self):
repo = self.repo
oldtags, oldparents = self.tagrevs, self.wcparents
+ oldbookmarks = self.bookmarkrevs
try:
oldbranches = [repo[n].rev() for n in self.branchtags.values()]
except error.RepoLookupError:
@@ -71,16 +73,17 @@ self.set_author_color()
self.hidetags = hglib.gethidetags(repo.ui)
- self.curbookmark = hglib.get_repo_bookmarkcurrent(repo)
try:
self.wcparents = [x.rev() for x in repo.parents()]
self.tagrevs = [repo[r].rev() for t, r in repo.tagslist()]
self.branchtags = repo.branchtags()
+ self.curbookmark = repo._bookmarkcurrent
+ self.bookmarkrevs = [repo[n].rev() for n in repo._bookmarks.values()]
except util.Abort:
pass
brevs = [repo[n].rev() for n in self.branchtags.values()]
- allrevs = set(oldtags + oldparents + oldbranches +
- brevs + self.wcparents + self.tagrevs)
+ allrevs = set(oldtags + oldparents + oldbranches + oldbookmarks +
+ brevs + self.wcparents + self.tagrevs + self.bookmarkrevs)
for rev in allrevs:
if rev in self.revisions:
del self.revisions[rev]
@@ -219,19 +222,24 @@ escape = gtklib.markup_escape_text
summary = escape(hglib.toutf(summary))
- node = ctx.node()
- tags = self.repo.nodetags(node)
tstr = ''
- for tag in tags:
+ for tag in ctx.tags():
if tag not in self.hidetags:
- bg = gtklib.PYELLOW
- if tag == self.curbookmark:
- bg = gtklib.PORANGE
- elif tag in self.mqpatches:
+ if tag in self.mqpatches:
bg = gtklib.PBLUE
+ else:
+ bg = gtklib.PYELLOW
style = {'color': gtklib.BLACK, 'background': bg}
tstr += gtklib.markup(' %s ' % tag, **style) + ' '
+ for mark in ctx.bookmarks():
+ if mark == self.curbookmark:
+ bg = gtklib.PORANGE
+ else:
+ bg = gtklib.PLIME
+ style = {'color': gtklib.BLACK, 'background': bg}
+ tstr += gtklib.markup(' %s ' % mark, **style) + ' '
+ node = ctx.node()
branch = ctx.branch()
bstr = ''
status = 0
|
|
@@ -249,25 +249,14 @@
def invalidaterepo(repo):
repo.dirstate.invalidate()
+ for attr in ('_bookmarks', '_bookmarkcurrent'):
+ if attr in repo.__dict__:
+ delattr(repo, attr)
if isinstance(repo, bundlerepo.bundlerepository):
# Work around a bug in hg-1.3. repo.invalidate() breaks
# overlay bundlerepos
return
repo.invalidate()
- # way _bookmarks / _bookmarkcurrent cached changed
- # from 1.4 to 1.5...
- for cachedAttr in ('_bookmarks', '_bookmarkcurrent'):
- # Check if it's a property or normal value...
- if is_descriptor(repo, cachedAttr):
- # The very act of calling hasattr would
- # re-cache the property, so just assume it's
- # already cached, and catch the error if it wasn't.
- try:
- delattr(repo, cachedAttr)
- except AttributeError:
- pass
- elif hasattr(repo, cachedAttr):
- setattr(repo, cachedAttr, None)
if 'mq' in repo.__dict__: #do not create if it does not exist
repo.mq.invalidate()
@@ -563,59 +552,6 @@ return_path = path_aux
return return_path
-def get_repo_bookmarks(repo, values=False):
- """
- Will return the bookmarks for the given repo if the
- bookmarks extension is loaded.
-
- By default, returns a list of bookmark names; if
- values is True, returns a dict mapping names to
- nodes.
-
- If the extension is not loaded, returns an empty
- list/dict.
- """
- try:
- bookmarks = extensions.find('bookmarks')
- except KeyError:
- return values and {} or []
- if bookmarks:
- # Bookmarks changed from 1.4 to 1.5...
- if hasattr(bookmarks, 'parse'):
- marks = bookmarks.parse(repo)
- elif hasattr(repo, '_bookmarks'):
- marks = repo._bookmarks
- else:
- marks = {}
- else:
- marks = {}
-
- if values:
- return marks
- else:
- return marks.keys()
-
-def get_repo_bookmarkcurrent(repo):
- """
- Will return the current bookmark for the given repo
- if the bookmarks extension is loaded, and the
- track.current option is on.
-
- If the extension is not loaded, or track.current
- is not set, returns None
- """
- try:
- bookmarks = extensions.find('bookmarks')
- except KeyError:
- return None
- if bookmarks and repo.ui.configbool('bookmarks', 'track.current'):
- # Bookmarks changed from 1.4 to 1.5...
- if hasattr(bookmarks, 'current'):
- return bookmarks.current(repo)
- elif hasattr(repo, '_bookmarkcurrent'):
- return repo._bookmarkcurrent
- return None
-
def is_rev_current(repo, rev):
'''
Returns True if the revision indicated by 'rev' is the current
|
Loading...