~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Ian Clatworthy
  • Date: 2009-01-18 06:11:18 UTC
  • mto: (3972.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3973.
  • Revision ID: ian.clatworthy@canonical.com-20090118061118-21mjqrjiaxwz1rdl
search the start tree if the end tree doesn't have a file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1895
1895
            tree, b, fp = bzrdir.BzrDir.open_containing_tree_or_branch(
1896
1896
                location)
1897
1897
            if fp != '':
1898
 
                # If a revision is given, get the file-id from the end tree
1899
 
                if revision is not None:
1900
 
                    if len(revision) == 1:
1901
 
                        tree = revision[0].as_tree(b)
1902
 
                    elif len(revision) == 2:
1903
 
                        rev_id = revision[1].as_revision_id(b)
1904
 
                        if rev_id is None:
1905
 
                            tree = b.basis_tree()
1906
 
                        else:
1907
 
                            tree = revision[1].as_tree(b)
1908
 
                elif tree is None:
1909
 
                    tree = b.basis_tree()
1910
 
                file_id = tree.path2id(fp)
 
1898
                file_id = _get_fileid_to_log(revision, tree, b, fp)
1911
1899
                if file_id is None:
1912
1900
                    raise errors.BzrCommandError(
1913
 
                        "Path unknown at end of revision history: %s" %
 
1901
                        "Path unknown at end or start of revision range: %s" %
1914
1902
                        location)
1915
1903
        else:
1916
1904
            # local dir only
1945
1933
        finally:
1946
1934
            b.unlock()
1947
1935
 
 
1936
def _get_fileid_to_log(revision, tree, b, fp):
 
1937
    if revision is None:
 
1938
        if tree is None:
 
1939
            tree = b.basis_tree()
 
1940
        file_id = tree.path2id(fp)
 
1941
        if file_id is None:
 
1942
            # go back to when time began
 
1943
            rev1 = b.get_rev_id(1)
 
1944
            tree = b.repository.revision_tree(rev1)
 
1945
            file_id = tree.path2id(fp)
 
1946
 
 
1947
    elif len(revision) == 1:
 
1948
        # One revision given - file must exist in it
 
1949
        tree = revision[0].as_tree(b)
 
1950
        file_id = tree.path2id(fp)
 
1951
 
 
1952
    elif len(revision) == 2:
 
1953
        # Revision range given. Get the file-id from the end tree.
 
1954
        # If that fails, try the start tree.
 
1955
        rev_id = revision[1].as_revision_id(b)
 
1956
        if rev_id is None:
 
1957
            tree = b.basis_tree()
 
1958
        else:
 
1959
            tree = revision[1].as_tree(b)
 
1960
        file_id = tree.path2id(fp)
 
1961
        if file_id is None:
 
1962
            rev_id = revision[0].as_revision_id(b)
 
1963
            if rev_id is None:
 
1964
                rev1 = b.get_rev_id(1)
 
1965
                tree = b.repository.revision_tree(rev1)
 
1966
            else:
 
1967
                tree = revision[0].as_tree(b)
 
1968
            file_id = tree.path2id(fp)
 
1969
    else:
 
1970
        raise errors.BzrCommandError(
 
1971
            'bzr log --revision takes one or two values.')
 
1972
    return file_id
 
1973
 
 
1974
 
1948
1975
def _get_revision_range(revisionspec_list, branch, command_name):
1949
1976
    """Take the input of a revision option and turn it into a revision range.
1950
1977