launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01130
[Merge] lp:~gary/launchpad/bug643715 into lp:launchpad/devel
Gary Poster has proposed merging lp:~gary/launchpad/bug643715 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#643715 Updating sourcecode directory when it is a no-op is unnecessarily slow
https://bugs.launchpad.net/bugs/643715
This was just a quick itch to scratch as I was updating my tree after being away for a week. It makes calling update-sourcecode much faster.
To test, run
./utilities/update-sourcecode
If you want to play around, you can change utilities/sourcedeps.conf to revert a revision, then run update-sourcecode, and then change the revision back. I could optimize that too, but I don't think that's an important win for the common case, so I'm not worrying about it.
I made a variety of changes for lint, even though some of them didn't make a lot of sense to me. I was surprised in particular by the preference for ('foo', ) over ('foo',). It's alright.
Gary
--
https://code.launchpad.net/~gary/launchpad/bug643715/+merge/36060
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gary/launchpad/bug643715 into lp:launchpad/devel.
=== modified file 'lib/devscripts/sourcecode.py'
--- lib/devscripts/sourcecode.py 2010-04-19 11:05:07 +0000
+++ lib/devscripts/sourcecode.py 2010-09-20 19:31:09 +0000
@@ -16,7 +16,11 @@
import sys
from bzrlib.branch import Branch
-from bzrlib.errors import BzrError, NotBranchError, IncompatibleRepositories
+from bzrlib.errors import (
+ BzrError,
+ NotBranchError,
+ IncompatibleRepositories,
+ NoSuchRevision)
from bzrlib.plugin import load_plugins
from bzrlib.revisionspec import RevisionSpec
from bzrlib.trace import enable_default_logging, report_exception
@@ -135,14 +139,13 @@
return spec.as_revision_id(from_branch)
# else return None
-
def _format_revision_name(revision, tip=False):
"""Formatting helper to return human-readable identifier for revision.
If ``tip`` is True, the revision value will be ignored.
"""
if not tip and revision:
- return 'revision %s' % (revision,)
+ return 'revision %s' % (revision, )
else:
return 'tip'
@@ -178,6 +181,17 @@
possible_transports=possible_transports)
+def get_revno(wt):
+ """Get the revno of a working tree."""
+ # Ripped from bzrlib.builtins.cmd_revno.run.
+ revid = wt.last_revision()
+ try:
+ revno_t = wt.branch.revision_id_to_dotted_revno(revid)
+ except NoSuchRevision:
+ revno_t = ('???', )
+ return ".".join(str(n) for n in revno_t)
+
+
def update_branches(sourcecode_directory, update_branches,
possible_transports=None, tip=False, quiet=False):
"""Update the existing branches in sourcecode."""
@@ -193,6 +207,12 @@
print 'Updating %s to %s' % (
project, _format_revision_name(revision, tip))
local_tree = WorkingTree.open(destination)
+ # See if we can shortcut: do we already have the desired revision?
+ if not tip and revision == get_revno(local_tree):
+ if not quiet:
+ print ' (No change)'
+ continue
+ # Apparently we do not. Open the remote branch.
try:
remote_branch = Branch.open(
branch_url, possible_transports=possible_transports)
@@ -210,10 +230,10 @@
remote_branch, stop_revision=revision_id, overwrite=True,
possible_transports=possible_transports)
except IncompatibleRepositories:
- # XXX JRV 20100407: Ideally remote_branch.bzrdir._format
+ # XXX JRV 20100407: Ideally remote_branch.bzrdir._format
# should be passed into upgrade() to ensure the format is the same
- # locally and remotely. Unfortunately smart server branches
- # have their _format set to RemoteFormat rather than an actual
+ # locally and remotely. Unfortunately smart server branches
+ # have their _format set to RemoteFormat rather than an actual
# format instance.
upgrade(destination)
# Upgraded, repoen working tree
@@ -277,7 +297,6 @@
# differ from each other (because of developers fiddling with things), we can
# take a survey of all of them, and choose the most popular.
-
def main(args):
parser = optparse.OptionParser("usage: %prog [options] [root [conffile]]")
parser.add_option(
@@ -305,8 +324,8 @@
if len(args) > 3:
parser.error("Too many arguments.")
if not options.quiet:
- print 'Sourcecode: %s' % (sourcecode_directory,)
- print 'Config: %s' % (config_filename,)
+ print 'Sourcecode: %s' % (sourcecode_directory, )
+ print 'Config: %s' % (config_filename, )
enable_default_logging()
# Tell bzr to use the terminal (if any) to show progress bars
ui.ui_factory = ui.make_ui_for_terminal(
Follow ups