[Pkg-bazaar-commits] ./bzrtools/unstable r678: New upstream release.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 21:52:50 UTC 2009


------------------------------------------------------------
revno: 678
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: unstable
timestamp: Fri 2009-04-10 23:52:50 +0200
message:
  New upstream release.
removed:
  clean_tree.py
  tests/clean_tree.py
added:
  conflict_diff.py
  tests/test_conflict_diff.py
modified:
  INSTALL
  NEWS
  README
  __init__.py
  command_classes.py
  debian/changelog
  errors.py
  tests/blackbox.py
  tests/upstream_import.py
  upstream_import.py
  version.py
    ------------------------------------------------------------
    revno: 659.1.38
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Wed 2009-03-11 12:13:43 +1000
    message:
      Remove clean-tree (now in bzr core)
    removed:
      clean_tree.py
      tests/clean_tree.py
    modified:
      INSTALL
      NEWS
      README
      __init__.py
      command_classes.py
      tests/blackbox.py
    ------------------------------------------------------------
    revno: 659.1.39
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Wed 2009-03-11 16:44:59 +1000
    message:
      Implement conflict-diff
    modified:
      __init__.py
      command_classes.py
    ------------------------------------------------------------
    revno: 659.1.40
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Wed 2009-03-25 14:47:57 -0400
    message:
      Clean up conflict-diff
    modified:
      command_classes.py
    ------------------------------------------------------------
    revno: 659.1.41
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Wed 2009-03-25 14:49:18 -0400
    message:
      Update version
    modified:
      version.py
    ------------------------------------------------------------
    revno: 659.1.42
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Wed 2009-03-25 15:39:25 -0400
    message:
      Use LCA tree for base if not provided.
    modified:
      command_classes.py
    ------------------------------------------------------------
    revno: 659.1.43
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Fri 2009-04-10 16:07:41 -0400
    message:
      Get conflict-diff under test.
    added:
      conflict_diff.py
      tests/test_conflict_diff.py
    modified:
      __init__.py
      command_classes.py
      errors.py
    ------------------------------------------------------------
    revno: 659.1.44
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Fri 2009-04-10 17:09:41 -0400
    message:
      Fix import with Python 2.6
    modified:
      tests/upstream_import.py
      upstream_import.py
    ------------------------------------------------------------
    revno: 659.1.45
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzrtools
    timestamp: Fri 2009-04-10 17:11:45 -0400
    message:
      Update NEWS for release.
    modified:
      NEWS
-------------- next part --------------
=== modified file 'INSTALL'
--- a/INSTALL	2008-05-30 02:30:22 +0000
+++ b/INSTALL	2009-03-11 02:13:43 +0000
@@ -9,7 +9,7 @@
 $ sudo ./setup.py install
 
 You can test whether they are successfully installed by doing 
-"bzr clean-tree -h"
+"bzr zap -h"
 
 Optional Dependencies:
 rsync          - used by rspush

=== modified file 'NEWS'
--- a/NEWS	2009-03-11 01:20:30 +0000
+++ b/NEWS	2009-04-10 21:11:45 +0000
@@ -1,6 +1,12 @@
+April 10 2008
+* Fix import command for Python 2.6
+* RELEASE: bzrtools 1.14.0
+
 March 11 2008
 * `bzr patch` handles URLs with trailing slashes.
 * RELEASE: bzrtools 1.13.0
+* Remove clean-tree (now in bzr core)
+* New conflict-diff command
 
 February 10 2008
 * RELEASE: bzrtools 1.12.0

=== modified file 'README'
--- a/README	2008-05-30 02:30:22 +0000
+++ b/README	2009-03-11 02:13:43 +0000
@@ -24,9 +24,6 @@
 oldtext=darkred
 diffstuff=darkgreen
 
-CLEAN-TREE
-Delete unknown, ignored, or detritus files, leaving versioned files untouched.
-
 FETCH-GHOSTS
 Scan this branch for missing ancestors (aka "ghosts), and attempt to retrieve
 them from a specified branch.

=== modified file '__init__.py'
--- a/__init__.py	2009-01-05 13:47:08 +0000
+++ b/__init__.py	2009-04-10 20:07:41 +0000
@@ -31,7 +31,7 @@
     'cmd_branch_history': [],
     'cmd_cbranch': [],
     'cmd_cdiff': [],
-    'cmd_clean_tree': [],
+    'cmd_conflict_diff': [],
     'cmd_fetch_ghosts': ['fetch-missing'],
     'cmd_graph_ancestry': [],
     'cmd_import': [],
@@ -73,10 +73,10 @@
     from doctest import DocTestSuite, ELLIPSIS
     from unittest import TestSuite
     import bzrtools
-    import tests.clean_tree
     import tests.test_dotgraph
     import tests.is_clean
     import tests.test_cbranch
+    import tests.test_conflict_diff
     import tests.test_link_tree
     import tests.test_patch
     import tests.test_rspush
@@ -86,7 +86,6 @@
     import tests.shelf_tests
     result = TestSuite()
     result.addTest(DocTestSuite(bzrtools, optionflags=ELLIPSIS))
-    result.addTest(tests.clean_tree.test_suite())
     result.addTest(tests.test_suite())
     result.addTest(TestLoader().loadTestsFromModule(tests.shelf_tests))
     result.addTest(tests.blackbox.test_suite())
@@ -98,4 +97,5 @@
     result.addTest(TestLoader().loadTestsFromModule(tests.test_patch))
     result.addTest(TestLoader().loadTestsFromModule(tests.test_rspush))
     result.addTest(TestLoader().loadTestsFromModule(tests.test_cbranch))
+    result.addTest(TestLoader().loadTestsFromModule(tests.test_conflict_diff))
     return result

=== removed file 'clean_tree.py'
--- a/clean_tree.py	2008-10-10 19:23:14 +0000
+++ b/clean_tree.py	1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
-# Copyright (C) 2005 by Aaron Bentley
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-import errno
-import os
-import shutil
-import sys
-
-from bzrlib.osutils import has_symlinks, isdir
-from bzrlib.trace import note
-from bzrlib.workingtree import WorkingTree
-
-
-def is_detritus(subp):
-    """Return True if the supplied path is detritus, False otherwise"""
-    return subp.endswith('.THIS') or subp.endswith('.BASE') or\
-        subp.endswith('.OTHER') or subp.endswith('~') or subp.endswith('.tmp')
-
-
-def iter_deletables(tree, unknown=False, ignored=False, detritus=False):
-    """Iterate through files that may be deleted"""
-    for subp in tree.extras():
-        if detritus and is_detritus(subp):
-            yield tree.abspath(subp), subp
-            continue
-        if tree.is_ignored(subp):
-            if ignored:
-                yield tree.abspath(subp), subp
-        else:
-            if unknown:
-                yield tree.abspath(subp), subp
-
-
-def clean_tree(directory, unknown=False, ignored=False, detritus=False, 
-               dry_run=False, no_prompt=False):
-    """Remove files in the specified classes from the tree"""
-    tree = WorkingTree.open_containing(directory)[0]
-    tree.lock_read()
-    try:
-        deletables = list(iter_deletables(tree, unknown=unknown,
-            ignored=ignored, detritus=detritus))
-        if len(deletables) == 0:
-            note('Nothing to delete.')
-            return 0
-        if not no_prompt:
-            for path, subp in deletables:
-                print subp
-            val = raw_input('Are you sure you wish to delete these [y/N]?')
-            if val.lower() not in ('y', 'yes'):
-                print 'Canceled'
-                return 0
-        delete_items(deletables, dry_run=dry_run)
-    finally:
-        tree.unlock()
-
-
-def delete_items(deletables, dry_run=False):
-    """Delete files in the deletables iterable"""
-    has_deleted = False
-    for path, subp in deletables:
-        if not has_deleted:
-            note("deleting paths:")
-            has_deleted = True
-        note('  ' + subp)
-        if not dry_run:
-            if isdir(path):
-                shutil.rmtree(path)
-            else:
-                os.unlink(path)
-    if not has_deleted:
-        note("No files deleted.")

=== modified file 'command_classes.py'
--- a/command_classes.py	2009-01-05 13:47:08 +0000
+++ b/command_classes.py	2009-04-10 20:07:41 +0000
@@ -16,6 +16,8 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import errno
+
 import bzrlib
 
 from bzrlib.lazy_import import lazy_import
@@ -39,44 +41,11 @@
 import bzrlib.ignores
 from bzrlib.trace import note
 from bzrlib.option import Option, RegistryOption
+from bzrlib.workingtree import WorkingTree
 
 from command import BzrToolsCommand
 
 
-class cmd_clean_tree(BzrToolsCommand):
-    """Remove unwanted files from working tree.
-
-    By default, only unknown files, not ignored files, are deleted.  Versioned
-    files are never deleted.
-
-    Another class is 'detritus', which includes files emitted by bzr during
-    normal operations and selftests.  (The value of these files decreases with
-    time.)
-
-    If no options are specified, unknown files are deleted.  Otherwise, option
-    flags are respected, and may be combined.
-
-    To check what clean-tree will do, use --dry-run.
-    """
-    takes_options = [Option('ignored', help='Delete all ignored files.'),
-                     Option('detritus', help='Delete conflict files, merge'
-                            ' backups, and failed selftest dirs.'),
-                     Option('unknown',
-                            help='Delete files unknown to bzr (default).'),
-                     Option('dry-run', help='Show files to delete instead of'
-                            ' deleting them.'),
-                     Option('force', help='Do not prompt before deleting.')]
-    def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
-            force=False):
-        from clean_tree import clean_tree
-        if not (unknown or ignored or detritus):
-            unknown = True
-        if dry_run:
-            force = True
-        clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus, 
-                   dry_run=dry_run, no_prompt=force)
-
-
 class cmd_graph_ancestry(BzrToolsCommand):
     """Produce ancestry graphs using dot.
     
@@ -548,6 +517,25 @@
         colordiff(color, check_style, *args, **kwargs)
 
 
+class cmd_conflict_diff(BzrToolsCommand):
+
+    """Compare a conflicted file against BASE."""
+
+    encoding_type = 'exact'
+    takes_args = ['file']
+    takes_options = [
+        RegistryOption.from_kwargs('direction', 'Direction of comparison.',
+            value_switches=True, enum_switch=False,
+            other='Compare OTHER against common base.',
+            this='Compare THIS against common base.')]
+
+    def run(self, file, direction='other'):
+        from bzrlib.plugins.bzrtools.colordiff import DiffWriter
+        from conflict_diff import conflict_diff
+        dw = DiffWriter(self.outf, check_style=False, color='auto')
+        conflict_diff(dw, file, direction)
+
+
 class cmd_rspush(BzrToolsCommand):
     """Upload this branch to another location using rsync.
 

=== added file 'conflict_diff.py'
--- a/conflict_diff.py	1970-01-01 00:00:00 +0000
+++ b/conflict_diff.py	2009-04-10 20:07:41 +0000
@@ -0,0 +1,57 @@
+# Copyright (C) 2009 Aaron Bentley <aaron at aaronbentley.com>
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+import errno
+
+from bzrlib.diff import internal_diff
+from bzrlib.workingtree import WorkingTree
+from bzrlib.plugins.bzrtools import errors
+
+
+def conflict_diff(output, filename, direction):
+    """Perform a diff for a file with conflicts."""
+    old_path = filename + '.BASE'
+    old_lines = get_old_lines(filename, old_path)
+    new_path_extension = {
+        'other': '.OTHER',
+        'this': '.THIS'}[direction]
+    new_path = filename + new_path_extension
+    newlines = open(new_path).readlines()
+    internal_diff(old_path, old_lines, new_path, newlines, output)
+
+
+def get_old_lines(filename, base_path):
+    """"Return the lines from before the conflicting changes were made."""
+    try:
+        old_lines = open(base_path).readlines()
+    except IOError, e:
+        if e.errno != errno.ENOENT:
+            raise
+        tree, path = WorkingTree.open_containing(filename)
+        tree.lock_read()
+        try:
+            file_id = tree.path2id(path)
+            graph = tree.branch.repository.get_graph()
+            parent_ids = tree.get_parent_ids()
+            if len(parent_ids) < 2:
+                raise errors.NoConflictFiles(base_path)
+            lca = graph.find_unique_lca(*parent_ids)
+            oldtree = tree.branch.repository.revision_tree(lca)
+            old_lines = oldtree.get_file_lines(file_id)
+        finally:
+            tree.unlock()
+    return old_lines

=== modified file 'debian/changelog'
--- a/debian/changelog	2009-03-19 17:24:43 +0000
+++ b/debian/changelog	2009-04-10 21:52:50 +0000
@@ -1,9 +1,10 @@
-bzrtools (1.13.0-2) UNRELEASED; urgency=low
+bzrtools (1.14.0-1) unstable; urgency=low
 
+  * New upstream release.
   * Move to section vcs.
   * Bump standards version to 3.8.1.
 
- -- Jelmer Vernooij <jelmer at debian.org>  Thu, 19 Mar 2009 18:24:33 +0100
+ -- Jelmer Vernooij <jelmer at debian.org>  Fri, 10 Apr 2009 23:52:41 +0200
 
 bzrtools (1.13.0-1) unstable; urgency=low
 

=== modified file 'errors.py'
--- a/errors.py	2008-05-30 02:46:25 +0000
+++ b/errors.py	2009-04-10 20:07:41 +0000
@@ -74,3 +74,11 @@
 class ChangedBinaryFiles(BzrError):
 
     _fmt = 'Changes involve binary files.'
+
+
+class NoConflictFiles(CommandError):
+
+    _fmt = '%(base_name)s does not exist and there are no pending merges.'
+
+    def __init__(self, base_name):
+        CommandError.__init__(self, base_name=base_name)

=== modified file 'tests/blackbox.py'
--- a/tests/blackbox.py	2008-11-12 03:00:42 +0000
+++ b/tests/blackbox.py	2009-03-11 02:13:43 +0000
@@ -13,35 +13,6 @@
     def touch(filename):
         file(filename, 'wb').write('')
 
-    def test_clean_tree(self):
-        self.run_bzr('init')
-        self.run_bzr('ignore *~')
-        self.run_bzr('ignore *.pyc')
-        self.touch('name')
-        self.touch('name~')
-        assert os.path.lexists('name~')
-        self.touch('name.pyc')
-        self.run_bzr('clean-tree --force')
-        assert os.path.lexists('name~')
-        assert not os.path.lexists('name')
-        self.touch('name')
-        self.run_bzr('clean-tree --detritus --force')
-        assert os.path.lexists('name')
-        assert not os.path.lexists('name~')
-        assert os.path.lexists('name.pyc')
-        self.run_bzr('clean-tree --ignored --force')
-        assert os.path.lexists('name')
-        assert not os.path.lexists('name.pyc')
-        self.run_bzr('clean-tree --unknown --force')
-        assert not os.path.lexists('name')
-        self.touch('name')
-        self.touch('name~')
-        self.touch('name.pyc')
-        self.run_bzr('clean-tree --unknown --ignored --force')
-        assert not os.path.lexists('name')
-        assert not os.path.lexists('name~')
-        assert not os.path.lexists('name.pyc')
-
     def test_shelve(self):
         self.run_bzr('init')
         self.run_bzr('commit -m uc --unchanged')

=== removed file 'tests/clean_tree.py'
--- a/tests/clean_tree.py	2008-10-10 19:23:14 +0000
+++ b/tests/clean_tree.py	1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-# Copyright (C) 2005 by Aaron Bentley
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-import os
-from StringIO import StringIO
-from unittest import makeSuite
-
-from bzrlib.bzrdir import BzrDir
-from bzrlib.osutils import has_symlinks
-from bzrlib.tests import TestCaseInTempDir
-
-from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
-
-class TestCleanTree(TestCaseInTempDir):
-    def test_symlinks(self):
-        if has_symlinks() is False:
-            return
-        os.mkdir('branch')
-        BzrDir.create_standalone_workingtree('branch')
-        os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
-        os.mkdir('no-die-please')
-        assert os.path.exists('branch/die-please')
-        os.mkdir('no-die-please/child')
-
-        clean_tree('branch', unknown=True, no_prompt=True)
-        assert os.path.exists('no-die-please')
-        assert os.path.exists('no-die-please/child')
-
-    def test_iter_deletable(self):
-        """Files are selected for deletion appropriately"""
-        os.mkdir('branch')
-        tree = BzrDir.create_standalone_workingtree('branch')
-        f = file('branch/.bzrignore', 'wb')
-        try:
-            f.write('*~\n*.pyc\n.bzrignore\n')
-        finally:
-            f.close()
-        file('branch/file.BASE', 'wb').write('contents')
-        tree.lock_write()
-        try:
-            self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
-            file('branch/file', 'wb').write('contents')
-            file('branch/file~', 'wb').write('contents')
-            file('branch/file.pyc', 'wb').write('contents')
-
-            dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
-            assert sorted(['file', 'file.BASE']) == dels
-
-            dels = [r for a,r in iter_deletables(tree, detritus=True)]
-            assert sorted(['file~', 'file.BASE']) == dels
-
-            dels = [r for a,r in iter_deletables(tree, ignored=True)]
-            assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
-
-            dels = [r for a,r in iter_deletables(tree, unknown=False)]
-            assert [] == dels
-        finally:
-            tree.unlock()
-
-def test_suite():
-    return makeSuite(TestCleanTree)

=== added file 'tests/test_conflict_diff.py'
--- a/tests/test_conflict_diff.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_conflict_diff.py	2009-04-10 20:07:41 +0000
@@ -0,0 +1,67 @@
+# Copyright (C) 2009 Aaron Bentley <aaron at aaronbentley.com>
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+from cStringIO import StringIO
+import os
+
+from bzrlib.tests import TestCaseWithTransport
+from bzrlib.plugins.bzrtools import errors
+from bzrlib.plugins.bzrtools.conflict_diff import (
+    conflict_diff,
+    get_old_lines,
+)
+
+
+class TestConflictDiff(TestCaseWithTransport):
+
+    def test_conflict_diff_this(self):
+        self.build_tree_contents(
+            [('foo.THIS', 'this\n'), ('foo.BASE', 'base\n')])
+        s = StringIO()
+        conflict_diff(s, 'foo', 'this')
+        self.assertEqual('--- foo.BASE\n+++ foo.THIS\n'
+                         '@@ -1,1 +1,1 @@\n'
+                         '-base\n+this\n\n', s.getvalue())
+
+    def test_no_conflict(self):
+        tree = self.make_branch_and_tree('.')
+        self.build_tree_contents([('foo', 'base\n')])
+        tree.add('foo')
+        e = self.assertRaises(errors.NoConflictFiles, get_old_lines, 'foo',
+                              'foo.BASE')
+        self.assertEqual('foo.BASE does not exist and there are no pending'
+                         ' merges.', str(e))
+
+    def test_get_old_lines(self):
+        self.build_tree_contents([('foo.BASE', 'base\n')])
+        old_lines = get_old_lines('foo', 'foo.BASE')
+        self.assertEqual(['base\n'], old_lines)
+
+    def test_get_old_lines_no_base(self):
+        tree = self.make_branch_and_tree('tree')
+        self.build_tree_contents([('tree/foo', 'base\n')])
+        tree.add('foo')
+        tree.commit('added foo')
+        other = tree.bzrdir.sprout('other').open_workingtree()
+        self.build_tree_contents([('other/foo', 'other\n')])
+        other.commit('Changed foo text')
+        self.build_tree_contents([('tree/foo', 'this\n')])
+        tree.commit('Changed foo text')
+        tree.merge_from_branch(other.branch)
+        os.unlink('tree/foo.BASE')
+        old_lines = get_old_lines('tree/foo', 'tree/foo.BASE')
+        self.assertEqual(['base\n'], old_lines)

=== modified file 'tests/upstream_import.py'
--- a/tests/upstream_import.py	2007-04-04 18:12:00 +0000
+++ b/tests/upstream_import.py	2009-04-10 21:09:41 +0000
@@ -13,7 +13,7 @@
     import_tar,
     import_zip,
     import_dir,
-    top_directory,
+    top_path,
     ZipFileWrapper,
 )
 from bzrlib.tests import TestCaseInTempDir
@@ -154,14 +154,15 @@
             return ZipFileWrapper(fileobj, 'w')
         return self.make_archive(maker)
 
-    def test_top_directory(self):
-        self.assertEqual(top_directory('ab/b/c'), 'ab')
-        self.assertEqual(top_directory('/etc'), '/')
+    def test_top_path(self):
+        self.assertEqual(top_path('ab/b/c'), 'ab')
+        self.assertEqual(top_path('etc'), 'etc')
+        self.assertEqual(top_path('project-0.1'), 'project-0.1')
 
     def test_common_directory(self):
         self.assertEqual(common_directory(['ab/c/d', 'ab/c/e']), 'ab')
         self.assertIs(common_directory(['ab/c/d', 'ac/c/e']), None)
-        self.assertIs(None, common_directory(['FEEDME']))
+        self.assertEqual('FEEDME', common_directory(['FEEDME']))
 
     def test_untar(self):
         def builder(fileobj, mode='w'):

=== modified file 'upstream_import.py'
--- a/upstream_import.py	2007-07-26 15:52:55 +0000
+++ b/upstream_import.py	2009-04-10 21:09:41 +0000
@@ -12,7 +12,7 @@
 from bzrlib.bzrdir import BzrDir
 from bzrlib.errors import NoSuchFile, BzrCommandError, NotBranchError
 from bzrlib.osutils import (pathjoin, isdir, file_iterator, basename,
-                            file_kind)
+                            file_kind, splitpath)
 from bzrlib.trace import warning
 from bzrlib.transform import TreeTransform, resolve_conflicts, cook_conflicts
 from bzrlib.workingtree import WorkingTree
@@ -117,22 +117,20 @@
             return False
 
 
-def top_directory(path):
+def top_path(path):
     """Return the top directory given in a path."""
-    dirname = os.path.dirname(path)
-    last_dirname = dirname
-    while True:
-        dirname = os.path.dirname(dirname)
-        if dirname == '' or dirname == last_dirname:
-            return last_dirname
-        last_dirname = dirname
+    components = splitpath(path)
+    if len(components) > 0:
+        return components[0]
+    else:
+        return ''
 
 
 def common_directory(names):
     """Determine a single directory prefix from a list of names"""
     possible_prefix = None
     for name in names:
-        name_top = top_directory(name)
+        name_top = top_path(name)
         if name_top == '':
             return None
         if possible_prefix is None:

=== modified file 'version.py'
--- a/version.py	2009-02-23 16:33:46 +0000
+++ b/version.py	2009-03-25 18:49:18 +0000
@@ -1,2 +1,2 @@
-__version__ = '1.13.0'
+__version__ = '1.14.0'
 version_info = tuple(int(n) for n in __version__.split('.'))



More information about the Pkg-bazaar-commits mailing list