Rev 506: Make handle-patch not dependend on the users name being abentley and install it. in file:///data/jelmer/bzr-gtk/fix-handle-patch/
Jelmer Vernooij
jelmer at samba.org
Fri Jun 27 17:54:27 BST 2008
At file:///data/jelmer/bzr-gtk/fix-handle-patch/
------------------------------------------------------------
revno: 506
revision-id: jelmer at samba.org-20080627165356-t5ip7cyqivwye2ro
parent: iacobs at m0n5t3r.info-20080624103438-4ujpbj1h49nrfxzb
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: fix-handle-patch
timestamp: Fri 2008-06-27 18:53:56 +0200
message:
Make handle-patch not dependend on the users name being abentley and install it.
renamed:
handle-patch => bzr-handle-patch handlepatch-20080223063850-kv7c3nsqsserhwr7-1
modified:
__init__.py __init__.py-20060519165329-a1fd52c8a829fcd5
setup.py setup.py-20060716162505-h2isrtlg8lmlg2o2-1
bzr-handle-patch handlepatch-20080223063850-kv7c3nsqsserhwr7-1
=== modified file '__init__.py'
--- a/__init__.py 2008-05-22 03:43:15 +0000
+++ b/__init__.py 2008-06-27 16:53:56 +0000
@@ -22,7 +22,6 @@
gcommit GTK+ commit dialog.
gconflicts GTK+ conflicts.
gdiff Show differences in working tree in a GTK+ Window.
-ghandle-patch Display and optionally merge a merge directive or patch.
ginit Initialise a new branch.
gmissing GTK+ missing revisions dialog.
gpreferences GTK+ preferences dialog.
@@ -120,21 +119,22 @@
return None
+def open_display():
+ pygtk = import_pygtk()
+ try:
+ import gtk
+ except RuntimeError, e:
+ if str(e) == "could not open display":
+ raise NoDisplayError
+ set_ui_factory()
+ return gtk
+
+
class GTKCommand(Command):
"""Abstract class providing GTK specific run commands."""
- def open_display(self):
- pygtk = import_pygtk()
- try:
- import gtk
- except RuntimeError, e:
- if str(e) == "could not open display":
- raise NoDisplayError
- set_ui_factory()
- return gtk
-
def run(self):
- self.open_display()
+ open_display()
dialog = self.get_gtk_dialog(os.path.abspath('.'))
dialog.run()
@@ -168,7 +168,7 @@
def run(self, location="."):
(br, path) = branch.Branch.open_containing(location)
- self.open_display()
+ open_display()
from push import PushDialog
dialog = PushDialog(br.repository, br.last_revision(), br)
dialog.run()
@@ -286,7 +286,7 @@
aliases = ["gblame", "gpraise"]
def run(self, filename, all=False, plain=False, line='1', revision=None):
- gtk = self.open_display()
+ gtk = open_display()
try:
line = int(line)
@@ -345,7 +345,7 @@
def run(self, filename=None):
import os
- self.open_display()
+ open_display()
from commit import CommitDialog
from bzrlib.errors import (BzrCommandError,
NotBranchError,
@@ -386,7 +386,7 @@
def run(self, path='.', revision=None):
import os
- gtk = self.open_display()
+ gtk = open_display()
from status import StatusDialog
(wt, wt_path) = workingtree.WorkingTree.open_containing(path)
@@ -410,7 +410,7 @@
"""
def run(self):
(br, path) = branch.Branch.open_containing(".")
- gtk = self.open_display()
+ gtk = open_display()
from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog
from StringIO import StringIO
dialog = SendMergeDirectiveDialog(br)
@@ -432,7 +432,7 @@
"""
def run(self):
(wt, path) = workingtree.WorkingTree.open_containing('.')
- self.open_display()
+ open_display()
from bzrlib.plugins.gtk.conflicts import ConflictsDialog
dialog = ConflictsDialog(wt)
dialog.run()
@@ -443,7 +443,7 @@
"""
def run(self):
- self.open_display()
+ open_display()
from bzrlib.plugins.gtk.preferences import PreferencesWindow
dialog = PreferencesWindow()
dialog.run()
@@ -487,7 +487,7 @@
class cmd_ginit(GTKCommand):
def run(self):
- self.open_display()
+ open_display()
from initialize import InitDialog
dialog = InitDialog(os.path.abspath(os.path.curdir))
dialog.run()
@@ -497,7 +497,7 @@
def run(self):
br = branch.Branch.open_containing('.')[0]
- gtk = self.open_display()
+ gtk = open_display()
from tags import TagsWindow
window = TagsWindow(br)
window.show()
@@ -534,7 +534,7 @@
def run(self):
from notify import NotifyPopupMenu
- gtk = self.open_display()
+ gtk = open_display()
menu = NotifyPopupMenu()
icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
icon.connect('popup-menu', menu.display)
@@ -692,44 +692,6 @@
register_command(cmd_test_gtk)
-class cmd_ghandle_patch(GTKCommand):
- """Display a patch or merge directive, possibly merging.
-
- This is a helper, meant to be launched from other programs like browsers
- or email clients. Since these programs often do not allow parameters to
- be provided, a "handle-patch" script is included.
- """
-
- takes_args = ['path']
-
- def run(self, path):
- try:
- from bzrlib.plugins.gtk.diff import (DiffController,
- MergeDirectiveController)
- if path == '-':
- lines = sys.stdin.readlines()
- else:
- lines = open(path, 'rb').readlines()
- lines = [l.replace('\r\n', '\n') for l in lines]
- try:
- directive = merge_directive.MergeDirective.from_lines(lines)
- except errors.NotAMergeDirective:
- controller = DiffController(path, lines)
- else:
- controller = MergeDirectiveController(path, directive)
- window = controller.window
- window.show()
- gtk = self.open_display()
- window.connect("destroy", gtk.main_quit)
- except Exception, e:
- from dialog import error_dialog
- error_dialog('Error', str(e))
- raise
- gtk.main()
-
-
-register_command(cmd_ghandle_patch)
-
import gettext
gettext.install('olive-gtk')
=== renamed file 'handle-patch' => 'bzr-handle-patch'
--- a/handle-patch 2008-02-23 06:39:14 +0000
+++ b/bzr-handle-patch 2008-06-27 16:53:56 +0000
@@ -1,2 +1,39 @@
-#!/bin/sh
-/home/abentley/bin/bzr ghandle-patch "$@"
+#!/usr/bin/python
+
+from bzrlib import errors, merge_directive
+from bzrlib.plugin import load_plugins
+from bzrlib.plugins.gtk import open_display
+load_plugins()
+
+import sys
+
+if len(sys.argv) < 2:
+ print "Usage: handle-patch <path>"
+ sys.exit(1)
+
+
+path = sys.argv[1]
+
+try:
+ from bzrlib.plugins.gtk.diff import (DiffController,
+ MergeDirectiveController)
+ if path == '-':
+ lines = sys.stdin.readlines()
+ else:
+ lines = open(path, 'rb').readlines()
+ lines = [l.replace('\r\n', '\n') for l in lines]
+ try:
+ directive = merge_directive.MergeDirective.from_lines(lines)
+ except errors.NotAMergeDirective:
+ controller = DiffController(path, lines)
+ else:
+ controller = MergeDirectiveController(path, directive)
+ window = controller.window
+ window.show()
+ gtk = open_display()
+ window.connect("destroy", gtk.main_quit)
+except Exception, e:
+ from dialog import error_dialog
+ error_dialog('Error', str(e))
+ raise
+gtk.main()
=== modified file 'setup.py'
--- a/setup.py 2008-05-04 20:23:56 +0000
+++ b/setup.py 2008-06-27 16:53:56 +0000
@@ -96,7 +96,7 @@
maintainer_email = "jelmer at samba.org",
description = "GTK+ Frontends for various Bazaar commands",
license = "GNU GPL v2 or later",
- scripts=['olive-gtk'],
+ scripts=['olive-gtk', 'bzr-handle-patch'],
package_dir = {
"bzrlib.plugins.gtk": ".",
"bzrlib.plugins.gtk.viz": "viz",
More information about the bazaar-commits
mailing list