Rev 4505: Use tree.has_changes() where appropriate (the test suite caught a in file:///home/vila/src/bzr/experimental/tree-has-changes/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Jul 2 14:07:14 BST 2009


At file:///home/vila/src/bzr/experimental/tree-has-changes/

------------------------------------------------------------
revno: 4505
revision-id: v.ladeuil+lp at free.fr-20090702130714-hsyqfusi8vn3a11m
parent: v.ladeuil+lp at free.fr-20090702102858-ihom217tfb09ulmp
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: tree-has-changes
timestamp: Thu 2009-07-02 15:07:14 +0200
message:
  Use tree.has_changes() where appropriate (the test suite caught a
  bug in has_changes() (not filtering out the root) in an impressive
  number of tests)
  
  * bzrlib/send.py:
  (send): Use tree.has_changes() instead of tree.changes_from().
  
  * bzrlib/reconfigure.py:
  (Reconfigure._check): Use tree.has_changes() instead of
  tree.changes_from().
  
  * bzrlib/merge.py:
  (Merger.ensure_revision_trees, Merger.compare_basis): Use
  tree.has_changes() instead of tree.changes_from().
  
  * bzrlib/builtins.py:
  (cmd_remove_tree.run, cmd_push.run, cmd_merge.run): Use
  tree.has_changes() instead of tree.changes_from().
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-07-01 19:06:14 +0000
+++ b/bzrlib/builtins.py	2009-07-02 13:07:14 +0000
@@ -450,18 +450,18 @@
         except errors.NoWorkingTree:
             raise errors.BzrCommandError("No working tree to remove")
         except errors.NotLocalUrl:
-            raise errors.BzrCommandError("You cannot remove the working tree of a "
-                                         "remote path")
+            raise errors.BzrCommandError("You cannot remove the working tree"
+                                         " of a remote path")
         if not force:
-            changes = working.changes_from(working.basis_tree())
-            if changes.has_changed():
+            # XXX: What about pending merges ? -- vila 20090629
+            if working.has_changes(working.basis_tree()):
                 raise errors.UncommittedChanges(working)
 
         working_path = working.bzrdir.root_transport.base
         branch_path = working.branch.bzrdir.root_transport.base
         if working_path != branch_path:
-            raise errors.BzrCommandError("You cannot remove the working tree from "
-                                         "a lightweight checkout")
+            raise errors.BzrCommandError("You cannot remove the working tree"
+                                         " from a lightweight checkout")
 
         d.destroy_workingtree()
 
@@ -1115,8 +1115,8 @@
             revision_id = None
         if (tree is not None and revision_id is None
             and (strict is None or strict)): # Default to True:
-            changes = tree.changes_from(tree.basis_tree())
-            if changes.has_changed() or len(tree.get_parent_ids()) > 1:
+            if (tree.has_changes(tree.basis_tree())
+                 or len(tree.get_parent_ids()) > 1):
                 raise errors.UncommittedChanges(
                     tree, more='Use --no-strict to force the push.')
             if tree.last_revision() != tree.branch.last_revision():
@@ -3642,8 +3642,7 @@
         except errors.NoSuchRevision:
             basis_tree = tree.basis_tree()
         if not force:
-            changes = tree.changes_from(basis_tree)
-            if changes.has_changed():
+            if tree.has_changes(basis_tree):
                 raise errors.UncommittedChanges(tree)
 
         view_info = _get_view_info_for_change_reporter(tree)

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2009-04-14 15:02:46 +0000
+++ b/bzrlib/merge.py	2009-07-02 13:07:14 +0000
@@ -243,8 +243,7 @@
 
         if self.other_rev_id is None:
             other_basis_tree = self.revision_tree(self.other_basis)
-            changes = other_basis_tree.changes_from(self.other_tree)
-            if changes.has_changed():
+            if other_basis_tree.has_changes(self.other_tree):
                 raise WorkingTreeNotRevision(self.this_tree)
             other_rev_id = self.other_basis
             self.other_tree = other_basis_tree
@@ -276,8 +275,7 @@
             basis_tree = self.revision_tree(self.this_tree.last_revision())
         except errors.NoSuchRevision:
             basis_tree = self.this_tree.basis_tree()
-        changes = self.this_tree.changes_from(basis_tree)
-        if not changes.has_changed():
+        if not self.this_tree.has_changes(basis_tree):
             self.this_rev_id = self.this_basis
 
     def set_interesting_files(self, file_list):

=== modified file 'bzrlib/reconfigure.py'
--- a/bzrlib/reconfigure.py	2009-05-07 05:08:46 +0000
+++ b/bzrlib/reconfigure.py	2009-07-02 13:07:14 +0000
@@ -217,8 +217,8 @@
     def _check(self):
         """Raise if reconfiguration would destroy local changes"""
         if self._destroy_tree:
-            changes = self.tree.changes_from(self.tree.basis_tree())
-            if changes.has_changed():
+            # XXX: What about pending merges ? -- vila 20090629
+            if self.tree.has_changes(self.tree.basis_tree()):
                 raise errors.UncommittedChanges(self.tree)
         if self._create_reference and self.local_branch is not None:
             reference_branch = branch.Branch.open(self._select_bind_location())

=== modified file 'bzrlib/send.py'
--- a/bzrlib/send.py	2009-07-01 15:17:33 +0000
+++ b/bzrlib/send.py	2009-07-02 13:07:14 +0000
@@ -119,8 +119,8 @@
                     except KeyError:
                         strict = None
             if tree is not None and (strict is None or strict):
-                changes = tree.changes_from(tree.basis_tree())
-                if changes.has_changed() or len(tree.get_parent_ids()) > 1:
+                if (tree.has_changes(tree.basis_tree())
+                    or len(tree.get_parent_ids()) > 1):
                     raise errors.UncommittedChanges(
                         tree, more='Use --no-strict to force the send.')
                 if tree.last_revision() != tree.branch.last_revision():



More information about the bazaar-commits mailing list