Merge ~racb/git-ubuntu:unglobal-parent-overrides into git-ubuntu:master

Proposed by Robie Basak
Status: Merged
Approved by: Nish Aravamudan
Approved revision: baf6159f2646ef0f9d5072e9f9ee4bd9f0dd8144
Merge reported by: Nish Aravamudan
Merged at revision: baf6159f2646ef0f9d5072e9f9ee4bd9f0dd8144
Proposed branch: ~racb/git-ubuntu:unglobal-parent-overrides
Merge into: git-ubuntu:master
Diff against target: 316 lines (+48/-40)
3 files modified
gitubuntu/importer.py (+43/-25)
gitubuntu/importlocal.py (+2/-3)
gitubuntu/importppa.py (+3/-12)
Reviewer Review Type Date Requested Status
Nish Aravamudan Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+336484@code.launchpad.net

Commit message

Make Jenkins happy

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

I compared the result of importing memcached (something that has a parent override defined) on the merge base (1e67e4c) and on this branch (baf6159). All the branches and tags resulted in identical commit hashes except for the pristine-tar branches. I smoke-checked that the pristine-tar branches visually looked completed in both cases by running git ls-tree on them.

importer/import/1.1.12-1 correctly had no parent in both 1e67e4c and baf6159.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:baf6159f2646ef0f9d5072e9f9ee4bd9f0dd8144
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/264/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/264/rebuild

review: Approve (continuous-integration)
Revision history for this message
Nish Aravamudan (nacc) wrote :

I know it's not a performance critical path, but does it make sense to make this @lru_cache()? Operationally, we don't want this to change under us, and it seems like it could during an operation?

Revision history for this message
Nish Aravamudan (nacc) :
review: Needs Information
Revision history for this message
Nish Aravamudan (nacc) wrote :

Barring that issue, I'm happy to land this and the follow-on.

Revision history for this message
Robie Basak (racb) wrote :

Which function do you mean? parse_parentfile is only called from the main function still I think (in the end)?

I did plan @lru_cache, but didn't refactor the code to re-parse every time anyway.

Revision history for this message
Nish Aravamudan (nacc) wrote :

Right, parse_parentfile before would not reparse, because _PARENT_OVERRIDES would be defined on second invocation (poor man's @lru_cache :); so if we want to be strictly functionally equivalent, we would keep that behavior. I suppose it does not matter, but we don't assert (nor is it mentioned in the comments) that calling the method will reparse every time.

Revision history for this message
Robie Basak (racb) wrote :

I see. Yes - I suppose that's a functional change to parse_parentfile. But I don't think it makes sense to maintain the old behaviour (specifically that protection). A grep for parse_parentfile confirms that we are only ever calling it once from the three main functions (import, importppa and importlocal). If I were to write this from scratch, I wouldn't include this protection, so I think it makes sense to drop it.

I can explicitly call out that change in the commit message if you wish. But I think that not having @lru_cache is the right thing to do.

Revision history for this message
Nish Aravamudan (nacc) wrote :

No, that's fine, I just wanted to make sure it was intentional.

Revision history for this message
Nish Aravamudan (nacc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
index 5e4fe00..cdd34e2 100644
--- a/gitubuntu/importer.py
+++ b/gitubuntu/importer.py
@@ -317,8 +317,7 @@ def main(
317317
318 os.makedirs(workdir, exist_ok=True)318 os.makedirs(workdir, exist_ok=True)
319319
320 # now sets a global _PARENT_OVERRIDES320 parent_overrides = parse_parentfile(parentfile, pkgname)
321 parse_parentfile(parentfile, pkgname)
322321
323 only_debian, history_found = import_publishes(322 only_debian, history_found = import_publishes(
324 repo=repo,323 repo=repo,
@@ -333,6 +332,7 @@ def main(
333 workdir=workdir,332 workdir=workdir,
334 skip_orig=skip_orig,333 skip_orig=skip_orig,
335 allow_applied_failures=allow_applied_failures,334 allow_applied_failures=allow_applied_failures,
335 parent_overrides=parent_overrides,
336 )336 )
337337
338 if not history_found:338 if not history_found:
@@ -354,6 +354,7 @@ def main(
354 workdir=workdir,354 workdir=workdir,
355 skip_orig=skip_orig,355 skip_orig=skip_orig,
356 allow_applied_failures=allow_applied_failures,356 allow_applied_failures=allow_applied_failures,
357 parent_overrides=parent_overrides,
357 )358 )
358359
359 update_devel_branches(360 update_devel_branches(
@@ -846,7 +847,6 @@ def import_patches_applied_tree(repo, dsc_pathname):
846 shutil.rmtree(extract_dir)847 shutil.rmtree(extract_dir)
847 repo.clean_repository_state()848 repo.clean_repository_state()
848849
849_PARENT_OVERRIDES = None
850def parse_parentfile(parentfile, pkgname):850def parse_parentfile(parentfile, pkgname):
851 """Extract parent overrides from a file851 """Extract parent overrides from a file
852852
@@ -862,13 +862,13 @@ def parse_parentfile(parentfile, pkgname):
862 The <changelog parent version> is the prior version in the862 The <changelog parent version> is the prior version in the
863 child publish's debian/changelog.863 child publish's debian/changelog.
864864
865 Keyword Arguments:865 :param str parentfile: path to parent overrides file
866 parentfile -- Path to parent overrides file866 :param str pkgname: source package name on which to filter
867 :rtype: dict
868 :returns: dictionary keyed by version string of dictionaries keyed by
869 'changelog_parent' of strings of changelog parent versions.
867 """870 """
868 global _PARENT_OVERRIDES871 parent_overrides = dict()
869 if _PARENT_OVERRIDES:
870 return
871 _PARENT_OVERRIDES = dict()
872 try:872 try:
873 with open(parentfile) as f:873 with open(parentfile) as f:
874 for line in f:874 for line in f:
@@ -882,22 +882,30 @@ def parse_parentfile(parentfile, pkgname):
882 continue882 continue
883 if m.group('pkgname') != pkgname:883 if m.group('pkgname') != pkgname:
884 continue884 continue
885 _PARENT_OVERRIDES[m.group('childversion')] = {885 parent_overrides[m.group('childversion')] = {
886 'changelog_parent': m.group('parent2version')886 'changelog_parent': m.group('parent2version')
887 }887 }
888 except FileNotFoundError:888 except FileNotFoundError:
889 pass889 pass
890890
891def override_parents(repo, spi, namespace):891 return parent_overrides
892
893def override_parents(parent_overrides, repo, spi, namespace):
894 """
895 returns: (unapplied, applied) where both elements of the tuple are commit
896 hash strings of the changelog parent to use, incorporating any defined
897 overrides.
898 rtype: tuple(str, str)
899 """
892 unapplied_changelog_parent_commit = None900 unapplied_changelog_parent_commit = None
893 applied_changelog_parent_commit = None901 applied_changelog_parent_commit = None
894902
895 unapplied_changelog_parent_tag = repo.get_import_tag(903 unapplied_changelog_parent_tag = repo.get_import_tag(
896 _PARENT_OVERRIDES[spi.version]['changelog_parent'],904 parent_overrides[spi.version]['changelog_parent'],
897 namespace905 namespace
898 )906 )
899 applied_changelog_parent_tag = repo.get_applied_tag(907 applied_changelog_parent_tag = repo.get_applied_tag(
900 _PARENT_OVERRIDES[spi.version]['changelog_parent'],908 parent_overrides[spi.version]['changelog_parent'],
901 namespace909 namespace
902 )910 )
903 if unapplied_changelog_parent_tag is not None:911 if unapplied_changelog_parent_tag is not None:
@@ -906,13 +914,13 @@ def override_parents(repo, spi, namespace):
906 parent_changelog_version, _ = repo.get_changelog_versions_from_treeish(914 parent_changelog_version, _ = repo.get_changelog_versions_from_treeish(
907 str(unapplied_changelog_parent_tag.peel().id),915 str(unapplied_changelog_parent_tag.peel().id),
908 )916 )
909 if parent_changelog_version != _PARENT_OVERRIDES[spi.version]['changelog_parent']:917 if parent_changelog_version != parent_overrides[spi.version]['changelog_parent']:
910 logging.error('Found a tag corresponding to '918 logging.error('Found a tag corresponding to '
911 'changelog parent override '919 'changelog parent override '
912 'version %s, but d/changelog '920 'version %s, but d/changelog '
913 'version (%s) differs. Will '921 'version (%s) differs. Will '
914 'orphan commit.' % (922 'orphan commit.' % (
915 _PARENT_OVERRIDES[spi.version]['changelog_parent'],923 parent_overrides[spi.version]['changelog_parent'],
916 parent_changelog_version924 parent_changelog_version
917 )925 )
918 )926 )
@@ -924,7 +932,7 @@ def override_parents(repo, spi, namespace):
924 repo.tag_to_pretty_name(unapplied_changelog_parent_tag)932 repo.tag_to_pretty_name(unapplied_changelog_parent_tag)
925 )933 )
926 else:934 else:
927 if _PARENT_OVERRIDES[spi.version]['changelog_parent'] == '-':935 if parent_overrides[spi.version]['changelog_parent'] == '-':
928 logging.debug('Not setting changelog parent as specified '936 logging.debug('Not setting changelog parent as specified '
929 'in override file.'937 'in override file.'
930 )938 )
@@ -932,7 +940,7 @@ def override_parents(repo, spi, namespace):
932 raise ParentOverrideError(940 raise ParentOverrideError(
933 "Specified changelog parent override (%s) for version "941 "Specified changelog parent override (%s) for version "
934 "(%s) not found in tags. Unable to proceed." % (942 "(%s) not found in tags. Unable to proceed." % (
935 _PARENT_OVERRIDES[spi.version]['changelog_parent'],943 parent_overrides[spi.version]['changelog_parent'],
936 spi.version,944 spi.version,
937 )945 )
938 )946 )
@@ -1057,7 +1065,13 @@ def update_devel_branches(
10571065
10581066
1059# imports a package based upon source package information1067# imports a package based upon source package information
1060def import_unapplied_spi(repo, spi, namespace, skip_orig):1068def import_unapplied_spi(
1069 repo,
1070 spi,
1071 namespace,
1072 skip_orig,
1073 parent_overrides,
1074):
1061 """Imports a source package from Launchpad into the git1075 """Imports a source package from Launchpad into the git
1062 repository1076 repository
10631077
@@ -1118,7 +1132,7 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig):
1118 )1132 )
11191133
1120 # sanity check on spph and d/changelog agreeing on the latest version1134 # sanity check on spph and d/changelog agreeing on the latest version
1121 if spi.version not in _PARENT_OVERRIDES:1135 if spi.version not in parent_overrides:
1122 assert spi.version == changelog_version, (1136 assert spi.version == changelog_version, (
1123 'source pkg version: {} != changelog version: {}'.format(1137 'source pkg version: {} != changelog version: {}'.format(
1124 spi.version, changelog_version))1138 spi.version, changelog_version))
@@ -1144,7 +1158,7 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig):
1144 upload_parent_commit = None1158 upload_parent_commit = None
1145 unapplied_parent_commit = None1159 unapplied_parent_commit = None
11461160
1147 if spi.version in _PARENT_OVERRIDES:1161 if spi.version in parent_overrides:
1148 logging.debug(1162 logging.debug(
1149 '%s is specified in the parent override file.',1163 '%s is specified in the parent override file.',
1150 spi.version1164 spi.version
@@ -1154,7 +1168,7 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig):
1154 (1168 (
1155 unapplied_changelog_parent_commit,1169 unapplied_changelog_parent_commit,
1156 _1170 _
1157 ) = override_parents(repo, spi, namespace)1171 ) = override_parents(parent_overrides, repo, spi, namespace)
1158 except ParentOverrideError as e:1172 except ParentOverrideError as e:
1159 logging.error("%s" % e)1173 logging.error("%s" % e)
1160 return1174 return
@@ -1180,7 +1194,7 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig):
1180 # if the parent was imported via a parent override1194 # if the parent was imported via a parent override
1181 # itself, assume it is valid without checking its1195 # itself, assume it is valid without checking its
1182 # tree's debian/changelog, as it wasn't used1196 # tree's debian/changelog, as it wasn't used
1183 if (version not in _PARENT_OVERRIDES and1197 if (version not in parent_overrides and
1184 parent_changelog_version != version1198 parent_changelog_version != version
1185 ):1199 ):
1186 logging.error(1200 logging.error(
@@ -1257,7 +1271,8 @@ def import_applied_spi(
1257 repo,1271 repo,
1258 spi,1272 spi,
1259 namespace,1273 namespace,
1260 allow_applied_failures1274 allow_applied_failures,
1275 parent_overrides,
1261):1276):
1262 """Imports a source package from Launchpad into the git1277 """Imports a source package from Launchpad into the git
1263 repository1278 repository
@@ -1304,7 +1319,7 @@ def import_applied_spi(
13041319
1305 applied_changelog_parent_commit = None1320 applied_changelog_parent_commit = None
13061321
1307 if spi.version in _PARENT_OVERRIDES:1322 if spi.version in parent_overrides:
1308 logging.debug('%s is specified in the parent override file.' %1323 logging.debug('%s is specified in the parent override file.' %
1309 spi.version1324 spi.version
1310 )1325 )
@@ -1313,6 +1328,7 @@ def import_applied_spi(
1313 _,1328 _,
1314 applied_changelog_parent_commit,1329 applied_changelog_parent_commit,
1315 ) = override_parents(1330 ) = override_parents(
1331 parent_overrides,
1316 repo,1332 repo,
1317 spi,1333 spi,
1318 namespace,1334 namespace,
@@ -1336,7 +1352,7 @@ def import_applied_spi(
1336 # if the parent was imported via a parent override1352 # if the parent was imported via a parent override
1337 # itself, assume it is valid without checking its1353 # itself, assume it is valid without checking its
1338 # tree's debian/changelog, as it wasn't used1354 # tree's debian/changelog, as it wasn't used
1339 if (version not in _PARENT_OVERRIDES and1355 if (version not in parent_overrides and
1340 parent_changelog_version != version1356 parent_changelog_version != version
1341 ):1357 ):
1342 logging.error('Found a tag corresponding to '1358 logging.error('Found a tag corresponding to '
@@ -1435,6 +1451,7 @@ def import_publishes(
1435 workdir,1451 workdir,
1436 skip_orig,1452 skip_orig,
1437 allow_applied_failures,1453 allow_applied_failures,
1454 parent_overrides,
1438):1455):
1439 history_found = False1456 history_found = False
1440 only_debian = False1457 only_debian = False
@@ -1471,6 +1488,7 @@ def import_publishes(
1471 repo=repo,1488 repo=repo,
1472 spi=srcpkg_information,1489 spi=srcpkg_information,
1473 namespace=_namespace,1490 namespace=_namespace,
1491 parent_overrides=parent_overrides,
1474 )1492 )
1475 except NoPublicationHistoryException:1493 except NoPublicationHistoryException:
1476 logging.warning("No publication history found for %s in %s.",1494 logging.warning("No publication history found for %s in %s.",
diff --git a/gitubuntu/importlocal.py b/gitubuntu/importlocal.py
index 13f8690..b514edf 100644
--- a/gitubuntu/importlocal.py
+++ b/gitubuntu/importlocal.py
@@ -15,7 +15,6 @@ from gitubuntu.run import run, runq
15from gitubuntu.version import VERSION15from gitubuntu.version import VERSION
16from gitubuntu.importer import (16from gitubuntu.importer import (
17 parse_parentfile,17 parse_parentfile,
18 _PARENT_OVERRIDES,
19 import_orig,18 import_orig,
20 import_dsc,19 import_dsc,
21 get_changelog_for_commit,20 get_changelog_for_commit,
@@ -84,7 +83,7 @@ def main(
8483
85 repo.clean_repository_state()84 repo.clean_repository_state()
8685
87 parse_parentfile(parentfile, pkgname)86 parent_overrides = parse_parentfile(parentfile, pkgname)
8887
89 unapplied_import_tree_hash = import_patches_unapplied_tree(repo, dsc_path)88 unapplied_import_tree_hash = import_patches_unapplied_tree(repo, dsc_path)
9089
@@ -137,7 +136,7 @@ def main(
137 # if the parent was imported via a parent override136 # if the parent was imported via a parent override
138 # itself, assume it is valid without checking its137 # itself, assume it is valid without checking its
139 # tree's debian/changelog, as it wasn't used138 # tree's debian/changelog, as it wasn't used
140 if (version not in _PARENT_OVERRIDES and139 if (version not in parent_overrides and
141 parent_changelog_version != version140 parent_changelog_version != version
142 ):141 ):
143 logging.error('Found a tag corresponding to '142 logging.error('Found a tag corresponding to '
diff --git a/gitubuntu/importppa.py b/gitubuntu/importppa.py
index 835b0aa..a2d27d3 100644
--- a/gitubuntu/importppa.py
+++ b/gitubuntu/importppa.py
@@ -8,26 +8,15 @@ import sys
8from gitubuntu.cache import CACHE_PATH8from gitubuntu.cache import CACHE_PATH
9from gitubuntu.git_repository import (9from gitubuntu.git_repository import (
10 GitUbuntuRepository,10 GitUbuntuRepository,
11 GitUbuntuRepositoryFetchError,
12)11)
13from gitubuntu.importer import (12from gitubuntu.importer import (
14 cleanup,
15 parse_parentfile,13 parse_parentfile,
16 _PARENT_OVERRIDES,
17 import_orig,
18 import_dsc,
19 get_changelog_for_commit,
20 import_unapplied_spi,14 import_unapplied_spi,
21 import_applied_spi,15 import_applied_spi,
22 import_patches_unapplied_tree,
23 import_patches_applied_tree,
24)16)
25from gitubuntu.source_information import (17from gitubuntu.source_information import (
26 GitUbuntuSourceInformation,18 GitUbuntuSourceInformation,
27 NoPublicationHistoryException,19 NoPublicationHistoryException,
28 SourceExtractionException,
29 launchpad_login_auth,
30 GitUbuntuSourceInformation,
31)20)
32from gitubuntu.version import VERSION21from gitubuntu.version import VERSION
33try:22try:
@@ -110,7 +99,7 @@ def main(
11099
111 os.makedirs(workdir, exist_ok=True)100 os.makedirs(workdir, exist_ok=True)
112101
113 parse_parentfile(pkgname, parentfile)102 parent_overrides = parse_parentfile(pkgname, parentfile)
114103
115 history_found = False104 history_found = False
116 try:105 try:
@@ -126,6 +115,7 @@ def main(
126 spi=srcpkg_information,115 spi=srcpkg_information,
127 namespace=namespace,116 namespace=namespace,
128 skip_orig=skip_orig,117 skip_orig=skip_orig,
118 parent_overrides=parent_overrides,
129 )119 )
130 except DownloadError:120 except DownloadError:
131 # it is non-fatal for a PPA to not have files for older121 # it is non-fatal for a PPA to not have files for older
@@ -159,6 +149,7 @@ def main(
159 spi=srcpkg_information,149 spi=srcpkg_information,
160 namespace=namespace,150 namespace=namespace,
161 allow_applied_failures=allow_applied_failures,151 allow_applied_failures=allow_applied_failures,
152 parent_overrides=parent_overrides,
162 )153 )
163 except DownloadError:154 except DownloadError:
164 # it is non-fatal for a PPA to not have files for older155 # it is non-fatal for a PPA to not have files for older

Subscribers

People subscribed via source and target branches