/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to patches/ndiff.patch

  • Committer: Martin Pool
  • Date: 2005-06-28 03:02:31 UTC
  • Revision ID: mbp@sourcefrog.net-20050628030231-d311e4ebcd467ef4
Merge John's import-speedup branch:

                                                                                         
  777 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:32 -0500
      revision-id: john@arbash-meinel.com-20050627032031-e82a50db3863b18e
      bzr selftest was not using the correct bzr

  776 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:20:22 -0500
      revision-id: john@arbash-meinel.com-20050627032021-c9f21fde989ddaee
      Add was using an old mutter

  775 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 22:02:33 -0500
      revision-id: john@arbash-meinel.com-20050627030233-9165cfe98fc63298
      Cleaned up to be less different

  774 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:54:53 -0500
      revision-id: john@arbash-meinel.com-20050627025452-4260d0e744edef43
      Allow BZR_PLUGIN_PATH='' to negate plugin loading.

  773 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:49:34 -0500
      revision-id: john@arbash-meinel.com-20050627024933-b7158f67b7b9eae5
      Finished the previous cleanup (allowing load_plugins to be called twice)

  772 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:45:08 -0500
      revision-id: john@arbash-meinel.com-20050627024508-723b1df510d196fc
      Work on making the tests pass. versioning.py is calling run_cmd directly, but plugins have been loaded.

  771 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:32:29 -0500
      revision-id: john@arbash-meinel.com-20050627023228-79972744d7c53e15
      Got it down a little bit more by removing import of tree and inventory.

  770 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 21:26:05 -0500
      revision-id: john@arbash-meinel.com-20050627022604-350b9773ef622f95
      Reducing the number of import from bzrlib/__init__.py and bzrlib/branch.py

  769 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:32:25 -0500
      revision-id: john@arbash-meinel.com-20050627013225-32dd044f10d23948
      Updated revision.py and xml.py to include SubElement.

  768 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:56 -0500
      revision-id: john@arbash-meinel.com-20050627010356-ee66919e1c377faf
      Minor typo

  767 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 20:03:13 -0500
      revision-id: john@arbash-meinel.com-20050627010312-40d024007eb85051
      Caching the import

  766 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:51:47 -0500
      revision-id: john@arbash-meinel.com-20050627005147-5281c99e48ed1834
      Created wrapper functions for lazy import of ElementTree

  765 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:46:37 -0500
      revision-id: john@arbash-meinel.com-20050627004636-bf432902004a94c5
      Removed all of the test imports of cElementTree

  764 John Arbash Meinel <john@arbash-meinel.com>       Sun 2005-06-26 19:43:59 -0500
      revision-id: john@arbash-meinel.com-20050627004358-d137fbe9570dd71b
      Trying to make bzr startup faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
*** modified file 'bzrlib/commands.py'
2
 
--- bzrlib/commands.py 
3
 
+++ bzrlib/commands.py 
4
 
@@ -721,10 +721,11 @@
5
 
     """
6
 
     
7
 
     takes_args = ['file*']
8
 
-    takes_options = ['revision', 'diff-options']
9
 
+    takes_options = ['revision', 'diff-options', 'ndiff']
10
 
     aliases = ['di', 'dif']
11
 
 
12
 
-    def run(self, revision=None, file_list=None, diff_options=None):
13
 
+    def run(self, revision=None, file_list=None, diff_options=None,
14
 
+            ndiff=None):
15
 
         from bzrlib.diff import show_diff
16
 
 
17
 
         if file_list:
18
 
@@ -735,9 +736,15 @@
19
 
                 file_list = None
20
 
         else:
21
 
             b = find_branch('.')
22
 
-    
23
 
+
24
 
+        if ndiff:
25
 
+            format = 'ndiff'
26
 
+        else:
27
 
+            format = None
28
 
+
29
 
         show_diff(b, revision, specific_files=file_list,
30
 
-                  external_diff_options=diff_options)
31
 
+                  external_diff_options=diff_options,
32
 
+                  format=format)
33
 
 
34
 
 
35
 
         
36
 
@@ -1344,6 +1351,7 @@
37
 
     'format':                 unicode,
38
 
     'forward':                None,
39
 
     'message':                unicode,
40
 
+    'ndiff':                  None,
41
 
     'no-recurse':             None,
42
 
     'profile':                None,
43
 
     'revision':               _parse_revision_str,
44
 
 
45
 
*** modified file 'bzrlib/diff.py'
46
 
--- bzrlib/diff.py 
47
 
+++ bzrlib/diff.py 
48
 
@@ -70,6 +70,13 @@
49
 
     print >>to_file
50
 
 
51
 
 
52
 
+
53
 
+def internal_ndiff(old_label, oldlines,
54
 
+                   new_label, newlines,
55
 
+                   to_file):
56
 
+    """Show diff in python-specific ndiff format."""
57
 
+    from difflib import ndiff
58
 
+    to_file.writelines(ndiff(oldlines, newlines))
59
 
 
60
 
 
61
 
 def external_diff(old_label, oldlines, new_label, newlines, to_file,
62
 
@@ -152,7 +159,8 @@
63
 
     
64
 
 
65
 
 
66
 
-def show_diff(b, revision, specific_files, external_diff_options=None):
67
 
+def show_diff(b, revision, specific_files, external_diff_options=None,
68
 
+              format=None):
69
 
     """Shortcut for showing the diff to the working tree.
70
 
 
71
 
     b
72
 
@@ -160,6 +168,9 @@
73
 
 
74
 
     revision
75
 
         None for each, or otherwise the old revision to compare against.
76
 
+
77
 
+    format
78
 
+        'unified', 'context', 'ndiff', 'external'
79
 
     
80
 
     The more general form is show_diff_trees(), where the caller
81
 
     supplies any two trees.
82
 
@@ -174,12 +185,13 @@
83
 
     new_tree = b.working_tree()
84
 
 
85
 
     show_diff_trees(old_tree, new_tree, sys.stdout, specific_files,
86
 
-                    external_diff_options)
87
 
+                    external_diff_options, format)
88
 
 
89
 
 
90
 
 
91
 
 def show_diff_trees(old_tree, new_tree, to_file, specific_files=None,
92
 
-                    external_diff_options=None):
93
 
+                    external_diff_options=None,
94
 
+                    format=None):
95
 
     """Show in text form the changes from one tree to another.
96
 
 
97
 
     to_files
98
 
@@ -204,10 +216,12 @@
99
 
     if external_diff_options:
100
 
         assert isinstance(external_diff_options, basestring)
101
 
         opts = external_diff_options.split()
102
 
-        def diff_file(olab, olines, nlab, nlines, to_file):
103
 
+        def diff_fn(olab, olines, nlab, nlines, to_file):
104
 
             external_diff(olab, olines, nlab, nlines, to_file, opts)
105
 
+    elif format == 'ndiff':
106
 
+        diff_fn = internal_ndiff
107
 
     else:
108
 
-        diff_file = internal_diff
109
 
+        diff_fn = internal_diff
110
 
     
111
 
 
112
 
     delta = compare_trees(old_tree, new_tree, want_unchanged=False,
113
 
@@ -216,7 +230,7 @@
114
 
     for path, file_id, kind in delta.removed:
115
 
         print >>to_file, '*** removed %s %r' % (kind, path)
116
 
         if kind == 'file':
117
 
-            diff_file(old_label + path,
118
 
+            diff_fn(old_label + path,
119
 
                       old_tree.get_file(file_id).readlines(),
120
 
                       DEVNULL, 
121
 
                       [],
122
 
@@ -225,7 +239,7 @@
123
 
     for path, file_id, kind in delta.added:
124
 
         print >>to_file, '*** added %s %r' % (kind, path)
125
 
         if kind == 'file':
126
 
-            diff_file(DEVNULL,
127
 
+            diff_fn(DEVNULL,
128
 
                       [],
129
 
                       new_label + path,
130
 
                       new_tree.get_file(file_id).readlines(),
131
 
@@ -234,7 +248,7 @@
132
 
     for old_path, new_path, file_id, kind, text_modified in delta.renamed:
133
 
         print >>to_file, '*** renamed %s %r => %r' % (kind, old_path, new_path)
134
 
         if text_modified:
135
 
-            diff_file(old_label + old_path,
136
 
+            diff_fn(old_label + old_path,
137
 
                       old_tree.get_file(file_id).readlines(),
138
 
                       new_label + new_path,
139
 
                       new_tree.get_file(file_id).readlines(),
140
 
@@ -243,7 +257,7 @@
141
 
     for path, file_id, kind in delta.modified:
142
 
         print >>to_file, '*** modified %s %r' % (kind, path)
143
 
         if kind == 'file':
144
 
-            diff_file(old_label + path,
145
 
+            diff_fn(old_label + path,
146
 
                       old_tree.get_file(file_id).readlines(),
147
 
                       new_label + path,
148
 
                       new_tree.get_file(file_id).readlines(),
149