[MERGE] Bug fix for bzr log -r ..x

Michael Ellerman michael at ellerman.id.au
Wed Feb 15 13:23:45 GMT 2006


Hi guys,

I've got a patch which fixes bug #4609 (and #31275), that is that bzr
log -r ..x doesn't work. It builds on an existing patch from Robey to
fix bzr log -r x..

I've added tests for this and also the other examples in the bug, so
we don't break it again.

I implemented it on top of JAM integration, because I needed tests to
work, not sure if that's a problem for merging.

Pullable from http://michael.ellerman.id.au/files/bzr/mpe

Patch below for your perusal.

cheers

=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py	
+++ bzrlib/builtins.py	
@@ -948,7 +948,12 @@
         elif len(revision) == 1:
             rev1 = rev2 = revision[0].in_history(b).revno
         elif len(revision) == 2:
-            rev1 = revision[0].in_history(b).revno
+            if revision[0].spec is None:
+                # missing begin-range means first revision
+                rev1 = 1
+            else:
+                rev1 = revision[0].in_history(b).revno
+
             if revision[1].spec is None:
                 # missing end-range means last known revision
                 rev2 = b.revno()

=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- bzrlib/tests/blackbox/test_log.py	
+++ bzrlib/tests/blackbox/test_log.py	
@@ -24,17 +24,65 @@
 import bzrlib
 from bzrlib.tests.blackbox import ExternalBase

+class TestLog(ExternalBase):
+    def _prepare(self):
+        self.runbzr("init")
+        self.build_tree(['hello.txt', 'goodbye.txt', 'meep.txt'])
+        self.runbzr("add hello.txt")
+        self.runbzr("commit -m message1 hello.txt")
+        self.runbzr("add goodbye.txt")
+        self.runbzr("commit -m message2 goodbye.txt")
+        self.runbzr("add meep.txt")
+        self.runbzr("commit -m message3 meep.txt")
+        self.full_log = self.runbzr("log")[0]

-class TestLog(ExternalBase):
+    def test_log_null_end_revspec(self):
+        self._prepare()
+        self.assertTrue('revno: 1\n' in self.full_log)
+        self.assertTrue('revno: 2\n' in self.full_log)
+        self.assertTrue('revno: 3\n' in self.full_log)
+        self.assertTrue('message:\n  message1\n' in self.full_log)
+        self.assertTrue('message:\n  message2\n' in self.full_log)
+        self.assertTrue('message:\n  message3\n' in self.full_log)

-    def test_log(self):
-        self.runbzr("init")
-        self.build_tree(['hello.txt'])
-        self.runbzr("add hello.txt")
-        self.runbzr("commit -m message hello.txt")
-        result = self.runbzr("log")[0]
-        self.assertTrue('revno: 1\n' in result)
-        self.assertTrue('message:\n  message\n' in result)
-
-        result2 = self.runbzr("log -r 1..")[0]
-        self.assertEquals(result2, result)
+        log = self.runbzr("log -r 1..")[0]
+        self.assertEquals(log, self.full_log)
+
+    def test_log_null_begin_revspec(self):
+        self._prepare()
+        log = self.runbzr("log -r ..3")[0]
+        self.assertEquals(self.full_log, log)
+
+    def test_log_null_both_revspecs(self):
+        self._prepare()
+        log = self.runbzr("log -r ..")[0]
+        self.assertEquals(self.full_log, log)
+
+    def test_log_negative_begin_revspec_full_log(self):
+        self._prepare()
+        log = self.runbzr("log -r -3..")[0]
+        self.assertEquals(self.full_log, log)
+
+    def test_log_negative_both_revspec_full_log(self):
+        self._prepare()
+        log = self.runbzr("log -r -3..-1")[0]
+        self.assertEquals(self.full_log, log)
+
+    def test_log_negative_both_revspec_partial(self):
+        self._prepare()
+        log = self.runbzr("log -r -3..-2")[0]
+        self.assertTrue('revno: 1\n' in log)
+        self.assertTrue('revno: 2\n' in log)
+        self.assertTrue('revno: 3\n' not in log)
+
+    def test_log_negative_begin_revspec(self):
+        self._prepare()
+        log = self.runbzr("log -r -2..")[0]
+        self.assertTrue('revno: 1\n' not in log)
+        self.assertTrue('revno: 2\n' in log)
+        self.assertTrue('revno: 3\n' in log)
+
+    def test_log_postive_revspecs(self):
+        self._prepare()
+        log = self.runbzr("log -r 1..3")[0]
+        self.assertEquals(self.full_log, log)




More information about the bazaar mailing list