Merge lp:~maxb/udd/local-branches into lp:udd

Proposed by Max Bowsher
Status: Merged
Merged at revision: 374
Proposed branch: lp:~maxb/udd/local-branches
Merge into: lp:udd
Diff against target: 176 lines (+68/-10)
2 files modified
icommon.py (+49/-1)
import_package.py (+19/-9)
To merge this branch: bzr merge lp:~maxb/udd/local-branches
Reviewer Review Type Date Requested Status
Ubuntu Distributed Development Developers Pending
Review via email: mp+37419@code.launchpad.net

Description of the change

When investigating a failure like the "NoSuchTag" failures, a key problem is that it is impossible to experiment with added tags to validate that they will fix the conversion.

Therefore, I've written a new option --local-branches - when used, a special BranchStore (thanks for having that factored out! :-) ) is used, which pushes and pulls from BASE_DIR/localbranches/PACKAGENAME/DISTRO-SERIES by default, but if that doesn't exist, it first populates it from Launchpad.

This allows convenient testing of changes to the existing import branches.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

On Sun, 03 Oct 2010 20:35:54 -0000, Max Bowsher <email address hidden> wrote:
> Max Bowsher has proposed merging lp:~maxb/udd/local-branches into lp:udd.
>
> Requested reviews:
> Ubuntu Distributed Development Developers (udd)
>
>
> When investigating a failure like the "NoSuchTag" failures, a key
> problem is that it is impossible to experiment with added tags to
> validate that they will fix the conversion.

>
> Therefore, I've written a new option --local-branches - when used, a
> special BranchStore (thanks for having that factored out! :-) ) is
> used, which pushes and pulls from
> BASE_DIR/localbranches/PACKAGENAME/DISTRO-SERIES by default, but if
> that doesn't exist, it first populates it from Launchpad.

Nice idea. I'll review tomorrow, thanks.

Just to note that I've been looking at NoSuchTag today, and think I have
a handle on it, check the referenced bug.

Sorry if I've caused duplicate effort.

Thanks,

James

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'icommon.py'
--- icommon.py 2010-10-03 17:10:32 +0000
+++ icommon.py 2010-10-03 20:35:53 +0000
@@ -20,7 +20,7 @@
2020
21from debian_bundle import changelog21from debian_bundle import changelog
2222
23from bzrlib import branch, diff, errors, merge, tag, testament, transport, ui23from bzrlib import branch, bzrdir, diff, errors, merge, tag, testament, transport, ui
24from bzrlib.trace import mutter24from bzrlib.trace import mutter
2525
2626
@@ -47,6 +47,7 @@
47max_threads_file = os.path.join(base_dir, "max_threads")47max_threads_file = os.path.join(base_dir, "max_threads")
48locks_dir = os.path.join(base_dir, "locks")48locks_dir = os.path.join(base_dir, "locks")
49updates_dir = os.path.join(base_dir, "updates")49updates_dir = os.path.join(base_dir, "updates")
50localbranches_dir = os.path.join(base_dir, "localbranches")
50sqlite_file = os.path.join(base_dir, "meta.db")51sqlite_file = os.path.join(base_dir, "meta.db")
51sqlite_package_file = os.path.join(base_dir, "packages.db")52sqlite_package_file = os.path.join(base_dir, "packages.db")
52sqlite_old_failures_file = os.path.join(base_dir, "failures.db")53sqlite_old_failures_file = os.path.join(base_dir, "failures.db")
@@ -1348,6 +1349,53 @@
1348 pocket=self._lp_pocket(pocket))1349 pocket=self._lp_pocket(pocket))
13491350
13501351
1352class LocalShadowBranchStore(BranchStore):
1353
1354 def __init__(self, package, lp, suffix):
1355 BranchStore.__init__(self, package, lp, suffix)
1356 self.branches_dir = os.path.join(localbranches_dir, package)
1357 if not os.path.exists(self.branches_dir):
1358 os.makedirs(self.branches_dir)
1359 format = bzrdir.format_registry.make_bzrdir('2a')
1360 to_transport = transport.get_transport(self.branches_dir)
1361 newdir = format.initialize_on_transport(to_transport)
1362 repo = newdir.create_repository(shared=True)
1363 repo.set_make_working_trees(False)
1364
1365 def side_branch_location(self, distro, release, suite):
1366 distro, suite = self._translate_suite(distro, suite)
1367 now = datetime.datetime.utcnow()
1368 now_str = now.strftime("%Y%m%d%H%M")
1369 return os.path.join(self.branches_dir, "%s-%s-%s" % (distro, suite, now_str))
1370
1371 def get_branch_parts(self, distro, release, pocket, possible_transports=None, readonly=False):
1372 local_location = self.push_location(distro, release, pocket)
1373 try:
1374 return branch.Branch.open(local_location, possible_transports=possible_transports)
1375 except errors.NotBranchError:
1376 try:
1377 br_from = branch.Branch.open(self._branch_location(distro, release, pocket, readonly=readonly),
1378 possible_transports=possible_transports)
1379 br_from.lock_read()
1380 try:
1381 dir = br_from.bzrdir.sprout(local_location)
1382 new_br = dir.open_branch()
1383 tag._merge_tags_if_possible(br_from, new_br)
1384 finally:
1385 br_from.unlock()
1386 return new_br
1387 except errors.NotBranchError:
1388 return None
1389
1390 def push_location(self, distro, release, pocket):
1391 distro, suite = self._translate_suite(distro, make_suite(release, pocket))
1392 return os.path.join(self.branches_dir, "%s-%s%s" % (distro,
1393 suite, self.suffix))
1394
1395 def set_official(self, distro, release, pocket, set_status=False,
1396 set_reviewer=False):
1397 pass # No-op in this implementation
1398
1351class MemoryBranchStore(BranchStore):1399class MemoryBranchStore(BranchStore):
13521400
1353 def __init__(self, package, lp, suffix):1401 def __init__(self, package, lp, suffix):
13541402
=== modified file 'import_package.py'
--- import_package.py 2010-10-03 17:33:40 +0000
+++ import_package.py 2010-10-03 20:35:53 +0000
@@ -53,6 +53,12 @@
53 help="Set debug flags, see 'bzr help debug-flags'")53 help="Set debug flags, see 'bzr help debug-flags'")
54parser.add_option("--lp-cache", dest="lp_cache", default=None,54parser.add_option("--lp-cache", dest="lp_cache", default=None,
55 help="Set the location of a Launchpadlib cache")55 help="Set the location of a Launchpadlib cache")
56parser.add_option("--local-branches", dest="local_branches", action="store_true",
57 help="Debugging mode in which branches in "
58 "BASE_DIR/localbranches/PACKAGE are used instead of the "
59 "real Launchpad branches. A local branch will be branched "
60 "from the Launchpad branch on first access if it does not "
61 "exist locally")
5662
57options, args = parser.parse_args()63options, args = parser.parse_args()
5864
@@ -647,7 +653,7 @@
647 return unimported_versions653 return unimported_versions
648654
649655
650def push_branches_back(package, temp_dir, bstore, possible_transports):656def push_branches_back(package, temp_dir, bstore, possible_transports, local_branches):
651 for d in distros:657 for d in distros:
652 pushed_devel = False658 pushed_devel = False
653 for known_release in icommon.lp_distro_releases[d]:659 for known_release in icommon.lp_distro_releases[d]:
@@ -662,7 +668,7 @@
662 if os.path.exists(source_branch_path + ".overwrite"):668 if os.path.exists(source_branch_path + ".overwrite"):
663 overwrite = True669 overwrite = True
664 to_loc = bstore.push_location(d, known_release, known_pocket)670 to_loc = bstore.push_location(d, known_release, known_pocket)
665 if pushed_devel:671 if pushed_devel and not local_branches:
666 mutter("sleeping to stack")672 mutter("sleeping to stack")
667 time.sleep(300)673 time.sleep(300)
668 pushed_devel = False674 pushed_devel = False
@@ -684,7 +690,7 @@
684 except HTTPError, e:690 except HTTPError, e:
685 print e.content.decode("utf-8", "replace")691 print e.content.decode("utf-8", "replace")
686 raise692 raise
687 if os.path.exists(source_branch_path + ".collisions"):693 if os.path.exists(source_branch_path + ".collisions") and not local_branches:
688 mutter("sleeping to file merge proposal")694 mutter("sleeping to file merge proposal")
689 time.sleep(120)695 time.sleep(120)
690 f = open(source_branch_path + ".collisions")696 f = open(source_branch_path + ".collisions")
@@ -905,7 +911,7 @@
905911
906912
907def main(package, push=True, check=False, extra_debian=None, no_existing=False,913def main(package, push=True, check=False, extra_debian=None, no_existing=False,
908 keep_temp=False):914 keep_temp=False, local_branches=False):
909 if not os.path.exists(icommon.logs_dir):915 if not os.path.exists(icommon.logs_dir):
910 os.makedirs(icommon.logs_dir)916 os.makedirs(icommon.logs_dir)
911 log_name = os.path.join(icommon.logs_dir, package)917 log_name = os.path.join(icommon.logs_dir, package)
@@ -920,7 +926,10 @@
920 if not no_existing:926 if not no_existing:
921 revid_db = icommon.RevidDatabase(icommon.sqlite_file, package)927 revid_db = icommon.RevidDatabase(icommon.sqlite_file, package)
922 suffix = revid_db.get_suffix()928 suffix = revid_db.get_suffix()
923 bstore = icommon.BranchStore(package, lp, suffix)929 if local_branches:
930 bstore = icommon.LocalShadowBranchStore(package, lp, suffix)
931 else:
932 bstore = icommon.BranchStore(package, lp, suffix)
924 commit_db = icommon.CommitDatabase(icommon.sqlite_file, package)933 commit_db = icommon.CommitDatabase(icommon.sqlite_file, package)
925 else:934 else:
926 revid_db = icommon.MemoryRevidDatabase(package)935 revid_db = icommon.MemoryRevidDatabase(package)
@@ -932,7 +941,7 @@
932 def push_back():941 def push_back():
933 possible_transports = []942 possible_transports = []
934 push_branches_back(package, temp_dir, bstore,943 push_branches_back(package, temp_dir, bstore,
935 possible_transports)944 possible_transports, local_branches)
936 icommon.generate_debian_diffs(lp, temp_dir, package, bstore,945 icommon.generate_debian_diffs(lp, temp_dir, package, bstore,
937 possible_transports=possible_transports)946 possible_transports=possible_transports)
938 icommon.generate_ubuntu_merges(lp, temp_dir, package, bstore,947 icommon.generate_ubuntu_merges(lp, temp_dir, package, bstore,
@@ -990,7 +999,7 @@
990 check_dwim(temp_dir, False, do_repo=True)999 check_dwim(temp_dir, False, do_repo=True)
991 if push:1000 if push:
992 commit_db.start_commit()1001 commit_db.start_commit()
993 push_branches_back(package, temp_dir, bstore, possible_transports)1002 push_branches_back(package, temp_dir, bstore, possible_transports, local_branches)
994 icommon.generate_debian_diffs(lp, temp_dir, package, bstore,1003 icommon.generate_debian_diffs(lp, temp_dir, package, bstore,
995 possible_transports=possible_transports)1004 possible_transports=possible_transports)
996 icommon.generate_ubuntu_merges(lp, temp_dir, package, bstore,1005 icommon.generate_ubuntu_merges(lp, temp_dir, package, bstore,
@@ -1035,7 +1044,7 @@
1035 sys.exit(1)1044 sys.exit(1)
1036 bstore = icommon.BranchStore(args[0], lp)1045 bstore = icommon.BranchStore(args[0], lp)
1037 try:1046 try:
1038 sys.exit(push_branches_back(args[0], args[1], bstore, []))1047 sys.exit(push_branches_back(args[0], args[1], bstore, [], False))
1039 except HTTPError, e:1048 except HTTPError, e:
1040 print e.content.decode("utf-8", "replace")1049 print e.content.decode("utf-8", "replace")
1041 raise1050 raise
@@ -1051,7 +1060,8 @@
1051 sys.exit(main(args[0], push=not options.no_push,1060 sys.exit(main(args[0], push=not options.no_push,
1052 extra_debian=options.extra_debian, check=options.check,1061 extra_debian=options.extra_debian, check=options.check,
1053 no_existing=options.no_existing,1062 no_existing=options.no_existing,
1054 keep_temp=options.keep_temp))1063 keep_temp=options.keep_temp,
1064 local_branches=options.local_branches))
1055 except HTTPError, e:1065 except HTTPError, e:
1056 print e.content.decode("utf-8", "replace")1066 print e.content.decode("utf-8", "replace")
1057 raise1067 raise

Subscribers

People subscribed via source and target branches