← Back to team overview

maria-developers team mailing list archive

Re: MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE

 

Hi, Alexey!

On Jul 16, Alexey Botchkov wrote:
> Hi, Sergei.
> 
> +++ sql/field.cc	2012-07-11 14:28:40 +0000
> @@ -9182,6 +9182,7 @@ void Create_field::init_for_tmp_table(en
> 
> > First: please, see the last section in
> > http://kb.askmonty.org/en/how-to-get-more-out-of-bzr-when-working-on-mariadb/
> > and do as it suggests
> >
> > I had to apply your patch locally and re-run bzr diff
> > to get the function names in the diff :(
> >
> 
> Wasn't able to start that last section.
> I created the .bazaar/diff_p/, the __init__.py, and .bazaar/rules files,
> then get:

it should be .bazaar/plugins/diff_p/

> $ bzr diff >dif2
>   bzr: ERROR: exceptions.UnboundLocalError: local variable 'diff_file' 
> referenced                    before assignment

Python is sentisive to indentation levels. May be you've messed up the
whitespace when copy-pasting from the kb? I'll attach the correct
__init__.py to this email.

> Although i used other tips from that page so my diff includes the 
> function's names already. Maybe that's enough.

diff_p plugin is better because it adds function names to (almost) *all*
diffs. Not only to 'bzr diff', but also to 'bzr commit' generated
emails, 'bzr log', etc.

Regards,
Sergei
#!/usr/bin/env python

"""diff -p everywhere"""

version_info = (0, 0, 3)

from bzrlib import diff
from bzrlib.trace import mutter

old_init = diff.DiffText.__init__

def new_init(self, old_tree, new_tree, to_file, path_encoding='utf-8',
    old_label='', new_label='', differ=diff.internal_diff):

  if differ == diff.internal_diff:
    def diff_file(old_filename, oldlines, new_filename, newlines, to_file,
                  allow_binary=False, sequence_matcher=None, path_encoding='utf8'):
        try:
          filename= old_filename[0:old_filename.rindex('\t')]
          re = old_tree.iter_search_rules([filename], ['diff_show_function_regex'])
          diff.external_diff(old_filename, oldlines, new_filename,
              newlines, to_file, ['-F', re.next()[0][1]])
        except (ValueError, IndexError):
          mutter("Failed to use diff_p for %s" % old_filename)
          diff.internal_diff(old_filename, oldlines, new_filename, newlines,
              to_file, allow_binary, sequence_matcher, path_encoding)
    differ = diff_file

  old_init(self, old_tree, new_tree, to_file, path_encoding,
      old_label, new_label, differ)

diff.DiffText.__init__ = new_init


Follow ups

References