[Pkg-bazaar-commits] r122 ./bzr-builddeb/trunk: Overhaul the handling of dirty trees and unkowns.

James Westby jw+debian at jameswestby.net
Tue Jul 10 17:12:07 UTC 2007


------------------------------------------------------------
revno: 122
committer: James Westby <jw+debian at jameswestby.net>
branch nick: trunk
timestamp: Tue 2007-07-10 18:12:07 +0100
message:
  Overhaul the handling of dirty trees and unkowns.
  
    * Give a separate message for unknowns, and explain how to avoid it.
    * Only check for unknowns on -w.
    * Add a working-tree configuration option to make -w default.
modified:
  README
  __init__.py
  config.py
  errors.py
  util.py
-------------- next part --------------
=== modified file 'README'
--- a/README	2007-06-18 22:07:21 +0000
+++ b/README	2007-07-10 17:12:07 +0000
@@ -203,6 +203,11 @@
 Others
 ######
 
+  * ``working-tree = True``
+
+    Always build the working tree, rather than the last revision committed
+    to the branch.
+
   * ``ignore-unknowns = True``
 
     Don't count unknown files in the tree as changes, and so allow the build

=== modified file '__init__.py'
--- a/__init__.py	2007-06-17 22:01:12 +0000
+++ b/__init__.py	2007-07-10 17:12:07 +0000
@@ -33,10 +33,11 @@
                      )
 from config import DebBuildConfig
 from errors import (ChangedError,
+                    UnknownsInTree,
                     StopBuild,
                     )
 from properties import BuildProperties
-from util import goto_branch, find_changelog, is_clean
+from util import goto_branch, find_changelog
 
 dont_purge_opt = Option('dont-purge',
     help="Don't purge the build directory after building")
@@ -221,13 +222,20 @@
             builder = "dpkg-buildpackage -uc -us -rfakeroot"
 
     if not working_tree:
+      working_tree = config.working_tree
+
+    if not working_tree:
       b = tree.branch
       rev_id = b.last_revision()
       info("Building branch from revision %s", rev_id)
       t = b.repository.revision_tree(rev_id)
-      if not ignore_changes and not is_clean(t, tree, ignore_unknowns):
-        raise ChangedError
+      if not ignore_changes:
+        changes = tree.changes_from(t)
+        if changes.has_changed():
+          raise ChangedError
     else:
+      if not ignore_unknowns and len(list(tree.unknowns())) > 0:
+        raise UnknownsInTree
       info("Building using working tree")
       t = tree
 

=== modified file 'config.py'
--- a/config.py	2007-06-18 21:12:43 +0000
+++ b/config.py	2007-07-10 17:12:07 +0000
@@ -219,6 +219,9 @@
   ignore_unknowns = _bool_property('ignore-unknowns',
                          "Build even when the tree has unknowns")
 
+  working_tree = _bool_property('working-tree',
+                         "Always build the working tree.")
+
   native = _bool_property('native', "Build a native package")
 
   split = _bool_property('split', "Split a full source package")

=== modified file 'errors.py'
--- a/errors.py	2007-06-18 21:57:14 +0000
+++ b/errors.py	2007-07-10 17:12:07 +0000
@@ -29,11 +29,26 @@
     self.message = message
 
 class ChangedError(DebianError):
-  _fmt = """There are modified files in the working tree. Either commit the 
-  changes, use --working to build the working tree, or --ignore-changes
-  to override this and build the branch without the changes in the working 
-  tree. Use bzr status to see the changes"""
-
+  _fmt = ("There are modified files in the working tree. Either commit the "
+         "changes, use --working to build the working tree, or "
+         "--ignore-changes to override this and build the branch without "
+         "the changes in the working tree. Use bzr status to see the changes. "
+         "To disable this check and always build the working tree see the "
+         "documentation of the working-tree configuration option in the README. "
+         )
+
+  def __init__(self):
+    DebianError.__init__(self, None)
+
+class UnknownsInTree(DebianError):
+  _fmt = ("There are unknown files in the working tree. The build will not "
+         "continue as you may want these files included in the build. If you "
+         "do want them then use 'bzr add' to add them to the tree. If you do "
+         "not then use the '--ignore-unknowns' option to 'builddeb'. To disable "
+         "this check then see the documentation of the 'ignore-unkowns' "
+         "configuration option in the README."
+         )
+ 
   def __init__(self):
     DebianError.__init__(self, None)
 

=== modified file 'util.py'
--- a/util.py	2007-07-08 19:23:05 +0000
+++ b/util.py	2007-07-10 17:12:07 +0000
@@ -47,18 +47,6 @@
       shutil.copy(path, todir)
 
 
-def is_clean(oldtree, newtree, ignore_unknowns=False):
-  """Return True if there are no uncommited changes or unknown files.
-  
-  If ignore_unknowns is True then unknown files do not count as changes."""
-
-  changes = newtree.changes_from(oldtree)
-  if changes.has_changed():
-    return False
-  if not ignore_unknowns and len(list(newtree.unknowns())) > 0:
-    return False
-  return True
-
 def goto_branch(branch):
   """Changes to the specified branch dir if it is not None"""
   if branch is not None:



More information about the Pkg-bazaar-commits mailing list