Rev 3434: Update how 'bzr missing' works when given --mine-only or --theirs-only in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/missing

John Arbash Meinel john at arbash-meinel.com
Tue May 20 19:18:56 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/missing

------------------------------------------------------------
revno: 3434
revision-id: john at arbash-meinel.com-20080520181835-kw4sd2fzblnw23mj
parent: john at arbash-meinel.com-20080520023401-42mkw5g7dhq9f5bh
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: missing
timestamp: Tue 2008-05-20 13:18:35 -0500
message:
  Update how 'bzr missing' works when given --mine-only or --theirs-only
  
  It used to always determine missing revisions on both sides, and then just suppress
  displaying them if the flag was given. It would also return status 1 if either side
  had extra revisions. However, if you are asking for --mine-only, it doesn't make sense
  to return status 1 when the local branch has nothing new.
  And the new code doesn't know whether there are new revisions on the other side anyway.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_missing.py test_missing.py-20051211212735-a2cf4c1840bb84c4
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-05-20 02:34:01 +0000
+++ b/NEWS	2008-05-20 18:18:35 +0000
@@ -33,6 +33,12 @@
 
   API BREAKS:
 
+    * ``bzr missing --mine-only`` will return status code 0 if you have no new
+      revisions, but the remote does. Similarly for ``--theirs-only``. The new
+      code only checks one side, so it doesn't know if the other side has
+      changes. This seems more accurate with the request anyway.
+      (John Arbash Meinel)
+
     * Many methods on ``VersionedFile``, ``Repository`` and in
       ``bzrlib.revision``  deprecated before bzrlib 1.5 have been removed.
       (Robert Collins)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-05-19 21:42:54 +0000
+++ b/bzrlib/builtins.py	2008-05-20 18:18:35 +0000
@@ -3352,6 +3352,8 @@
                         local_extra.reverse()
                     if remote_extra is not None:
                         remote_extra.reverse()
+
+                status_code = 0
                 if local_extra and not theirs_only:
                     self.outf.write("You have %d extra revision(s):\n" %
                                     len(local_extra))
@@ -3360,8 +3362,10 @@
                                         verbose):
                         lf.log_revision(revision)
                     printed_local = True
+                    status_code = 1
                 else:
                     printed_local = False
+
                 if remote_extra and not mine_only:
                     if printed_local is True:
                         self.outf.write("\n\n\n")
@@ -3371,11 +3375,19 @@
                                         remote_branch.repository,
                                         verbose):
                         lf.log_revision(revision)
-                if not remote_extra and not local_extra:
-                    status_code = 0
+                    status_code = 1
+
+                if mine_only and not local_extra:
+                    # We checked local, and found nothing extra
+                    self.outf.write('Local branch is up to date.\n')
+                elif theirs_only and not remote_extra:
+                    # We checked remote, and found nothing extra
+                    self.outf.write('Remote branch is up to date.\n')
+                elif not (mine_only or theirs_only or local_extra or
+                          remote_extra):
+                    # We checked both branches, and neither one had extra
+                    # revisions
                     self.outf.write("Branches are up to date.\n")
-                else:
-                    status_code = 1
             finally:
                 remote_branch.unlock()
         finally:

=== modified file 'bzrlib/tests/blackbox/test_missing.py'
--- a/bzrlib/tests/blackbox/test_missing.py	2007-08-08 12:48:16 +0000
+++ b/bzrlib/tests/blackbox/test_missing.py	2008-05-20 18:18:35 +0000
@@ -77,7 +77,7 @@
         lines2 = self.run_bzr('missing ../b --mine-only', retcode=1)[0]
         lines2 = lines2.splitlines()
         self.assertEqual(lines, lines2)
-        lines3 = self.run_bzr('missing ../b --theirs-only', retcode=1)[0]
+        lines3 = self.run_bzr('missing ../b --theirs-only', retcode=0)[0]
         lines3 = lines3.splitlines()
         self.assertEqual(0, len(lines3))
 
@@ -89,9 +89,8 @@
         lines2 = self.run_bzr('missing ../a --theirs-only', retcode=1)[0]
         lines2 = lines2.splitlines()
         self.assertEqual(lines, lines2)
-        lines3 = self.run_bzr('missing ../a --mine-only', retcode=1)[0]
-        lines3 = lines3.splitlines()
-        self.assertEqual(0, len(lines3))
+        lines3 = self.run_bzr('missing ../a --mine-only', retcode=0)[0]
+        self.assertEqualDiff('Local branch is up to date\n', lines3)
         lines4 = self.run_bzr('missing ../a --short', retcode=1)[0]
         lines4 = lines4.splitlines()
         self.assertEqual(4, len(lines4))
@@ -109,9 +108,22 @@
         self.assertEqual("modified:", lines8[-2])
         self.assertEqual("  a", lines8[-1])
 
+        os.chdir('../a')
+        self.assertEqualDiff('Remote branch is up to date.\n',
+                             self.run_bzr('missing ../b --theirs-only')[0])
+
         # after a pull we're back on track
         b_tree.pull(a_branch)
-        self.assertEqual("Branches are up to date.\n", self.run_bzr('missing ../a')[0])
+        self.assertEqualDiff("Branches are up to date.\n",
+                             self.run_bzr('missing ../b')[0])
+        os.chdir('../b')
+        self.assertEqualDiff('Branches are up to date.\n',
+                             self.run_bzr('missing ../a')[0])
+        # If you supply mine or theirs you only know one side is up to date
+        self.assertEqualDiff('Local branch is up to date.\n',
+                             self.run_bzr('missing ../a --mine-only')[0])
+        self.assertEqualDiff('Remote branch is up to date.\n',
+                             self.run_bzr('missing ../a --theirs-only')[0])
 
     def test_missing_check_last_location(self):
         # check that last location shown as filepath not file URL



More information about the bazaar-commits mailing list