/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
505.1.1 by Jelmer Vernooij
Make handle-patch not dependend on the users name being abentley and install it.
1
#!/usr/bin/python
2
3
from bzrlib import errors, merge_directive
4
from bzrlib.plugin import load_plugins
727 by Fabio Zanini
Fix import of open_display in bzr-handle-patch.
5
from bzrlib.plugins.gtk.commands import open_display
6
505.1.1 by Jelmer Vernooij
Make handle-patch not dependend on the users name being abentley and install it.
7
load_plugins()
8
9
import sys
10
11
if len(sys.argv) < 2:
12
	print "Usage: handle-patch <path>"
13
	sys.exit(1)
14
15
16
path = sys.argv[1]
17
18
try:
19
	from bzrlib.plugins.gtk.diff import (DiffController,
20
										 MergeDirectiveController)
21
	if path == '-':
22
		lines = sys.stdin.readlines()
23
	else:
24
		lines = open(path, 'rb').readlines()
25
	lines = [l.replace('\r\n', '\n') for l in lines]
26
	try:
27
		directive = merge_directive.MergeDirective.from_lines(lines)
28
	except errors.NotAMergeDirective:
688.3.1 by Toshio Kuratomi
Fix bzr-handle-patch to process patches with leading and trailing comments with
29
		controller = DiffController(path, lines, allow_dirty=True)
505.1.1 by Jelmer Vernooij
Make handle-patch not dependend on the users name being abentley and install it.
30
	else:
31
		controller = MergeDirectiveController(path, directive)
32
	window = controller.window
33
	window.show()
734.1.2 by Curtis Hovey
Removed import_pygtk because gi does not impicitly call Main(). Inlined checks for gtk availablility.
34
	Gtk = open_display()
505.1.1 by Jelmer Vernooij
Make handle-patch not dependend on the users name being abentley and install it.
35
	window.connect("destroy", gtk.main_quit)
36
except Exception, e:
666.3.1 by Toshio Kuratomi
Fix import of error_dialog.
37
	from bzrlib.plugins.gtk.dialog import error_dialog
505.1.1 by Jelmer Vernooij
Make handle-patch not dependend on the users name being abentley and install it.
38
	error_dialog('Error', str(e))
39
	raise
40
gtk.main()