Rev 4956: Refactor the function into an helper. in file:///home/vila/src/bzr/bugs/476293-log-respect-direction/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Jan 14 15:24:40 GMT 2010


At file:///home/vila/src/bzr/bugs/476293-log-respect-direction/

------------------------------------------------------------
revno: 4956
revision-id: v.ladeuil+lp at free.fr-20100114152439-6b264l1jv84mzaax
parent: pqm at pqm.ubuntu.com-20100113002544-mztf6nwrfgqienjc
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: cleanup
timestamp: Thu 2010-01-14 16:24:39 +0100
message:
  	Refactor the function into an helper.
  
  	* bzrlib/tests/test_log.py:
  	(TestCaseForLogFormatter.make_commits_with_trailing_newlines):
  	Turned into a helper.
  	(TestShortLogFormatter.test_trailing_newlines)
  	(TestLongLogFormatter.test_trailing_newlines)
  	(TestLineLogFormatter.test_trailing_newlines)
  	(TestLongLogFormatterWithoutMergeRevisions.test_long_trailing_newlines):
  	Use the helper, notice the pattern :-/
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-01-12 22:36:23 +0000
+++ b/bzrlib/builtins.py	2010-01-14 15:24:39 +0000
@@ -5411,7 +5411,6 @@
     directory of the current branch. For example, if you are currently in a
     checkout of /path/to/branch, specifying 'newbranch' will find a branch at
     /path/to/newbranch.
-
     Bound branches use the nickname of its master branch unless it is set
     locally, in which case switching will update the local nickname to be
     that of the master.

=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py	2010-01-05 02:13:02 +0000
+++ b/bzrlib/tests/test_log.py	2010-01-14 15:24:39 +0000
@@ -71,6 +71,29 @@
         wt.commit(**kwargs)
         return wt
 
+    def make_commits_with_trailing_newlines(self, wt):
+        """Helper method for LogFormatter tests"""
+        b = wt.branch
+        b.nick = 'test'
+        open('a', 'wb').write('hello moto\n')
+        wt.add('a')
+        wt.commit('simple log message', rev_id='a1',
+                  timestamp=1132586655.459960938, timezone=-6*3600,
+                  committer='Joe Foo <joe at foo.com>')
+        open('b', 'wb').write('goodbye\n')
+        wt.add('b')
+        wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
+                  timestamp=1132586842.411175966, timezone=-6*3600,
+                  committer='Joe Foo <joe at foo.com>',
+                  authors=['Joe Bar <joe at bar.com>'])
+
+        open('c', 'wb').write('just another manic monday\n')
+        wt.add('c')
+        wt.commit('single line with trailing newline\n', rev_id='a3',
+                  timestamp=1132587176.835228920, timezone=-6*3600,
+                  committer = 'Joe Foo <joe at foo.com>')
+        return b
+
     def _prepare_tree_with_merges(self, with_tags=False):
         wt = self.make_branch_and_memory_tree('.')
         wt.lock_write()
@@ -97,8 +120,6 @@
             branch.tags.set_tag('v1.0', 'rev-3')
         return wt
 
-        
-
 
 class LogCatcher(log.LogFormatter):
     """Pull log messages into a list rather than displaying them.
@@ -260,29 +281,6 @@
         self.checkDelta(logentry.delta, added=['file1', 'file2'])
 
 
-def make_commits_with_trailing_newlines(wt):
-    """Helper method for LogFormatter tests"""
-    b = wt.branch
-    b.nick='test'
-    open('a', 'wb').write('hello moto\n')
-    wt.add('a')
-    wt.commit('simple log message', rev_id='a1',
-              timestamp=1132586655.459960938, timezone=-6*3600,
-              committer='Joe Foo <joe at foo.com>')
-    open('b', 'wb').write('goodbye\n')
-    wt.add('b')
-    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
-              timestamp=1132586842.411175966, timezone=-6*3600,
-              committer='Joe Foo <joe at foo.com>',
-              authors=['Joe Bar <joe at bar.com>'])
-
-    open('c', 'wb').write('just another manic monday\n')
-    wt.add('c')
-    wt.commit('single line with trailing newline\n', rev_id='a3',
-              timestamp=1132587176.835228920, timezone=-6*3600,
-              committer = 'Joe Foo <joe at foo.com>')
-    return b
-
 
 def normalize_log(log):
     """Replaces the variable lines of logs with fixed lines"""
@@ -305,7 +303,7 @@
 
     def test_trailing_newlines(self):
         wt = self.make_branch_and_tree('.')
-        b = make_commits_with_trailing_newlines(wt)
+        b = self.make_commits_with_trailing_newlines(wt)
         self.assertFormatterResult("""\
     3 Joe Foo\t2005-11-21
       single line with trailing newline
@@ -619,7 +617,7 @@
 
     def test_trailing_newlines(self):
         wt = self.make_branch_and_tree('.')
-        b = make_commits_with_trailing_newlines(wt)
+        b = self.make_commits_with_trailing_newlines(wt)
         self.assertFormatterResult("""\
 ------------------------------------------------------------
 revno: 3
@@ -812,7 +810,7 @@
 
     def test_long_trailing_newlines(self):
         wt = self.make_branch_and_tree('.')
-        b = make_commits_with_trailing_newlines(wt)
+        b = self.make_commits_with_trailing_newlines(wt)
         self.assertFormatterResult("""\
 ------------------------------------------------------------
 revno: 3
@@ -903,7 +901,7 @@
 
     def test_trailing_newlines(self):
         wt = self.make_branch_and_tree('.')
-        b = make_commits_with_trailing_newlines(wt)
+        b = self.make_commits_with_trailing_newlines(wt)
         self.assertFormatterResult("""\
 3: Joe Foo 2005-11-21 single line with trailing newline
 2: Joe Bar 2005-11-21 multiline



More information about the bazaar-commits mailing list