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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 8651d7420e9254733234e84e84933c806521a4fc
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-bzr-dev-support
Merge into: launchpad:master
Diff against target: 327 lines (+55/-142)
5 files modified
database/schema/upgrade.py (+12/-28)
lib/lp/tests/test_no_conflict_marker.py (+5/-18)
scripts/update-version-info.sh (+18/-31)
utilities/create-lp-wadl-and-apidoc.py (+4/-13)
utilities/find-changed-files.sh (+16/-52)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+380616@code.launchpad.net

Commit message

Remove support for running Launchpad from bzr

Description of the change

We're very much committed to running on git now, so we no longer need to keep transitional support for bzr.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) wrote :

Seems to turn on!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/upgrade.py b/database/schema/upgrade.py
2index 0b14e06..abfa308 100755
3--- a/database/schema/upgrade.py
4+++ b/database/schema/upgrade.py
5@@ -1,6 +1,6 @@
6 #!/usr/bin/python -S
7 #
8-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
9+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
10 # GNU Affero General Public License version 3 (see the file LICENSE).
11
12 """
13@@ -18,9 +18,6 @@ import re
14 import subprocess
15 from textwrap import dedent
16
17-from bzrlib.branch import Branch
18-from bzrlib.errors import NotBranchError
19-
20 from lp.services.database.sqlbase import (
21 connect,
22 sqlvalues,
23@@ -93,7 +90,7 @@ FIX_PATCH_TIMES_POST_SQL = dedent("""\
24 SET
25 start_time=_start_time.start_time,
26 branch_nick = %s,
27- revno = %s,
28+ revno = NULL,
29 revid = %s
30 FROM _start_time
31 WHERE
32@@ -250,33 +247,20 @@ _vcs_details_cache = None
33
34
35 def get_vcs_details():
36- """Return (branch_nick, revno, revision_id) of this VCS branch.
37-
38- If this is a Git branch, then revno will be None.
39+ """Return (branch_nick, revision_id) of this Git branch.
40
41- Returns (None, None, None) if the tree this code is running from
42- is not a VCS branch.
43+ Returns (None, None) if the tree this code is running from is not a Git
44+ branch.
45 """
46 global _vcs_details_cache
47 if _vcs_details_cache is None:
48- top = os.path.dirname(os.path.dirname(SCHEMA_DIR))
49- if os.path.exists(os.path.join(top, ".git")):
50- branch_nick = subprocess.check_output(
51- ["git", "rev-parse", "--abbrev-ref", "HEAD"],
52- universal_newlines=True).rstrip("\n")
53- revno = None
54- revision_id = subprocess.check_output(
55- ["git", "rev-parse", "HEAD"],
56- universal_newlines=True).rstrip("\n")
57- else:
58- try:
59- branch = Branch.open_containing(SCHEMA_DIR)[0]
60- revno, revision_id = branch.last_revision_info()
61- branch_nick = branch.get_config().get_nickname()
62- except NotBranchError:
63- log.warning("Not a Bazaar branch - branch details unavailable")
64- revision_id, revno, branch_nick = None, None, None
65- _vcs_details_cache = (branch_nick, revno, revision_id)
66+ branch_nick = subprocess.check_output(
67+ ["git", "rev-parse", "--abbrev-ref", "HEAD"],
68+ universal_newlines=True).rstrip("\n")
69+ revision_id = subprocess.check_output(
70+ ["git", "rev-parse", "HEAD"],
71+ universal_newlines=True).rstrip("\n")
72+ _vcs_details_cache = (branch_nick, revision_id)
73 return _vcs_details_cache
74
75
76diff --git a/lib/lp/tests/test_no_conflict_marker.py b/lib/lp/tests/test_no_conflict_marker.py
77index 1584099..f3cade4 100644
78--- a/lib/lp/tests/test_no_conflict_marker.py
79+++ b/lib/lp/tests/test_no_conflict_marker.py
80@@ -1,4 +1,4 @@
81-# Copyright 2009 Canonical Ltd. This software is licensed under the
82+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
83 # GNU Affero General Public License version 3 (see the file LICENSE).
84
85 """Test that no files in the tree has spurious conflicts markers."""
86@@ -17,28 +17,15 @@ class NoSpuriousConflictsMarkerTest(unittest.TestCase):
87 # old heading style in some doctests.
88 CONFLICT_MARKER_RE = r'^\(<<<<<<< \|>>>>>>> \)'
89
90- # We could use bzrlib.workingtree for that test, but this cause
91- # problems when the system bzr (so the developer's branch) isn't at
92- # the same level than the bzrlib included in our tree. Anyway, it's
93- # probably faster to use grep.
94- # XXX cjwatson 2019-09-25: Once we're on git, it may be simpler to use
95- # something based on "git diff --check".
96+ # XXX cjwatson 2019-09-25: It may be simpler to use something based on
97+ # "git diff --check", but we'd need to work out what to do about its
98+ # whitespace checks.
99 def test_noSpuriousConflictsMarker(self):
100 """Fail if any spurious conflicts markers are found."""
101 root_dir = os.path.join(os.path.dirname(__file__), '../../..')
102
103- if os.path.exists(os.path.join(root_dir, '.git')):
104- list_files_command = ['git', 'ls-files']
105- else:
106- list_files_command = ['bzr', 'ls', '-R', '--versioned']
107-
108- # We need to reset PYTHONPATH here, otherwise the bzr in our tree
109- # will be picked up.
110- new_env = dict(os.environ)
111- new_env['PYTHONPATH'] = ''
112 list_files = subprocess.Popen(
113- list_files_command,
114- stdout=subprocess.PIPE, cwd=root_dir, env=new_env)
115+ ['git', 'ls-files'], stdout=subprocess.PIPE, cwd=root_dir)
116 unique_files = subprocess.Popen(
117 ['sort', '-u'],
118 stdin=list_files.stdout, stdout=subprocess.PIPE)
119diff --git a/scripts/update-version-info.sh b/scripts/update-version-info.sh
120index f925832..54e777e 100755
121--- a/scripts/update-version-info.sh
122+++ b/scripts/update-version-info.sh
123@@ -1,24 +1,27 @@
124 #!/bin/bash
125 #
126-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
127+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
128 # GNU Affero General Public License version 3 (see the file LICENSE).
129 #
130 # Update version-info.py -- but only if the revision number has
131 # changed
132-#
133
134 newfile=version-info-${RANDOM}.py
135
136-if [ -e .git ]; then
137- if ! which git > /dev/null || ! test -x $(which git); then
138- echo "No working 'git' executable found" >&2
139- exit 1
140- fi
141+if [ ! -e .git ]; then
142+ echo "Not in a Git working tree" >&2
143+ exit 1
144+fi
145
146- branch_nick="$(git rev-parse --abbrev-ref HEAD | sed "s/'/\\\\'/g")"
147- revision_id="$(git rev-parse HEAD)"
148- date="$(git show -s --format=%ci HEAD)"
149- cat > $newfile <<EOF
150+if ! which git > /dev/null || ! test -x $(which git); then
151+ echo "No working 'git' executable found" >&2
152+ exit 1
153+fi
154+
155+branch_nick="$(git rev-parse --abbrev-ref HEAD | sed "s/'/\\\\'/g")"
156+revision_id="$(git rev-parse HEAD)"
157+date="$(git show -s --format=%ci HEAD)"
158+cat > $newfile <<EOF
159 #! /usr/bin/env python
160
161 from __future__ import print_function
162@@ -32,33 +35,17 @@ version_info = {
163 if __name__ == '__main__':
164 print('revision id: %(revision_id)s' % version_info)
165 EOF
166-elif [ -d .bzr ]; then
167- if ! which bzr > /dev/null || ! test -x $(which bzr); then
168- echo "No working 'bzr' executable found" >&2
169- exit 1
170- fi
171-
172- bzr version-info --format=python > $newfile 2>/dev/null
173-else
174- echo "Not in a Git or Bazaar working tree" >&2
175- exit 1
176-fi
177
178 revision_id=$(python $newfile | sed -n 's/^revision id: //p')
179 if ! [ -f version-info.py ]; then
180 echo "Creating version-info.py at revision $revision_id"
181 mv ${newfile} version-info.py
182 else
183- # Here we compare the actual output instead of the contents of the
184- # file because bzr includes a build-date that is actually updated
185- # every time you run bzr version-info.
186- newcontents=$(python $newfile)
187- oldcontents=$(python version-info.py)
188- if [ "$newcontents" != "$oldcontents" ]; then
189- echo "Updating version-info.py to revision $revision_id"
190- mv ${newfile} version-info.py
191- else
192+ if cmp -s version-info.py "$newfile"; then
193 echo "Skipping version-info.py update; already at revision $revision_id"
194 rm ${newfile}
195+ else
196+ echo "Updating version-info.py to revision $revision_id"
197+ mv ${newfile} version-info.py
198 fi
199 fi
200diff --git a/utilities/create-lp-wadl-and-apidoc.py b/utilities/create-lp-wadl-and-apidoc.py
201index fcfe9a0..a2255ff 100755
202--- a/utilities/create-lp-wadl-and-apidoc.py
203+++ b/utilities/create-lp-wadl-and-apidoc.py
204@@ -1,6 +1,6 @@
205 #! /usr/bin/python -S
206 #
207-# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
208+# Copyright 2010-2020 Canonical Ltd. This software is licensed under the
209 # GNU Affero General Public License version 3 (see the file LICENSE).
210
211 """Create a static WADL file describing the current webservice.
212@@ -21,8 +21,6 @@ import os
213 import subprocess
214 import sys
215
216-import breezy
217-from breezy.branch import Branch
218 from lazr.restful.interfaces import IWebServiceConfiguration
219 from zope.component import getUtility
220 from zope.pagetemplate.pagetemplatefile import PageTemplateFile
221@@ -141,16 +139,9 @@ def main(directory, force=False):
222 # Get the time of the last commit. We will use this as the mtime for the
223 # generated files so that we can safely use it as part of Apache's etag
224 # generation in the face of multiple servers/filesystems.
225- top = os.path.dirname(os.path.dirname(__file__))
226- if os.path.exists(os.path.join(top, ".git")):
227- timestamp = int(subprocess.check_output(
228- ["git", "log", "-1", "--format=%ct", "HEAD"],
229- universal_newlines=True))
230- else:
231- with breezy.get_global_state():
232- branch = Branch.open(top)
233- timestamp = branch.repository.get_revision(
234- branch.last_revision()).timestamp
235+ timestamp = int(subprocess.check_output(
236+ ["git", "log", "-1", "--format=%ct", "HEAD"],
237+ universal_newlines=True))
238
239 # Start a process to build each set of WADL and HTML files.
240 processes = []
241diff --git a/utilities/find-changed-files.sh b/utilities/find-changed-files.sh
242index 159ebd4..bdaedd2 100755
243--- a/utilities/find-changed-files.sh
244+++ b/utilities/find-changed-files.sh
245@@ -1,6 +1,6 @@
246 #!/bin/bash
247 #
248-# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
249+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
250 # GNU Affero General Public License version 3 (see the file LICENSE).
251 #
252 # Determine the changed files in the working tree, or if the working tree is
253@@ -9,59 +9,23 @@
254 set -e
255 set -o pipefail
256
257-if [ -e .git ]; then
258- git_diff_files() {
259- git diff --name-only -z $@ | perl -l -0 -ne '
260- # Only show paths that exist and are not symlinks.
261- print if -e and not -l'
262- }
263+if [ ! -e .git ]; then
264+ echo "Not in a Git working tree" >&2
265+ exit 1
266+fi
267
268- files=$(git_diff_files HEAD)
269- if [ -z "$files" ]; then
270- # git doesn't give us a way to track the parent branch, so just use
271- # master by default and let the user override that using a
272- # positional argument.
273- files=$(git_diff_files "${1:-master}")
274- fi
275-elif [ -d .bzr ]; then
276- bzr() {
277- # PYTHONPATH may point to the ./lib directory in the launchpad tree.
278- # This directory includes a bzrlib. When this script calls bzr, we
279- # want it to use the system bzrlib, not the one in the launchpad
280- # tree.
281- PYTHONPATH='' `which bzr` "$@"
282- }
283+git_diff_files() {
284+ git diff --name-only -z $@ | perl -l -0 -ne '
285+ # Only show paths that exist and are not symlinks.
286+ print if -e and not -l'
287+}
288
289- diff_status=0
290- bzr diff > /dev/null || diff_status=$?
291- if [ $diff_status -eq 0 ] ; then
292- # No uncommitted changes in the tree.
293- if bzr status | grep -q "^Current thread:"; then
294- # This is a loom, lint changes relative to the lower thread.
295- rev_option="-r thread:"
296- elif [ "$(bzr pipes | sed -n -e "/^\\*/q;p" | wc -l)" -gt 0 ]; then
297- # This is a pipeline with at least one pipe before the
298- # current, lint changes relative to the previous pipe
299- rev_option="-r ancestor::prev"
300- else
301- # Lint changes relative to the parent.
302- rev=`bzr info | sed \
303- '/parent branch:/!d; s/ *parent branch: /ancestor:/'`
304- rev_option="-r $rev"
305- fi
306- elif [ $diff_status -eq 1 ] ; then
307- # Uncommitted changes in the tree, return those files.
308- rev_option=""
309- else
310- # bzr diff failed
311- exit 1
312- fi
313- # Extract filename from status line. Skip symlinks.
314- files=`bzr st --short $rev_option |
315- sed -e '/^.[MN]/!d; s/.* //' -e '/@$/d'`
316-else
317- echo "Not in a Git or Bazaar working tree" >&2
318- exit 1
319+files=$(git_diff_files HEAD)
320+if [ -z "$files" ]; then
321+ # git doesn't give us a way to track the parent branch, so just use
322+ # master by default and let the user override that using a
323+ # positional argument.
324+ files=$(git_diff_files "${1:-master}")
325 fi
326
327 echo $files

Subscribers

People subscribed via source and target branches

to status/vote changes: