Rev 6339: Merge trunk resolving conflicts in http://bazaar.launchpad.net/~vila/bzr/integration/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Dec 2 12:35:10 UTC 2011
At http://bazaar.launchpad.net/~vila/bzr/integration/
------------------------------------------------------------
revno: 6339 [merge]
revision-id: v.ladeuil+lp at free.fr-20111202123510-2oyuj2jcfy414ldk
parent: v.ladeuil+lp at free.fr-20111202122829-qfj1bcb435vatrrn
parent: pqm at pqm.ubuntu.com-20111202122758-51hwrv7xal5mccv2
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Fri 2011-12-02 13:35:10 +0100
message:
Merge trunk resolving conflicts
modified:
bzrlib/plugins/launchpad/lp_propose.py lp_submit.py-20100120065117-penrmqruf596pui6-1
bzrlib/revisionspec.py revisionspec.py-20050907152633-17567659fd5c0ddb
bzrlib/tests/test_revisionspec.py testrevisionnamespaces.py-20050711050225-8b4af89e6b1efe84
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
-------------- next part --------------
=== modified file 'bzrlib/plugins/launchpad/lp_propose.py'
--- a/bzrlib/plugins/launchpad/lp_propose.py 2011-09-20 10:19:58 +0000
+++ b/bzrlib/plugins/launchpad/lp_propose.py 2011-12-01 23:10:02 +0000
@@ -25,6 +25,7 @@
from bzrlib import (
msgeditor,
)
+from bzrlib.i18n import gettext
from bzrlib.plugins.launchpad import (
lp_api,
lp_registration,
=== modified file 'bzrlib/revisionspec.py'
--- a/bzrlib/revisionspec.py 2011-10-05 18:11:19 +0000
+++ b/bzrlib/revisionspec.py 2011-12-01 23:10:02 +0000
@@ -38,9 +38,6 @@
)
-_marker = []
-
-
class RevisionInfo(object):
"""The results of applying a revision specification to a branch."""
@@ -58,17 +55,24 @@
or treat the result as a tuple.
"""
- def __init__(self, branch, revno, rev_id=_marker):
+ def __init__(self, branch, revno=None, rev_id=None):
self.branch = branch
- self.revno = revno
- if rev_id is _marker:
+ self._has_revno = (revno is not None)
+ self._revno = revno
+ self.rev_id = rev_id
+ if self.rev_id is None and self._revno is not None:
# allow caller to be lazy
- if self.revno is None:
- self.rev_id = None
- else:
- self.rev_id = branch.get_rev_id(self.revno)
- else:
- self.rev_id = rev_id
+ self.rev_id = branch.get_rev_id(self._revno)
+
+ @property
+ def revno(self):
+ if not self._has_revno and self.rev_id is not None:
+ try:
+ self._revno = self.branch.revision_id_to_revno(self.rev_id)
+ except errors.NoSuchRevision:
+ self._revno = None
+ self._has_revno = True
+ return self._revno
def __nonzero__(self):
# first the easy ones...
@@ -104,18 +108,17 @@
self.revno, self.rev_id, self.branch)
@staticmethod
- def from_revision_id(branch, revision_id, revs):
+ def from_revision_id(branch, revision_id, revs=symbol_versioning.DEPRECATED_PARAMETER):
"""Construct a RevisionInfo given just the id.
Use this if you don't know or care what the revno is.
"""
- if revision_id == revision.NULL_REVISION:
- return RevisionInfo(branch, 0, revision_id)
- try:
- revno = revs.index(revision_id) + 1
- except ValueError:
- revno = None
- return RevisionInfo(branch, revno, revision_id)
+ if symbol_versioning.deprecated_passed(revs):
+ symbol_versioning.warn(
+ 'RevisionInfo.from_revision_id(revs) was deprecated in 2.5.',
+ DeprecationWarning,
+ stacklevel=2)
+ return RevisionInfo(branch, revno=None, rev_id=revision_id)
class RevisionSpec(object):
@@ -138,7 +141,8 @@
"""
prefix = None
- wants_revision_history = True
+ # wants_revision_history has been deprecated in 2.5.
+ wants_revision_history = False
dwim_catchable_exceptions = (errors.InvalidRevisionSpec,)
"""Exceptions that RevisionSpec_dwim._match_on will catch.
@@ -209,7 +213,10 @@
def in_history(self, branch):
if branch:
if self.wants_revision_history:
- # TODO: avoid looking at all of history
+ symbol_versioning.warn(
+ "RevisionSpec.wants_revision_history was "
+ "deprecated in 2.5 (%s)." % self.__class__.__name__,
+ DeprecationWarning)
branch.lock_read()
try:
graph = branch.repository.get_graph()
@@ -303,9 +310,6 @@
"""
help_txt = None
- # We don't need to build the revision history ourself, that's delegated to
- # each revspec we try.
- wants_revision_history = False
_revno_regex = lazy_regex.lazy_compile(r'^(?:(\d+(\.\d+)*)|-\d+)(:.*)?$')
@@ -389,14 +393,13 @@
your history is very long.
"""
prefix = 'revno:'
- wants_revision_history = False
def _match_on(self, branch, revs):
"""Lookup a revision by revision number"""
- branch, revno, revision_id = self._lookup(branch, revs)
+ branch, revno, revision_id = self._lookup(branch)
return RevisionInfo(branch, revno, revision_id)
- def _lookup(self, branch, revs_or_none):
+ def _lookup(self, branch):
loc = self.spec.find(':')
if loc == -1:
revno_spec = self.spec
@@ -426,12 +429,8 @@
dotted = True
if branch_spec:
- # the user has override the branch to look in.
- # we need to refresh the revision_history map and
- # the branch object.
- from bzrlib.branch import Branch
- branch = Branch.open(branch_spec)
- revs_or_none = None
+ # the user has overriden the branch to look in.
+ branch = _mod_branch.Branch.open(branch_spec)
if dotted:
try:
@@ -441,7 +440,7 @@
raise errors.InvalidRevisionSpec(self.user_spec, branch)
else:
# there is no traditional 'revno' for dotted-decimal revnos.
- # so for API compatability we return None.
+ # so for API compatibility we return None.
return branch, None, revision_id
else:
last_revno, last_revision_id = branch.last_revision_info()
@@ -453,14 +452,14 @@
else:
revno = last_revno + revno + 1
try:
- revision_id = branch.get_rev_id(revno, revs_or_none)
+ revision_id = branch.get_rev_id(revno)
except errors.NoSuchRevision:
raise errors.InvalidRevisionSpec(self.user_spec, branch)
return branch, revno, revision_id
def _as_revision_id(self, context_branch):
# We would have the revno here, but we don't really care
- branch, revno, revision_id = self._lookup(context_branch, None)
+ branch, revno, revision_id = self._lookup(context_branch)
return revision_id
def needs_branch(self):
@@ -476,12 +475,11 @@
RevisionSpec_int = RevisionSpec_revno
-
class RevisionIDSpec(RevisionSpec):
def _match_on(self, branch, revs):
revision_id = self.as_revision_id(branch)
- return RevisionInfo.from_revision_id(branch, revision_id, revs)
+ return RevisionInfo.from_revision_id(branch, revision_id)
class RevisionSpec_revid(RevisionIDSpec):
@@ -523,10 +521,10 @@
prefix = 'last:'
def _match_on(self, branch, revs):
- revno, revision_id = self._revno_and_revision_id(branch, revs)
+ revno, revision_id = self._revno_and_revision_id(branch)
return RevisionInfo(branch, revno, revision_id)
- def _revno_and_revision_id(self, context_branch, revs_or_none):
+ def _revno_and_revision_id(self, context_branch):
last_revno, last_revision_id = context_branch.last_revision_info()
if self.spec == '':
@@ -545,7 +543,7 @@
revno = last_revno - offset + 1
try:
- revision_id = context_branch.get_rev_id(revno, revs_or_none)
+ revision_id = context_branch.get_rev_id(revno)
except errors.NoSuchRevision:
raise errors.InvalidRevisionSpec(self.user_spec, context_branch)
return revno, revision_id
@@ -553,7 +551,7 @@
def _as_revision_id(self, context_branch):
# We compute the revno as part of the process, but we don't really care
# about it.
- revno, revision_id = self._revno_and_revision_id(context_branch, None)
+ revno, revision_id = self._revno_and_revision_id(context_branch)
return revision_id
@@ -591,14 +589,10 @@
# We need to use the repository history here
rev = branch.repository.get_revision(r.rev_id)
if not rev.parent_ids:
- revno = 0
revision_id = revision.NULL_REVISION
else:
revision_id = rev.parent_ids[0]
- try:
- revno = revs.index(revision_id) + 1
- except ValueError:
- revno = None
+ revno = None
else:
revno = r.revno - 1
try:
@@ -609,8 +603,7 @@
return RevisionInfo(branch, revno, revision_id)
def _as_revision_id(self, context_branch):
- base_revspec = RevisionSpec.from_string(self.spec)
- base_revision_id = base_revspec.as_revision_id(context_branch)
+ base_revision_id = RevisionSpec.from_string(self.spec)._as_revision_id(context_branch)
if base_revision_id == revision.NULL_REVISION:
raise errors.InvalidRevisionSpec(self.user_spec, context_branch,
'cannot go before the null: revision')
@@ -646,8 +639,7 @@
def _match_on(self, branch, revs):
# Can raise tags not supported, NoSuchTag, etc
return RevisionInfo.from_revision_id(branch,
- branch.tags.lookup_tag(self.spec),
- revs)
+ branch.tags.lookup_tag(self.spec))
def _as_revision_id(self, context_branch):
return context_branch.tags.lookup_tag(self.spec)
@@ -657,20 +649,19 @@
class _RevListToTimestamps(object):
"""This takes a list of revisions, and allows you to bisect by date"""
- __slots__ = ['revs', 'branch']
+ __slots__ = ['branch']
- def __init__(self, revs, branch):
- self.revs = revs
+ def __init__(self, branch):
self.branch = branch
def __getitem__(self, index):
"""Get the date of the index'd item"""
- r = self.branch.repository.get_revision(self.revs[index])
+ r = self.branch.repository.get_revision(self.branch.get_rev_id(index))
# TODO: Handle timezone.
return datetime.datetime.fromtimestamp(r.timestamp)
def __len__(self):
- return len(self.revs)
+ return self.branch.revno()
class RevisionSpec_date(RevisionSpec):
@@ -750,13 +741,12 @@
hour=hour, minute=minute, second=second)
branch.lock_read()
try:
- rev = bisect.bisect(_RevListToTimestamps(revs, branch), dt)
+ rev = bisect.bisect(_RevListToTimestamps(branch), dt, 1)
finally:
branch.unlock()
- if rev == len(revs):
+ if rev == branch.revno():
raise errors.InvalidRevisionSpec(self.user_spec, branch)
- else:
- return RevisionInfo(branch, rev + 1)
+ return RevisionInfo(branch, rev)
@@ -793,11 +783,7 @@
def _find_revision_info(branch, other_location):
revision_id = RevisionSpec_ancestor._find_revision_id(branch,
other_location)
- try:
- revno = branch.revision_id_to_revno(revision_id)
- except errors.NoSuchRevision:
- revno = None
- return RevisionInfo(branch, revno, revision_id)
+ return RevisionInfo(branch, None, revision_id)
@staticmethod
def _find_revision_id(branch, other_location):
@@ -857,11 +843,7 @@
branch.fetch(other_branch, revision_b)
except errors.ReadOnlyError:
branch = other_branch
- try:
- revno = branch.revision_id_to_revno(revision_b)
- except errors.NoSuchRevision:
- revno = None
- return RevisionInfo(branch, revno, revision_b)
+ return RevisionInfo(branch, None, revision_b)
def _as_revision_id(self, context_branch):
from bzrlib.branch import Branch
=== modified file 'bzrlib/tests/test_revisionspec.py'
--- a/bzrlib/tests/test_revisionspec.py 2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/test_revisionspec.py 2011-12-01 23:10:02 +0000
@@ -20,6 +20,7 @@
from bzrlib import (
errors,
revision as _mod_revision,
+ symbol_versioning,
)
from bzrlib.tests import TestCaseWithTransport
from bzrlib.revisionspec import (
@@ -118,7 +119,10 @@
# If wants_revision_history = True, then _match_on should get the
# branch revision history
spec = RevisionSpecMatchOnTrap('foo', _internal=True)
- spec.in_history(self.tree.branch)
+ spec.wants_revision_history = True
+ self.callDeprecated(['RevisionSpec.wants_revision_history was '
+ 'deprecated in 2.5 (RevisionSpecMatchOnTrap).'],
+ spec.in_history, self.tree.branch)
self.assertEqual((self.tree.branch, ['r1' ,'r2']),
spec.last_call)
@@ -127,7 +131,6 @@
# If wants_revision_history = False, then _match_on should get None for
# the branch revision history
spec = RevisionSpecMatchOnTrap('foo', _internal=True)
- spec.wants_revision_history = False
spec.in_history(self.tree.branch)
self.assertEqual((self.tree.branch, None), spec.last_call)
@@ -150,7 +153,7 @@
def _match_on(self, branch, revs):
if self.spec == "bork":
- return RevisionInfo.from_revision_id(branch, "r1", revs)
+ return RevisionInfo.from_revision_id(branch, "r1")
else:
raise errors.InvalidRevisionSpec(self.spec, branch)
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-12-02 12:28:29 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-12-02 12:35:10 +0000
@@ -48,6 +48,10 @@
* ``bzr status`` no longer shows shelves if files are specified.
(Francis Devereux)
+* Revision specifiers will now only browse as much history as they
+ need to, rather than grabbing the whole history unnecessarily in some
+ cases. (Jelmer Vernooij)
+
* When using ``bzr switch`` to switch to a sibling of the current
branch, the relative branch name should no longer be url-encoded.
(Jelmer Vernooij)
@@ -137,6 +141,10 @@
* ``Repository.verify_revision`` has been renamed to
``Repository.verify_revision_signature``. (Jelmer Vernooij)
+* ``RevisionSpec.wants_revision_history`` now defaults to ``False`` and
+ is deprecated. The ``revs`` argument of
+ ``RevisionInfo.from_revision_id`` is now deprecated. (Jelmer Vernooij)
+
* ``Tree.get_file_by_path`` is now deprecated. Use ``Tree.get_file`` instead.
(Jelmer Vernooij, #666897)
More information about the bazaar-commits
mailing list