Merge branch 'cassandra-1.2' into trunk

Conflicts:
        bin/cqlsh
        pylib/cqlshlib/test/test_cqlsh_completion.py
        pylib/cqlshlib/test/test_cqlsh_output.py


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4f7e2b80
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4f7e2b80
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4f7e2b80

Branch: refs/heads/trunk
Commit: 4f7e2b801894614266d8284bd41e7d2676c8773b
Parents: d78b622 87450cb
Author: Aleksey Yeschenko <alek...@apache.org>
Authored: Wed May 29 21:12:08 2013 +0300
Committer: Aleksey Yeschenko <alek...@apache.org>
Committed: Wed May 29 21:12:08 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                  |    1 +
 bin/cqlsh                                    |   70 ++++++++++++++++++++-
 pylib/cqlshlib/test/test_cqlsh_completion.py |    4 +-
 3 files changed, 71 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4f7e2b80/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4f7e2b80/bin/cqlsh
----------------------------------------------------------------------
diff --cc bin/cqlsh
index 977603b,1abd078..5741c31
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@@ -952,6 -1138,29 +962,20 @@@ class Shell(cmd.Cmd)
              line = ' | '.join(col.rjust(w, color=self.color) for (col, w) in 
zip(row, widths))
              self.writeresult(' ' + line)
  
+     def print_formatted_result_vertically(self, formatted_names, 
formatted_values):
+         max_col_width = max([n.displaywidth for n in formatted_names])
+         max_val_width = max([n.displaywidth for row in formatted_values for n 
in row])
+ 
+         # for each row returned, list all the column-value pairs
+         for row_id, row in enumerate(formatted_values):
+             self.writeresult("@ Row %d" % (row_id + 1))
+             self.writeresult('-%s-' % '-+-'.join(['-' * max_col_width, '-' * 
max_val_width]))
+             for field_id, field in enumerate(row):
+                 column = formatted_names[field_id].ljust(max_col_width, 
color=self.color)
+                 value = field.ljust(field.displaywidth, color=self.color)
+                 self.writeresult(' ' + " | ".join([column, value]))
+             self.writeresult('')
+ 
 -    def print_dynamic_result(self, cursor):
 -        for row in cursor:
 -            colnames = [d[0] for d in cursor.description]
 -            colnames_t = [(name, self.get_nametype(cursor, n)) for (n, name) 
in enumerate(colnames)]
 -            colnames = [self.myformat_colname(name, nametype) for (name, 
nametype) in colnames_t]
 -            colvals = map(self.myformat_value, row, cursor.column_types)
 -            line = ' | '.join('%s,%s' % (n.coloredval, v.coloredval) for (n, 
v) in zip(colnames, colvals))
 -            self.writeresult(' ' + line)
 -
      def emptyline(self):
          pass
  
@@@ -1645,9 -2008,51 +1669,51 @@@
              self.tracing_enabled = False
              print 'Disabled tracing.'
  
+     def do_expand(self, parsed):
+         """
+         EXPAND [cqlsh]
+ 
+           Enables or disables expanded (vertical) output.
+ 
+         EXPAND ON
+ 
+           Enables expanded (vertical) output.
+ 
+         EXPAND OFF
+ 
+           Disables expanded (vertical) output.
+ 
+         EXPAND
+ 
+           EXPAND with no arguments shows the current value of expand setting.
+         """
+         switch = parsed.get_binding('switch')
+         if switch is None:
+             if self.expand_enabled:
+                 print "Expanded output is currently enabled. Use EXPAND OFF 
to disable"
+             else:
+                 print "Expanded output is currently disabled. Use EXPAND ON 
to enable."
+             return
+ 
+         if switch.upper() == 'ON':
+             if self.expand_enabled:
+                 self.printerr('Expanded output is already enabled. '
+                               'Use EXPAND OFF to disable.')
+                 return
+             self.expand_enabled = True
+             print 'Now printing expanded output'
+             return
+ 
+         if switch.upper() == 'OFF':
+             if not self.expand_enabled:
+                 self.printerr('Expanded output is not enabled.')
+                 return
+             self.expand_enabled = False
+             print 'Disabled expanded output.'
+ 
      def do_consistency(self, parsed):
          """
 -        CONSISTENCY [cqlsh with CQL3 only]
 +        CONSISTENCY [cqlsh only]
  
             Overrides default consistency level (default level is ONE).
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4f7e2b80/pylib/cqlshlib/test/test_cqlsh_completion.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/test/test_cqlsh_completion.py
index ea4f77c,3051378..b8f0167
--- a/pylib/cqlshlib/test/test_cqlsh_completion.py
+++ b/pylib/cqlshlib/test/test_cqlsh_completion.py
@@@ -90,16 -90,15 +90,16 @@@ class CqlshCompletionCase(BaseTestCase)
      def strategies(self):
          return self.module.CqlRuleSet.replication_strategies
  
 -class TestCqlshCompletion_CQL2(CqlshCompletionCase):
 -    cqlver = 2
 -    module = cqlsh.cqlhandling
 +class TestCqlshCompletion(CqlshCompletionCase):
 +    cqlver = '3.1.0'
 +    module = cqlsh.cql3handling
  
      def test_complete_on_empty_string(self):
 -        self.trycompletions('', choices=('?', 'ALTER', 'ASSUME', 'BEGIN', 
'CAPTURE', 'CONSISTENCY',
 +        self.trycompletions('', choices=('?', 'ALTER', 'BEGIN', 'CAPTURE', 
'CONSISTENCY',
                                           'COPY', 'CREATE', 'DEBUG', 'DELETE', 
'DESC', 'DESCRIBE',
 -                                         'DROP', 'HELP', 'INSERT', 'SELECT', 
'SHOW', 'SOURCE',
 -                                         'TRACING', 'EXPAND', 'TRUNCATE', 
'UPDATE', 'USE', 'exit', 'quit'))
 +                                         'DROP', 'GRANT', 'HELP', 'INSERT', 
'LIST', 'REVOKE',
-                                          'SELECT', 'SHOW', 'SOURCE', 
'TRACING', 'TRUNCATE', 'UPDATE',
-                                          'USE', 'exit', 'quit'))
++                                         'SELECT', 'SHOW', 'SOURCE', 
'TRACING', 'EXPAND', 'TRUNCATE',
++                                         'UPDATE', 'USE', 'exit', 'quit'))
  
      def test_complete_command_words(self):
          self.trycompletions('alt', '\b\b\bALTER ')

Reply via email to