File: bzr-handle-patch

package info (click to toggle)
bzr-gtk 0.103.0+bzr792-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,524 kB
  • sloc: python: 9,616; makefile: 16; sh: 10
file content (43 lines) | stat: -rwxr-xr-x 1,149 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python

from bzrlib import errors, merge_directive
from bzrlib.plugin import load_plugins
load_plugins()
from bzrlib.plugins.gtk.commands import open_display

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, allow_dirty=True)
    else:
        controller = MergeDirectiveController(path, directive)
    window = controller.window
    window.show()
    Gtk = open_display()
    window.connect("destroy", Gtk.main_quit)
except Exception, e:
    from bzrlib.plugins.gtk.dialog import error_dialog
    error_dialog('Error', str(e))
    raise

if len(sys.argv) == 3 and sys.argv[2] == 'test':
    sys.exit(0)

Gtk.main()