[MERGE] Fix missing pending merges

John A Meinel john at arbash-meinel.com
Tue Jun 27 02:00:04 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jelmer Vernooij wrote:
> Hi,
> 
> WorkingTree.pending_merges() was checking for the wrong exception. This
> exception fixes this and adds a test. 
> 
> Modern checkouts, however, will always have a 'pending-merges' file. So
> alternatively, this check could be removed altogether.
> 
> Cheers,
> 
> Jelmer
> 

I think some upgrade paths might lead to a missing pending merges, if it
wasn't there to start with.

But more importantly, a user might delete the file, and it isn't 100%
critical that it is there. So I prefer if it continues to catch the
exception. And I'm +1 on your changes.

John
=:->

> 
> ------------------------------------------------------------------------
> 
> # Bazaar revision bundle v0.8
> #
> # message:
> #   Catch right exception to detect pending-merges file is missing.
> #   
> # committer: Jelmer Vernooij <jelmer at samba.org>
> # date: Tue 2006-06-27 02:52:14.816222906 +0200
> 
> === modified file bzrlib/tests/workingtree_implementations/test_workingtree.py
> --- bzrlib/tests/workingtree_implementations/test_workingtree.py
> +++ bzrlib/tests/workingtree_implementations/test_workingtree.py
> @@ -477,6 +477,12 @@
>          self.assertEqual('foo', tree.last_revision())
>          self.assertEqual('foo', tree.branch.last_revision())
>  
> +    def test_missing_pending_merges(self):
> +        master_tree = self.make_branch_and_tree('master')
> +        tree = self.make_branch_and_tree('tree')
> +        tree._control_files._transport.delete("pending-merges")
> +        self.assertEqual([], tree.pending_merges())
> +
>      def test_update_turns_local_commit_into_merge(self):
>          # doing an update with a few local commits and no master commits
>          # makes pending-merges. 
> 
> === modified file bzrlib/workingtree.py
> --- bzrlib/workingtree.py
> +++ bzrlib/workingtree.py
> @@ -656,9 +656,7 @@
>          """
>          try:
>              merges_file = self._control_files.get_utf8('pending-merges')
> -        except OSError, e:
> -            if e.errno != errno.ENOENT:
> -                raise
> +        except NoSuchFile:
>              return []
>          p = []
>          for l in merges_file.readlines():
> 
> # revision id: jelmer at samba.org-20060627005214-ada07acfa15484b7
> # sha1: 5fd216a2b0b8f5d3ace5eb6199f2272623177e4b
> # inventory sha1: b5da39296d1534f677fab685242855d8aeea6539
> # parent ids:
> #   pqm at pqm.ubuntu.com-20060626193547-43661d1377f72b4d
> # base id: pqm at pqm.ubuntu.com-20060626193547-43661d1377f72b4d
> # properties:
> #   branch-nick: bzr.dev
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEoIMUJdeBCYSNAAMRAlzTAKCciktlLu6+URalAYnrQ5RM5PxA5ACfUw5a
TSHXDedhkBgkOjLpxw75+D0=
=V5k6
-----END PGP SIGNATURE-----




More information about the bazaar mailing list