Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.3rc1, 0.3, and 0.4rc1

hggtk/changeset: add 'save at revision' option

* hg cat only works on revisions that include modifications to the
file, so I expanded the check for annotation to include this feature
* Checking for revlog.LookupError() also catches revisions where the
file has been deleted (removed from the manifest but not changed otherwise)
* This was added as the second item in the context menu to avoid making it
the default action when a row is activated in the file list.

Changeset 51c8bfc32a95

Parent f4e55aa73c38

by Steve Borho

Changes to one file · Browse files at 51c8bfc32a95 Showing diff from parent f4e55aa73c38 Diff from another changeset...

 
18
19
20
21
 
22
23
24
 
266
267
268
 
 
269
270
271
 
407
408
409
410
411
412
 
 
 
 
 
 
 
413
414
415
 
418
419
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
422
423
424
425
426
 
18
19
20
 
21
22
23
24
 
266
267
268
269
270
271
272
273
 
409
410
411
 
 
 
412
413
414
415
416
417
418
419
420
421
 
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
 
444
445
446
@@ -18,7 +18,7 @@
   from mercurial.i18n import _  from mercurial.node import * -from mercurial import cmdutil, util, ui, hg, commands, patch +from mercurial import cmdutil, util, ui, hg, commands, patch, revlog  from gdialog import *  from hgcmd import CmdDialog   @@ -266,6 +266,8 @@
    _menu = gtk.Menu()   _menu.append(create_menu('_view at revision', self._view_file_rev)) + self._save_menu = create_menu('_save at revision', self._save_file_rev) + _menu.append(self._save_menu)   _menu.append(create_menu('_file history', self._file_history))   self._ann_menu = create_menu('_annotate file', self._ann_file)   _menu.append(self._ann_menu) @@ -407,9 +409,13 @@
  # cannot be annotated at this revision (since this changeset   # does not appear in the filelog)   ctx = self.repo.changectx(self.currev) - fctx = ctx.filectx(self.curfile) - can_annotate = fctx.filelog().linkrev(fctx.filenode()) == ctx.rev() - self._ann_menu.set_sensitive(can_annotate) + try: + fctx = ctx.filectx(self.curfile) + has_filelog = fctx.filelog().linkrev(fctx.filenode()) == ctx.rev() + except revlog.LookupError: + has_filelog = False + self._ann_menu.set_sensitive(has_filelog) + self._save_menu.set_sensitive(has_filelog)   return True     def _file_row_act(self, tree, path, column) : @@ -418,9 +424,23 @@
  self._filemenu.get_children()[0].activate()   return True   + def _save_file_rev(self, menuitem): + file, ext = os.path.splitext(os.path.basename(self.curfile)) + filename = "%s@%d%s" % (file, self.currev, ext) + fd = NativeSaveFileDialogWrapper(Title = "Save file to", + InitialDir=self.cwd, + FileName=filename) + result = fd.run() + if result: + import Queue + import hglib + q = Queue.Queue() + cpath = util.canonpath(self.repo.root, self.cwd, self.curfile) + hglib.hgcmd_toq(self.repo.root, q, 'cat', '--rev', + str(self.currev), '--output', result, cpath) +   def _view_file_rev(self, menuitem):   '''User selected view file revision from the file list context menu''' - # TODO   rev = self.currev   parents = self.parents   if len(parents) == 0: