Rev 3300: Diff describes execute-bit changes better (cmiller) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sun Mar 23 20:02:46 GMT 2008


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

------------------------------------------------------------
revno: 3300
revision-id:pqm at pqm.ubuntu.com-20080323200233-gaiwmyujgxauj4ve
parent: pqm at pqm.ubuntu.com-20080320180614-grrzhydka050ap3a
parent: aaron at aaronbentley.com-20080323182637-udhhz4srjvwjc95p
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2008-03-23 20:02:33 +0000
message:
  Diff describes execute-bit changes better (cmiller)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
  bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
    ------------------------------------------------------------
    revno: 3299.1.2
    revision-id:aaron at aaronbentley.com-20080323182637-udhhz4srjvwjc95p
    parent: aaron at aaronbentley.com-20080323182425-qnr06aeuwcxr86t9
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Sun 2008-03-23 14:26:37 -0400
    message:
      Add NEWS entry
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3299.1.1
    revision-id:aaron at aaronbentley.com-20080323182425-qnr06aeuwcxr86t9
    parent: pqm at pqm.ubuntu.com-20080320180614-grrzhydka050ap3a
    parent: bzrdev at chad.org-20080313232212-gl2nml7k11m6623u
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Sun 2008-03-23 14:24:25 -0400
    message:
      Merge explicit property change from Chad Miller
    modified:
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
    ------------------------------------------------------------
    revno: 3268.1.1
    revision-id:bzrdev at chad.org-20080313232212-gl2nml7k11m6623u
    parent: pqm at pqm.ubuntu.com-20080312213603-mtgxmfy3td5n04yh
    committer: C Miller <bzrdev at chad.org>
    branch nick: bzr.dev--explicit-prop-diff
    timestamp: Thu 2008-03-13 19:22:12 -0400
    message:
      Describe the property changes in diffs.  Currently, this is the executable-bit
      only.  
      
      Now, includes tests.
    modified:
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
=== modified file 'NEWS'
--- a/NEWS	2008-03-20 16:24:32 +0000
+++ b/NEWS	2008-03-23 18:26:37 +0000
@@ -31,6 +31,9 @@
     * Merge is faster.  We no longer check a file's existence unnecessarily
       when merging the execute bit.  (Aaron Bentley)
 
+    * Diff is now more specific about execute-bit changes it describes
+      (Chad Miller)
+
   BUGFIXES:
 
     * ``bzr mv a b`` can be now used also to rename previously renamed

=== modified file 'bzrlib/diff.py'
--- a/bzrlib/diff.py	2008-03-07 14:15:10 +0000
+++ b/bzrlib/diff.py	2008-03-13 23:22:12 +0000
@@ -41,6 +41,7 @@
 from bzrlib.symbol_versioning import (
         deprecated_function,
         one_zero,
+        one_three
         )
 from bzrlib.trace import mutter, warning
 
@@ -540,12 +541,20 @@
         raise errors.PathsDoNotExist(sorted(s))
 
 
+ at deprecated_function(one_three)
 def get_prop_change(meta_modified):
     if meta_modified:
         return " (properties changed)"
     else:
         return  ""
 
+def get_executable_change(old_is_x, new_is_x):
+    descr = { True:"+x", False:"-x", None:"??" }
+    if old_is_x != new_is_x:
+        return ["%s to %s" % (descr[old_is_x], descr[new_is_x],)]
+    else:
+        return []
+
 
 class DiffPath(object):
     """Base type for command object that compare files"""
@@ -954,7 +963,15 @@
             old_present = (kind[0] is not None and versioned[0])
             new_present = (kind[1] is not None and versioned[1])
             renamed = (parent[0], name[0]) != (parent[1], name[1])
-            prop_str = get_prop_change(executable[0] != executable[1])
+
+            properties_changed = []
+            properties_changed.extend(get_executable_change(executable[0], executable[1]))
+
+            if properties_changed:
+                prop_str = " (properties changed: %s)" % (", ".join(properties_changed),)
+            else:
+                prop_str = ""
+
             if (old_present, new_present) == (True, False):
                 self.to_file.write("=== removed %s '%s'\n" %
                                    (kind[0], oldpath_encoded))

=== modified file 'bzrlib/tests/test_diff.py'
--- a/bzrlib/tests/test_diff.py	2008-01-29 15:58:23 +0000
+++ b/bzrlib/tests/test_diff.py	2008-03-13 23:22:12 +0000
@@ -34,6 +34,7 @@
     )
 from bzrlib.errors import BinaryFile, NoDiff, ExecutableMissing
 import bzrlib.osutils as osutils
+import bzrlib.transform as transform
 import bzrlib.patiencediff
 import bzrlib._patiencediff_py
 from bzrlib.tests import (Feature, TestCase, TestCaseWithTransport,
@@ -509,6 +510,39 @@
         self.assertContainsRe(diff, '-contents\n'
                                     '\\+new contents\n')
 
+
+    def test_internal_diff_exec_property(self):
+        tree = self.make_branch_and_tree('tree')
+
+        tt = transform.TreeTransform(tree)
+        tt.new_file('a', tt.root, 'contents\n', 'a-id', True)
+        tt.new_file('b', tt.root, 'contents\n', 'b-id', False)
+        tt.new_file('c', tt.root, 'contents\n', 'c-id', True)
+        tt.new_file('d', tt.root, 'contents\n', 'd-id', False)
+        tt.new_file('e', tt.root, 'contents\n', 'control-e-id', True)
+        tt.new_file('f', tt.root, 'contents\n', 'control-f-id', False)
+        tt.apply()
+        tree.commit('one', rev_id='rev-1')
+
+        tt = transform.TreeTransform(tree)
+        tt.set_executability(False, tt.trans_id_file_id('a-id'))
+        tt.set_executability(True, tt.trans_id_file_id('b-id'))
+        tt.set_executability(False, tt.trans_id_file_id('c-id'))
+        tt.set_executability(True, tt.trans_id_file_id('d-id'))
+        tt.apply()
+        tree.rename_one('c', 'new-c')
+        tree.rename_one('d', 'new-d')
+
+        diff = self.get_diff(tree.basis_tree(), tree)
+
+        self.assertContainsRe(diff, r"file 'a'.*\(properties changed:.*\+x to -x.*\)")
+        self.assertContainsRe(diff, r"file 'b'.*\(properties changed:.*-x to \+x.*\)")
+        self.assertContainsRe(diff, r"file 'c'.*\(properties changed:.*\+x to -x.*\)")
+        self.assertContainsRe(diff, r"file 'd'.*\(properties changed:.*-x to \+x.*\)")
+        self.assertNotContainsRe(diff, r"file 'e'")
+        self.assertNotContainsRe(diff, r"file 'f'")
+
+
     def test_binary_unicode_filenames(self):
         """Test that contents of files are *not* encoded in UTF-8 when there
         is a binary file in the diff.




More information about the bazaar-commits mailing list