[Pkg-bazaar-commits] ./bzr-gtk/unstable r80: Integrate nautilus-bzr.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:49:17 UTC 2009


------------------------------------------------------------
revno: 80
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-gtk
timestamp: Tue 2006-09-05 22:46:39 +0200
message:
  Integrate nautilus-bzr.
added:
  nautilus-bzr.py
modified:
  AUTHORS
  README
    ------------------------------------------------------------
    revno: 0.5.1
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: nautilus-bzr
    timestamp: Wed 2006-04-12 22:53:28 +0200
    message:
      Start working on bzr integration plugin for nautilus 
    added:
      __init__.py
    ------------------------------------------------------------
    revno: 0.5.2
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sat 2006-05-13 22:15:35 -0400
    message:
      Bring this to a state where it actually works.  Specifically:
      
       * Add missing callback methods
       * Do not attempt to work on non-local URIs
       * Feed the URI, not a NautilusVFSFile to bzrlib
       * Feed the relative path to file_class
       * Put our menu items in a private BzrNautilus namespace
       * Nautilus items are done per-file, keep them within the scope of the loop.
      
      And also remove some unnecessary variable wrangling.
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 0.5.3
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 09:41:40 -0400
    message:
      Rename py file to something more useful, add README
    added:
      README
    renamed:
      __init__.py => nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.4
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 10:21:10 -0400
    message:
      Add 'add' function.  Give framework for other callbacks.
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.5
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 10:31:59 -0400
    message:
      Remove stray function definitions
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.6
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 10:35:46 -0400
    message:
      Implement remove
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.7
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 10:54:33 -0400
    message:
      Add hook for creating new bzr trees.
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.8
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 11:17:08 -0400
    message:
      Add bzrk plugin
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.9
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 11:57:58 -0400
    message:
      Implement repository creation
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.10
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 12:06:35 -0400
    message:
      [merge] Jelmer
    modified:
      README
      nautilus-bzr.py
        ------------------------------------------------------------
        revno: 0.6.1
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: nautilus-bzr
        timestamp: Sun 2006-05-14 17:58:39 +0200
        message:
          Fix undefined global error
        modified:
          nautilus-bzr.py
        ------------------------------------------------------------
        revno: 0.6.2
        committer: Jelmer Vernooij <jelmer at samba.org>
        branch nick: nautilus-bzr
        timestamp: Sun 2006-05-14 17:59:00 +0200
        message:
          Add 'Annotate' menu entry that uses the gannotate bzr plugin
        modified:
          README
          nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.11
    committer: jbailey at ubuntu.com
    branch nick: nautilus-bzr
    timestamp: Sun 2006-05-14 14:21:44 -0400
    message:
      [merge] Wouter van Heyst
    modified:
      nautilus-bzr.py
        ------------------------------------------------------------
        revno: 0.7.1
        committer: Wouter van Heyst <larstiq at larstiq.dyndns.org>
        branch nick: nautilus-bzr
        timestamp: Sun 2006-05-14 18:38:34 +0200
        message:
          use the bzrlib method of loading plugins, takes care of ~/.bazaar/plugins
        modified:
          nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.12
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: nautilus-bzr
    timestamp: Fri 2006-05-19 19:03:51 +0200
    message:
      Rename "Visualise Bazaar Branch" to "Log", which is a term 
      more people will be familiar with. 
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.13
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: nautilus-bzr
    timestamp: Fri 2006-05-19 23:21:25 +0200
    message:
      Use the gtk plugin rather than separate bzrk and gannotate
      Implement 'Diff' using bzrk's diffwindow
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.14
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: nautilus-bzr
    timestamp: Fri 2006-05-19 23:48:54 +0200
    message:
      Implement 'Diff' menu item
    modified:
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.15
    committer: Jelmer Vernooij <jelmer at samba.org>
    timestamp: Sat 2006-05-20 18:05:21 +0200
    message:
      Add 'Commit' entries
    modified:
      README
      nautilus-bzr.py
    ------------------------------------------------------------
    revno: 0.5.16
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: nautilus-bzr
    timestamp: Sat 2006-05-20 21:54:10 +0200
    message:
      Adapt to bzr-gtk's API changes, add 'Clone' dialog
    modified:
      nautilus-bzr.py
-------------- next part --------------
=== modified file 'AUTHORS'
--- a/AUTHORS	2006-09-05 02:16:09 +0000
+++ b/AUTHORS	2006-09-05 20:46:39 +0000
@@ -8,3 +8,7 @@
 
 gannotate was written by Dan Loda <danloda at gmail.com> and later maintained 
 by Aaron Bentley <abentley at panoramicfeedback.com>.
+
+nautilus-bzr was written by Jelmer Vernooij and Jeff Bailey.
+
+See the Bazaar history of this branch for a full list of authors.

=== modified file 'README'
--- a/README	2006-08-30 11:25:53 +0000
+++ b/README	2006-09-05 20:46:39 +0000
@@ -25,6 +25,10 @@
 
   * gtksourceview python bindings
 
+In order to use the nautilus integration, you will need:
+
+ * python-nautilus
+
 Installation
 ------------
 
@@ -35,6 +39,9 @@
 your bzr working tree, or adding the location of bzr-gtk to your
 BZR_PLUGIN_PATH environment variable.
 
+To use the nautilus integration, either place the nautilus-bzr.py file in
+~/.nautilus/python-extensions or in /usr/lib/nautilus/extensions-1.0/python
+
 Usage - Visualisation
 ---------------------
 

=== added file 'nautilus-bzr.py'
--- a/nautilus-bzr.py	1970-01-01 00:00:00 +0000
+++ b/nautilus-bzr.py	2006-05-20 19:54:10 +0000
@@ -0,0 +1,281 @@
+import nautilus
+import bzrlib
+from bzrlib.bzrdir import BzrDir
+from bzrlib.errors import NotBranchError
+from bzrlib.workingtree import WorkingTree
+
+from bzrlib.plugin import load_plugins
+load_plugins()
+
+try:
+    from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
+    have_gtkplugin = True
+except ImportError:
+    have_gtkplugin = False
+
+class BzrExtension(nautilus.MenuProvider):
+    def __init__(self):
+        pass
+
+    def add_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        tree.add(path)
+
+        return
+
+    def ignore_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        #FIXME
+
+        return
+
+    def unignore_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        #FIXME
+
+        return
+
+    def diff_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
+        window = DiffWindow()
+        window.set_diff(tree.branch, tree, tree.branch.revision_tree())
+        window.show()
+
+        return
+
+    def newtree_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+
+        # We only want to continue here if we get a NotBranchError
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            BzrDir.create_branch_and_repo(file)
+
+    def remove_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        tree.remove(path)
+
+    def annotate_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+
+        vis = cmd_gannotate()
+        vis.run(file)
+
+    def clone_cb(self, menu, vfs_file=None):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        from bzrlib.plugins.gtk.clone import CloneDialog
+        dialog = CloneDialog(file)
+        if dialog.run() != gtk.RESPONSE_CANCEL:
+            bzrdir = BzrDir.open(dialog.url)
+            bzrdir.sprout(dialog.dest_path)
+ 
+    def commit_cb(self, menu, vfs_file=None):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        from bzrlib.plugins.gtk.commit import GCommitDialog
+        dialog = GCommitDialog(tree)
+        dialog.set_title(path + " - Commit")
+        if dialog.run() != gtk.RESPONSE_CANCEL:
+            Commit().commit(working_tree=wt,message=dialog.message,
+                            specific_files=dialog.specific_files)
+
+    def log_cb(self, menu, vfs_file):
+        # We can only cope with local files
+        if vfs_file.get_uri_scheme() != 'file':
+            return
+
+        file = vfs_file.get_uri()
+
+        # We only want to continue here if we get a NotBranchError
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            return
+
+        vis = cmd_visualise()
+        vis.run(file)
+
+        return
+
+    def get_background_items(self, window, vfs_file):
+        file = vfs_file.get_uri()
+        try:
+            tree, path = WorkingTree.open_containing(file)
+        except NotBranchError:
+            item = nautilus.MenuItem('BzrNautilus::newtree',
+                                 'Create new Bazaar tree',
+                                 'Create new Bazaar tree in this folder')
+            item.connect('activate', self.newtree_cb, vfs_file)
+            items.append(item)
+
+            item = nautilus.MenuItem('BzrNautilus::clone',
+                                 'Checkout',
+                                 'Checkout Existing Bazaar Branch')
+            item.connect('activate', self.clone_cb, vfs_file)
+            items.append(item)
+
+            return items
+
+        items = []
+        if have_gtkplugin:
+            item = nautilus.MenuItem('BzrNautilus::log',
+                                 'Log',
+                                 'Show Bazaar history')
+            item.connect('activate', self.log_cb, vfs_file)
+            items.append(item)
+
+            item = nautilus.MenuItem('BzrNautilus::commit',
+                                 'Commit',
+                                 'Commit Changes')
+            item.connect('activate', self.commit_cb, vfs_file)
+            items.append(item)
+
+        return items
+
+
+    def get_file_items(self, window, files):
+        items = []
+
+        for vfs_file in files:
+            # We can only cope with local files
+            if vfs_file.get_uri_scheme() != 'file':
+                return
+
+            file = vfs_file.get_uri()
+            try:
+                tree, path = WorkingTree.open_containing(file)
+            except NotBranchError:
+                if not vfs_file.is_directory():
+                    return
+                item = nautilus.MenuItem('BzrNautilus::newtree',
+                                     'Create new Bazaar tree',
+                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
+                item.connect('activate', self.newtree_cb, vfs_file)
+                return item,
+
+            file_class = tree.file_class(path)
+
+            if file_class == '?':
+                item = nautilus.MenuItem('BzrNautilus::add',
+                                     'Add',
+                                     'Add as versioned file')
+                item.connect('activate', self.add_cb, vfs_file)
+                items.append(item)
+
+                item = nautilus.MenuItem('BzrNautilus::ignore',
+                                     'Ignore',
+                                     'Ignore file for versioning')
+                item.connect('activate', self.ignore_cb, vfs_file)
+                items.append(item)
+            elif file_class == 'I':
+                item = nautilus.MenuItem('BzrNautilus::unignore',
+                                     'Unignore',
+                                     'Unignore file for versioning')
+                item.connect('activate', self.unignore_cb, vfs_file)
+                items.append(item)
+            elif file_class == 'V':
+                if have_gtkplugin:
+                    item = nautilus.MenuItem('BzrNautilus::log',
+                                     'Log',
+                                     'List changes')
+                    item.connect('activate', self.log_cb, vfs_file)
+                    items.append(item)
+
+                    item = nautilus.MenuItem('BzrNautilus::diff',
+                                     'Diff',
+                                     'Show differences')
+                    item.connect('activate', self.diff_cb, vfs_file)
+                    items.append(item)
+
+                item = nautilus.MenuItem('BzrNautilus::remove',
+                                     'Remove',
+                                     'Remove this file from versioning')
+                item.connect('activate', self.remove_cb, vfs_file)
+                items.append(item)
+
+                if have_gtkplugin:
+                    item = nautilus.MenuItem('BzrNautilus::annotate',
+                                 'Annotate',
+                                 'Annotate File Data')
+                    item.connect('activate', self.annotate_cb, vfs_file)
+                    items.append(item)
+
+                    item = nautilus.MenuItem('BzrNautilus::commit',
+                                 'Commit',
+                                 'Commit Changes')
+                    item.connect('activate', self.commit_cb, vfs_file)
+                    items.append(item)
+    
+        return items



More information about the Pkg-bazaar-commits mailing list