← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:remove-bzr-dev-support into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:remove-bzr-dev-support into launchpad:master.

Commit message:
Remove support for running Launchpad from bzr

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/380616

We're very much committed to running on git now, so we no longer need to keep transitional support for bzr.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-bzr-dev-support into launchpad:master.
diff --git a/database/schema/upgrade.py b/database/schema/upgrade.py
index 0b14e06..abfa308 100755
--- a/database/schema/upgrade.py
+++ b/database/schema/upgrade.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python -S
 #
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """
@@ -18,9 +18,6 @@ import re
 import subprocess
 from textwrap import dedent
 
-from bzrlib.branch import Branch
-from bzrlib.errors import NotBranchError
-
 from lp.services.database.sqlbase import (
     connect,
     sqlvalues,
@@ -93,7 +90,7 @@ FIX_PATCH_TIMES_POST_SQL = dedent("""\
     SET
         start_time=_start_time.start_time,
         branch_nick = %s,
-        revno = %s,
+        revno = NULL,
         revid = %s
     FROM _start_time
     WHERE
@@ -250,33 +247,20 @@ _vcs_details_cache = None
 
 
 def get_vcs_details():
-    """Return (branch_nick, revno, revision_id) of this VCS branch.
-
-    If this is a Git branch, then revno will be None.
+    """Return (branch_nick, revision_id) of this Git branch.
 
-    Returns (None, None, None) if the tree this code is running from
-    is not a VCS branch.
+    Returns (None, None) if the tree this code is running from is not a Git
+    branch.
     """
     global _vcs_details_cache
     if _vcs_details_cache is None:
-        top = os.path.dirname(os.path.dirname(SCHEMA_DIR))
-        if os.path.exists(os.path.join(top, ".git")):
-            branch_nick = subprocess.check_output(
-                ["git", "rev-parse", "--abbrev-ref", "HEAD"],
-                universal_newlines=True).rstrip("\n")
-            revno = None
-            revision_id = subprocess.check_output(
-                ["git", "rev-parse", "HEAD"],
-                universal_newlines=True).rstrip("\n")
-        else:
-            try:
-                branch = Branch.open_containing(SCHEMA_DIR)[0]
-                revno, revision_id = branch.last_revision_info()
-                branch_nick = branch.get_config().get_nickname()
-            except NotBranchError:
-                log.warning("Not a Bazaar branch - branch details unavailable")
-                revision_id, revno, branch_nick = None, None, None
-        _vcs_details_cache = (branch_nick, revno, revision_id)
+        branch_nick = subprocess.check_output(
+            ["git", "rev-parse", "--abbrev-ref", "HEAD"],
+            universal_newlines=True).rstrip("\n")
+        revision_id = subprocess.check_output(
+            ["git", "rev-parse", "HEAD"],
+            universal_newlines=True).rstrip("\n")
+        _vcs_details_cache = (branch_nick, revision_id)
     return _vcs_details_cache
 
 
diff --git a/lib/lp/tests/test_no_conflict_marker.py b/lib/lp/tests/test_no_conflict_marker.py
index 1584099..f3cade4 100644
--- a/lib/lp/tests/test_no_conflict_marker.py
+++ b/lib/lp/tests/test_no_conflict_marker.py
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test that no files in the tree has spurious conflicts markers."""
@@ -17,28 +17,15 @@ class NoSpuriousConflictsMarkerTest(unittest.TestCase):
     # old heading style in some doctests.
     CONFLICT_MARKER_RE = r'^\(<<<<<<< \|>>>>>>> \)'
 
-    # We could use bzrlib.workingtree for that test, but this cause
-    # problems when the system bzr (so the developer's branch) isn't at
-    # the same level than the bzrlib included in our tree. Anyway, it's
-    # probably faster to use grep.
-    # XXX cjwatson 2019-09-25: Once we're on git, it may be simpler to use
-    # something based on "git diff --check".
+    # XXX cjwatson 2019-09-25: It may be simpler to use something based on
+    # "git diff --check", but we'd need to work out what to do about its
+    # whitespace checks.
     def test_noSpuriousConflictsMarker(self):
         """Fail if any spurious conflicts markers are found."""
         root_dir = os.path.join(os.path.dirname(__file__), '../../..')
 
-        if os.path.exists(os.path.join(root_dir, '.git')):
-            list_files_command = ['git', 'ls-files']
-        else:
-            list_files_command = ['bzr', 'ls', '-R', '--versioned']
-
-        # We need to reset PYTHONPATH here, otherwise the bzr in our tree
-        # will be picked up.
-        new_env = dict(os.environ)
-        new_env['PYTHONPATH'] = ''
         list_files = subprocess.Popen(
-            list_files_command,
-            stdout=subprocess.PIPE, cwd=root_dir, env=new_env)
+            ['git', 'ls-files'], stdout=subprocess.PIPE, cwd=root_dir)
         unique_files = subprocess.Popen(
             ['sort', '-u'],
             stdin=list_files.stdout, stdout=subprocess.PIPE)
diff --git a/scripts/update-version-info.sh b/scripts/update-version-info.sh
index f925832..54e777e 100755
--- a/scripts/update-version-info.sh
+++ b/scripts/update-version-info.sh
@@ -1,24 +1,27 @@
 #!/bin/bash
 #
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 #
 # Update version-info.py -- but only if the revision number has
 # changed
-#
 
 newfile=version-info-${RANDOM}.py
 
-if [ -e .git ]; then
-    if ! which git > /dev/null || ! test -x $(which git); then
-        echo "No working 'git' executable found" >&2
-        exit 1
-    fi
+if [ ! -e .git ]; then
+    echo "Not in a Git working tree" >&2
+    exit 1
+fi
 
-    branch_nick="$(git rev-parse --abbrev-ref HEAD | sed "s/'/\\\\'/g")"
-    revision_id="$(git rev-parse HEAD)"
-    date="$(git show -s --format=%ci HEAD)"
-    cat > $newfile <<EOF
+if ! which git > /dev/null || ! test -x $(which git); then
+    echo "No working 'git' executable found" >&2
+    exit 1
+fi
+
+branch_nick="$(git rev-parse --abbrev-ref HEAD | sed "s/'/\\\\'/g")"
+revision_id="$(git rev-parse HEAD)"
+date="$(git show -s --format=%ci HEAD)"
+cat > $newfile <<EOF
 #! /usr/bin/env python
 
 from __future__ import print_function
@@ -32,33 +35,17 @@ version_info = {
 if __name__ == '__main__':
     print('revision id: %(revision_id)s' % version_info)
 EOF
-elif [ -d .bzr ]; then
-    if ! which bzr > /dev/null || ! test -x $(which bzr); then
-        echo "No working 'bzr' executable found" >&2
-        exit 1
-    fi
-
-    bzr version-info --format=python > $newfile 2>/dev/null
-else
-    echo "Not in a Git or Bazaar working tree" >&2
-    exit 1
-fi
 
 revision_id=$(python $newfile | sed -n 's/^revision id: //p')
 if ! [ -f version-info.py ]; then
     echo "Creating version-info.py at revision $revision_id"
     mv ${newfile} version-info.py
 else
-    # Here we compare the actual output instead of the contents of the
-    # file because bzr includes a build-date that is actually updated
-    # every time you run bzr version-info.
-    newcontents=$(python $newfile)
-    oldcontents=$(python version-info.py)
-    if [ "$newcontents" != "$oldcontents" ]; then
-        echo "Updating version-info.py to revision $revision_id"
-        mv ${newfile} version-info.py
-    else
+    if cmp -s version-info.py "$newfile"; then
         echo "Skipping version-info.py update; already at revision $revision_id"
         rm ${newfile}
+    else
+        echo "Updating version-info.py to revision $revision_id"
+        mv ${newfile} version-info.py
     fi
 fi
diff --git a/utilities/create-lp-wadl-and-apidoc.py b/utilities/create-lp-wadl-and-apidoc.py
index fcfe9a0..a2255ff 100755
--- a/utilities/create-lp-wadl-and-apidoc.py
+++ b/utilities/create-lp-wadl-and-apidoc.py
@@ -1,6 +1,6 @@
 #! /usr/bin/python -S
 #
-# Copyright 2010-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Create a static WADL file describing the current webservice.
@@ -21,8 +21,6 @@ import os
 import subprocess
 import sys
 
-import breezy
-from breezy.branch import Branch
 from lazr.restful.interfaces import IWebServiceConfiguration
 from zope.component import getUtility
 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
@@ -141,16 +139,9 @@ def main(directory, force=False):
     # Get the time of the last commit.  We will use this as the mtime for the
     # generated files so that we can safely use it as part of Apache's etag
     # generation in the face of multiple servers/filesystems.
-    top = os.path.dirname(os.path.dirname(__file__))
-    if os.path.exists(os.path.join(top, ".git")):
-        timestamp = int(subprocess.check_output(
-            ["git", "log", "-1", "--format=%ct", "HEAD"],
-            universal_newlines=True))
-    else:
-        with breezy.get_global_state():
-            branch = Branch.open(top)
-            timestamp = branch.repository.get_revision(
-                branch.last_revision()).timestamp
+    timestamp = int(subprocess.check_output(
+        ["git", "log", "-1", "--format=%ct", "HEAD"],
+        universal_newlines=True))
 
     # Start a process to build each set of WADL and HTML files.
     processes = []
diff --git a/utilities/find-changed-files.sh b/utilities/find-changed-files.sh
index 159ebd4..bdaedd2 100755
--- a/utilities/find-changed-files.sh
+++ b/utilities/find-changed-files.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 #
 # Determine the changed files in the working tree, or if the working tree is
@@ -9,59 +9,23 @@
 set -e
 set -o pipefail
 
-if [ -e .git ]; then
-    git_diff_files() {
-        git diff --name-only -z $@ | perl -l -0 -ne '
-            # Only show paths that exist and are not symlinks.
-            print if -e and not -l'
-    }
+if [ ! -e .git ]; then
+    echo "Not in a Git working tree" >&2
+    exit 1
+fi
 
-    files=$(git_diff_files HEAD)
-    if [ -z "$files" ]; then
-        # git doesn't give us a way to track the parent branch, so just use
-        # master by default and let the user override that using a
-        # positional argument.
-        files=$(git_diff_files "${1:-master}")
-    fi
-elif [ -d .bzr ]; then
-    bzr() {
-        # PYTHONPATH may point to the ./lib directory in the launchpad tree.
-        # This directory includes a bzrlib. When this script calls bzr, we
-        # want it to use the system bzrlib, not the one in the launchpad
-        # tree.
-        PYTHONPATH='' `which bzr` "$@"
-    }
+git_diff_files() {
+    git diff --name-only -z $@ | perl -l -0 -ne '
+        # Only show paths that exist and are not symlinks.
+        print if -e and not -l'
+}
 
-    diff_status=0
-    bzr diff > /dev/null || diff_status=$?
-    if [ $diff_status -eq 0 ] ; then
-        # No uncommitted changes in the tree.
-        if bzr status | grep -q "^Current thread:"; then
-            # This is a loom, lint changes relative to the lower thread.
-            rev_option="-r thread:"
-        elif [ "$(bzr pipes | sed -n -e "/^\\*/q;p" | wc -l)" -gt 0 ]; then
-            # This is a pipeline with at least one pipe before the
-            # current, lint changes relative to the previous pipe
-            rev_option="-r ancestor::prev"
-        else
-            # Lint changes relative to the parent.
-            rev=`bzr info | sed \
-                '/parent branch:/!d; s/ *parent branch: /ancestor:/'`
-            rev_option="-r $rev"
-        fi
-    elif [ $diff_status -eq 1 ] ; then
-        # Uncommitted changes in the tree, return those files.
-        rev_option=""
-    else
-        # bzr diff failed
-        exit 1
-    fi
-    # Extract filename from status line.  Skip symlinks.
-    files=`bzr st --short $rev_option |
-        sed -e '/^.[MN]/!d; s/.* //' -e '/@$/d'`
-else
-    echo "Not in a Git or Bazaar working tree" >&2
-    exit 1
+files=$(git_diff_files HEAD)
+if [ -z "$files" ]; then
+    # git doesn't give us a way to track the parent branch, so just use
+    # master by default and let the user override that using a
+    # positional argument.
+    files=$(git_diff_files "${1:-master}")
 fi
 
 echo $files