~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-15 11:24:18 UTC
  • mfrom: (2617 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070715112418-9nn4n6esxv60ny4b
merge bzr.dev@1617

Show diffs side-by-side

added added

removed removed

Lines of Context:
512
512
 
513
513
    def revision_id_to_revno(self, revision_id):
514
514
        """Given a revision id, return its revno"""
515
 
        if revision_id is None:
 
515
        if _mod_revision.is_null(revision_id):
516
516
            return 0
517
517
        revision_id = osutils.safe_revision_id(revision_id)
518
518
        history = self.revision_history()
708
708
        :param revision_id: The revision-id to truncate history at.  May
709
709
          be None to copy complete history.
710
710
        """
 
711
        if revision_id == _mod_revision.NULL_REVISION:
 
712
            new_history = []
711
713
        new_history = self.revision_history()
712
 
        if revision_id is not None:
 
714
        if revision_id is not None and new_history != []:
713
715
            revision_id = osutils.safe_revision_id(revision_id)
714
716
            try:
715
717
                new_history = new_history[:new_history.index(revision_id) + 1]
1411
1413
                          other_branch=None):
1412
1414
        # stop_revision must be a descendant of last_revision
1413
1415
        stop_graph = self.repository.get_revision_graph(revision_id)
1414
 
        if last_rev is not None and last_rev not in stop_graph:
 
1416
        if (last_rev is not None and last_rev != _mod_revision.NULL_REVISION
 
1417
            and last_rev not in stop_graph):
1415
1418
            # our previous tip is not merged into stop_revision
1416
1419
            raise errors.DivergedBranches(self, other_branch)
1417
1420
        # make a new revision history from the graph
1456
1459
                stop_revision = osutils.safe_revision_id(stop_revision)
1457
1460
            # whats the current last revision, before we fetch [and change it
1458
1461
            # possibly]
1459
 
            last_rev = self.last_revision()
 
1462
            last_rev = _mod_revision.ensure_null(self.last_revision())
1460
1463
            # we fetch here regardless of whether we need to so that we pickup
1461
1464
            # filled in ghosts.
1462
1465
            self.fetch(other, stop_revision)
1786
1789
        # last_rev is not in the other_last_rev history, AND
1787
1790
        # other_last_rev is not in our history, and do it without pulling
1788
1791
        # history around
1789
 
        last_rev = self.last_revision()
1790
 
        if last_rev is not None:
 
1792
        last_rev = _mod_revision.ensure_null(self.last_revision())
 
1793
        if last_rev != _mod_revision.NULL_REVISION:
1791
1794
            other.lock_read()
1792
1795
            try:
1793
1796
                other_last_rev = other.last_revision()
1794
 
                if other_last_rev is not None:
 
1797
                if not _mod_revision.is_null(other_last_rev):
1795
1798
                    # neither branch is new, we have to do some work to
1796
1799
                    # ascertain diversion.
1797
1800
                    remote_graph = other.repository.get_revision_graph(
1820
1823
        if master is not None:
1821
1824
            old_tip = self.last_revision()
1822
1825
            self.pull(master, overwrite=True)
1823
 
            if old_tip in self.repository.get_ancestry(self.last_revision(),
1824
 
                                                       topo_sorted=False):
 
1826
            if old_tip in self.repository.get_ancestry(
 
1827
                _mod_revision.ensure_null(self.last_revision()),
 
1828
                topo_sorted=False):
1825
1829
                return None
1826
1830
            return old_tip
1827
1831
        return None
1968
1972
        self._clear_cached_state()
1969
1973
 
1970
1974
    def _check_history_violation(self, revision_id):
1971
 
        last_revision = self.last_revision()
1972
 
        if last_revision is None:
 
1975
        last_revision = _mod_revision.ensure_null(self.last_revision())
 
1976
        if _mod_revision.is_null(last_revision):
1973
1977
            return
1974
1978
        if last_revision not in self._lefthand_history(revision_id):
1975
1979
            raise errors.AppendRevisionsOnlyViolation(self.base)