Rev 4092: (Aguilar) Fail quickly when there are local changes. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Mar 9 00:33:11 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4092
revision-id: pqm at pqm.ubuntu.com-20090309003307-8iqjojdf64v2rdoe
parent: pqm at pqm.ubuntu.com-20090308235314-a20l1vl1t444ic57
parent: aaron at aaronbentley.com-20090308234012-vlyphxxye80fb8t0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-03-09 00:33:07 +0000
message:
  (Aguilar) Fail quickly when there are local changes.
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
    ------------------------------------------------------------
    revno: 4090.1.1
    revision-id: aaron at aaronbentley.com-20090308234012-vlyphxxye80fb8t0
    parent: pqm at pqm.ubuntu.com-20090308222317-d1nw017gzfen1aqs
    parent: roberto.c.aguilar at gmail.com-20090227083719-0etmu5762avd63f1
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Mon 2009-03-09 09:40:12 +1000
    message:
      Merge fast-fail from Aguilar.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
    ------------------------------------------------------------
    revno: 4037.2.5
    revision-id: roberto.c.aguilar at gmail.com-20090227083719-0etmu5762avd63f1
    parent: roberto.c.aguilar at gmail.com-20090227065718-0nisn2xlrfc8zdjl
    committer: Roberto Aguilar <roberto.c.aguilar at gmail.com>
    branch nick: bzr.repo
    timestamp: Fri 2009-02-27 00:37:19 -0800
    message:
      Updating tests for uncommitted changes.
      
      Updating test_merge_remember() to pass when the uncommitted changes test
      happens further up the chain and adding another file into the test branch to
      make sure that implicit --remember continues to work.
    modified:
      bzrlib/tests/blackbox/test_merge.py test_merge.py-20060323225809-9bc0459c19917f41
    ------------------------------------------------------------
    revno: 4037.2.4
    revision-id: roberto.c.aguilar at gmail.com-20090227065718-0nisn2xlrfc8zdjl
    parent: roberto.c.aguilar at gmail.com-20090226063853-o5dpq7i6hqcm8fc2
    committer: Roberto Aguilar <roberto.c.aguilar at gmail.com>
    branch nick: bzr.repo
    timestamp: Thu 2009-02-26 22:57:18 -0800
    message:
      Set check_basis to False.
      
      Instead of inverting what was there, actually make the check for uncommitted
      changes False
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4037.2.3
    revision-id: roberto.c.aguilar at gmail.com-20090226063853-o5dpq7i6hqcm8fc2
    parent: roberto.c.aguilar at gmail.com-20090226063700-8g31ggf2r0yt37jm
    committer: Roberto Aguilar <roberto.c.aguilar at gmail.com>
    branch nick: bzr.repo
    timestamp: Wed 2009-02-25 22:38:53 -0800
    message:
      Not checking clean in check_basis call.
      
      Because a check for modified files is done at the top of the command, do not
      check when calling check_basis().
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4037.2.2
    revision-id: roberto.c.aguilar at gmail.com-20090226063700-8g31ggf2r0yt37jm
    parent: roberto.c.aguilar at gmail.com-20090224075553-ae0zk1434ht4y193
    committer: Roberto Aguilar <roberto.c.aguilar at gmail.com>
    branch nick: bzr.repo
    timestamp: Wed 2009-02-25 22:37:00 -0800
    message:
      Updating uncommitted changes check.
      
      Looking through the merge module to see how it determines if there are
      uncommitted changes and pulling out the code that does so into cmd_merge.
      
      Still need a little more work so that the check isn't done twice.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 4037.2.1
    revision-id: roberto.c.aguilar at gmail.com-20090224075553-ae0zk1434ht4y193
    parent: pqm at pqm.ubuntu.com-20090224073648-8cdhj9m2zsab8hx8
    committer: Roberto Aguilar <roberto.c.aguilar at gmail.com>
    branch nick: bzr.repo
    timestamp: Mon 2009-02-23 23:55:53 -0800
    message:
      Check for umcommitted changes.
      
      The bzr merge command does a lot of work prior to mentioning there are
      uncommitted changes in the local branch.  Here is a patch that checks as soon
      as possible.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-03-06 01:01:32 +0000
+++ b/bzrlib/builtins.py	2009-03-08 23:40:12 +0000
@@ -3367,6 +3367,16 @@
         allow_pending = True
         verified = 'inapplicable'
         tree = WorkingTree.open_containing(directory)[0]
+
+        # die as quickly as possible if there are uncommitted changes
+        try:
+            basis_tree = tree.revision_tree(tree.last_revision())
+        except errors.NoSuchRevision:
+            basis_tree = tree.basis_tree()
+        changes = tree.changes_from(basis_tree)
+        if changes.has_changed():
+            raise errors.UncommittedChanges(tree)
+
         view_info = _get_view_info_for_change_reporter(tree)
         change_reporter = delta._ChangeReporter(
             unversioned_filter=tree.is_ignored, view_info=view_info)
@@ -3425,7 +3435,7 @@
                                        merger.other_rev_id)
                     result.report(self.outf)
                     return 0
-            merger.check_basis(not force)
+            merger.check_basis(False)
             if preview:
                 return self._do_preview(merger)
             else:

=== modified file 'bzrlib/tests/blackbox/test_merge.py'
--- a/bzrlib/tests/blackbox/test_merge.py	2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/blackbox/test_merge.py	2009-02-27 08:37:19 +0000
@@ -236,23 +236,28 @@
         out = self.run_bzr('merge', retcode=3)
         self.assertEquals(out,
                 ('','bzr: ERROR: No location specified or remembered\n'))
-        # test implicit --remember when no parent set, this merge conflicts
+
+        # test uncommitted changes
         self.build_tree(['d'])
         tree_b.add('d')
         self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
-                           'merge ../branch_a')
-        self.assertEquals(abspath(branch_b.get_submit_branch()),
-                          abspath(parent))
-        # test implicit --remember after resolving conflict
+                           'merge')
+
+        # merge should now pass and implicitly remember merge location
         tree_b.commit('commit d')
+        out, err = self.run_bzr('merge ../branch_a')
+
+        base = urlutils.local_path_from_url(branch_a.base)
+        self.assertEndsWith(err, '+N  b\nAll changes applied successfully.\n')
+        self.assertEquals(abspath(branch_b.get_submit_branch()),
+                          abspath(parent))
+        # test implicit --remember when committing new file
+        self.build_tree(['e'])
+        tree_b.add('e')
+        tree_b.commit('commit e')
         out, err = self.run_bzr('merge')
-
-        base = urlutils.local_path_from_url(branch_a.base)
         self.assertStartsWith(err,
                           'Merging from remembered submit location %s\n' % (base,))
-        self.assertEndsWith(err, '+N  b\nAll changes applied successfully.\n')
-        self.assertEquals(abspath(branch_b.get_submit_branch()),
-                          abspath(parent))
         # re-open tree as external run_bzr modified it
         tree_b = branch_b.bzrdir.open_workingtree()
         tree_b.commit('merge branch_a')




More information about the bazaar-commits mailing list