/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2007-07-13 22:13:17 UTC
  • mfrom: (208.2.7 gtk)
  • Revision ID: jelmer@samba.org-20070713221317-ln7o6nviz4jok52e
MergeĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""GTK+ frontends to Bazaar commands """
 
17
"""Graphical support for Bazaar using GTK.
 
18
 
 
19
This plugin includes:
 
20
commit-notify     Start the graphical notifier of commits.
 
21
gannotate         GTK+ annotate. 
 
22
gbranch           GTK+ branching. 
 
23
gcheckout         GTK+ checkout. 
 
24
gcommit           GTK+ commit dialog 
 
25
gconflicts        GTK+ push. 
 
26
gdiff             Show differences in working tree in a GTK+ Window. 
 
27
ginit             Initialise a new branch.
 
28
gmissing          GTK+ missing revisions dialog. 
 
29
gpreferences      GTK+ preferences dialog. 
 
30
gpush             GTK+ push. 
 
31
gstatus           GTK+ status dialog 
 
32
gtags             Manage branch tags.
 
33
visualise         Graphically visualise this branch. 
 
34
"""
18
35
 
19
36
import bzrlib
20
37
 
196
213
            wt.unlock()
197
214
 
198
215
 
 
216
def start_viz_window(branch, revision, limit=None):
 
217
    """Start viz on branch with revision revision.
 
218
    
 
219
    :return: The viz window object.
 
220
    """
 
221
    from viz.branchwin import BranchWindow
 
222
    branch.lock_read()
 
223
    pp = BranchWindow()
 
224
    pp.set_branch(branch, revision, limit)
 
225
    # cleanup locks when the window is closed
 
226
    pp.connect("destroy", lambda w: branch.unlock())
 
227
    return pp
 
228
 
 
229
 
199
230
class cmd_visualise(Command):
200
231
    """Graphically visualise this branch.
201
232
 
207
238
    """
208
239
    takes_options = [
209
240
        "revision",
210
 
        Option('limit', "maximum number of revisions to display",
 
241
        Option('limit', "Maximum number of revisions to display.",
211
242
               int, 'count')]
212
243
    takes_args = [ "location?" ]
213
244
    aliases = [ "visualize", "vis", "viz" ]
216
247
        set_ui_factory()
217
248
        (br, path) = branch.Branch.open_containing(location)
218
249
        br.lock_read()
219
 
        br.repository.lock_read()
220
250
        try:
221
251
            if revision is None:
222
252
                revid = br.last_revision()
225
255
            else:
226
256
                (revno, revid) = revision[0].in_history(br)
227
257
 
228
 
            from viz.branchwin import BranchWindow
229
258
            import gtk
230
 
                
231
 
            pp = BranchWindow()
232
 
            pp.set_branch(br, revid, limit)
 
259
            pp = start_viz_window(br, revid, limit)
233
260
            pp.connect("destroy", lambda w: gtk.main_quit())
234
261
            pp.show()
235
262
            gtk.main()
236
263
        finally:
237
 
            br.repository.unlock()
238
264
            br.unlock()
239
265
 
240
266
 
246
272
 
247
273
    takes_args = ["filename", "line?"]
248
274
    takes_options = [
249
 
        Option("all", help="show annotations on all lines"),
250
 
        Option("plain", help="don't highlight annotation lines"),
 
275
        Option("all", help="Show annotations on all lines."),
 
276
        Option("plain", help="Don't highlight annotation lines."),
251
277
        Option("line", type=int, argname="lineno",
252
 
               help="jump to specified line number"),
 
278
               help="Jump to specified line number."),
253
279
        "revision",
254
280
    ]
255
281
    aliases = ["gblame", "gpraise"]
506
532
                body += revision.message
507
533
                body = cgi.escape(body)
508
534
                nw = pynotify.Notification(summary, body)
 
535
                def start_viz(notification=None, action=None, data=None):
 
536
                    """Start the viz program."""
 
537
                    pp = start_viz_window(branch, revision_id)
 
538
                    pp.show()
 
539
                def start_branch(notification=None, action=None, data=None):
 
540
                    """Start a Branch dialog"""
 
541
                    from bzrlib.plugins.gtk.branch import BranchDialog
 
542
                    bd = BranchDialog(remote_path=url)
 
543
                    bd.run()
 
544
                nw.add_action("inspect", "Inspect", start_viz, None)
 
545
                nw.add_action("branch", "Branch", start_branch, None)
509
546
                nw.set_timeout(5000)
510
547
                nw.show()
511
548
            except Exception, e: