Merge ~nacc/git-ubuntu:lp-importer-no-publish-parent into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Superseded
Proposed branch: ~nacc/git-ubuntu:lp-importer-no-publish-parent
Merge into: git-ubuntu:master
Diff against target: 512 lines (+81/-177)
4 files modified
gitubuntu/importer.py (+74/-162)
gitubuntu/importlocal.py (+0/-1)
gitubuntu/parent_overrides.txt (+4/-4)
man/man1/git-ubuntu-import.1 (+3/-10)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Robie Basak Pending
Review via email: mp+331822@code.launchpad.net

This proposal has been superseded by a proposal from 2017-10-27.

Description of the change

Robie,

I think this implements what you and Colin want.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:e18dd529d2d7cb7a0d789ddbefe2fe6b1b0b74d1
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/161/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Style Check
    SUCCESS: Unit Tests
    FAILED: Integration Tests

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:e18dd529d2d7cb7a0d789ddbefe2fe6b1b0b74d1
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/166/
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/166/rebuild

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

PASSED: Continuous integration, rev:454a165784906469f197b7abef16bd4f73f45f4b
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/175/
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/175/rebuild

review: Approve (continuous-integration)

Unmerged commits

454a165... by Nish Aravamudan

import: drop publishing parent functionality

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
2index 7248ee6..e96fe17 100644
3--- a/gitubuntu/importer.py
4+++ b/gitubuntu/importer.py
5@@ -413,7 +413,6 @@ def main(
6 def get_changelog_for_commit(
7 repo,
8 tree_hash,
9- publish_parent_commit,
10 changelog_parent_commit,
11 ):
12 """Extract changes to debian/changelog in this publish
13@@ -425,10 +424,6 @@ def get_changelog_for_commit(
14 cmd = ['diff-tree', '-p', changelog_parent_commit,
15 tree_hash, '--', 'debian/changelog']
16 raw_clog_entry = repo.git_run(cmd).stdout
17- elif publish_parent_commit is not None:
18- cmd = ['diff-tree', '-p', publish_parent_commit,
19- tree_hash, '--', 'debian/changelog']
20- raw_clog_entry = repo.git_run(cmd).stdout
21
22 changelog_entry = b''
23 changelog_entry_found = False
24@@ -453,10 +448,14 @@ def get_changelog_for_commit(
25 changelog_entry_found = True
26 return changelog_entry
27
28-def _commit_import(repo, spi, tree_hash, namespace,
29- publish_parent_commit,
30- changelog_parent_commit, upload_parent_commit,
31- unapplied_parent_commit
32+def _commit_import(
33+ repo,
34+ spi,
35+ tree_hash,
36+ namespace,
37+ changelog_parent_commit,
38+ upload_parent_commit,
39+ unapplied_parent_commit,
40 ):
41 """Commit a tree object into the repository with the specified
42 parents
43@@ -469,7 +468,6 @@ def _commit_import(repo, spi, tree_hash, namespace,
44 Arguments:
45 spi - A SourcePackageInformation instance for this publish
46 tree_hash - SHA1 from git-dsc-commit --tree-only of this publish
47- publish_parent_commit = SHA1 of publishing parent
48 changelog_parent_commit = SHA1 of changelog parent
49 upload_parent_commit = SHA1 of upload parent
50 unapplied_parent_commit = SHA1 of unapplied-patches import parent
51@@ -495,7 +493,6 @@ def _commit_import(repo, spi, tree_hash, namespace,
52 changelog_entry = get_changelog_for_commit(
53 repo,
54 tree_hash,
55- publish_parent_commit,
56 changelog_parent_commit
57 )
58 msg = (b'Import %s version %b to %b\n\nImported using git-ubuntu import.' %
59@@ -504,8 +501,7 @@ def _commit_import(repo, spi, tree_hash, namespace,
60
61 parents = []
62
63- if publish_parent_commit is None and \
64- changelog_parent_commit is None and \
65+ if changelog_parent_commit is None and \
66 upload_parent_commit is None and \
67 unapplied_parent_commit is None and \
68 target_head_name in repo.local_branch_names:
69@@ -514,9 +510,6 @@ def _commit_import(repo, spi, tree_hash, namespace,
70 else:
71 msg += b'\n'
72
73- if publish_parent_commit is not None:
74- parents.append(publish_parent_commit)
75- msg += b'\nPublish parent: %b' % publish_parent_commit.encode()
76 if changelog_parent_commit is not None:
77 parents.append(changelog_parent_commit)
78 msg += b'\nChangelog parent: %b' % changelog_parent_commit.encode()
79@@ -555,7 +548,6 @@ def commit_unapplied_patches_import(
80 spi,
81 import_tree_hash,
82 namespace,
83- publish_parent_commit,
84 changelog_parent_commit,
85 upload_parent_commit,
86 ):
87@@ -564,7 +556,6 @@ def commit_unapplied_patches_import(
88 spi,
89 import_tree_hash,
90 namespace,
91- publish_parent_commit,
92 changelog_parent_commit,
93 upload_parent_commit,
94 # unapplied trees do not have a distinct unapplied parent
95@@ -576,7 +567,6 @@ def commit_applied_patches_import(
96 spi,
97 import_tree_hash,
98 namespace,
99- publish_parent_commit,
100 changelog_parent_commit,
101 unapplied_parent_commit
102 ):
103@@ -585,7 +575,6 @@ def commit_applied_patches_import(
104 spi,
105 import_tree_hash,
106 namespace,
107- publish_parent_commit,
108 changelog_parent_commit,
109 # uploads will be unapplied trees currently, so applied trees
110 # can not have them as direct parents
111@@ -839,16 +828,12 @@ def parse_parentfile(parentfile, pkgname):
112 The parent overrides file specifies parent-child relationship(s),
113 where the importer may not be able to determine them automatically.
114 The format of the file is:
115- <pkgname> <child version> <publish parent version> <changelog parent version>
116+ <pkgname> <child version> <changelog parent version>
117 with one override per line.
118
119 <child version> is the published version to which this override
120 applies.
121
122- The <publish parent version> is the prior version published in the
123- same series/pocket, or the immediately preceding series/pocket, if
124- this is the first publish in a series/pocket.
125-
126 The <changelog parent version> is the prior version in the
127 child publish's debian/changelog.
128
129@@ -865,7 +850,7 @@ def parse_parentfile(parentfile, pkgname):
130 if line.startswith('#'):
131 continue
132 m = re.match(
133- r'(?P<pkgname>\S*)\s*(?P<childversion>\S*)\s*(?P<parent1version>\S*)\s*(?P<parent2version>\S*)',
134+ r'(?P<pkgname>\S*)\s*(?P<childversion>\S*)\s*(?P<parent2version>\S*)',
135 line
136 )
137 if m is None:
138@@ -873,61 +858,15 @@ def parse_parentfile(parentfile, pkgname):
139 if m.group('pkgname') != pkgname:
140 continue
141 _PARENT_OVERRIDES[m.group('childversion')] = {
142- 'publish_parent':m.group('parent1version'),
143- 'changelog_parent':m.group('parent2version')
144- }
145+ 'changelog_parent': m.group('parent2version')
146+ }
147 except FileNotFoundError:
148 pass
149
150 def override_parents(repo, spi, namespace):
151- unapplied_publish_parent_commit = None
152 unapplied_changelog_parent_commit = None
153- applied_publish_parent_commit = None
154 applied_changelog_parent_commit = None
155
156- unapplied_publish_parent_tag = repo.get_import_tag(
157- _PARENT_OVERRIDES[spi.version]['publish_parent'],
158- namespace
159- )
160- applied_publish_parent_tag = repo.get_applied_tag(
161- _PARENT_OVERRIDES[spi.version]['publish_parent'],
162- namespace
163- )
164- if unapplied_publish_parent_tag is not None:
165- # sanity check that version from d/changelog of the
166- # tagged commit matches ours
167- parent_publish_version, _ = \
168- repo.get_changelog_versions_from_treeish(
169- str(unapplied_publish_parent_tag.peel().id),
170- )
171- if parent_publish_version != _PARENT_OVERRIDES[spi.version]['publish_parent']:
172- logging.error('Found a tag corresponding to publish parent '
173- 'override version %s, but d/changelog version (%s) '
174- 'differs. Will orphan commit.',
175- _PARENT_OVERRIDES[spi.version]['publish_parent'],
176- parent_publish_version
177- )
178- else:
179- unapplied_publish_parent_commit = str(unapplied_publish_parent_tag.peel().id)
180- if applied_publish_parent_tag is not None:
181- applied_publish_parent_commit = str(applied_publish_parent_tag.peel().id)
182- logging.debug('Overriding publish parent (tag) to %s',
183- repo.tag_to_pretty_name(unapplied_publish_parent_tag)
184- )
185- else:
186- if _PARENT_OVERRIDES[spi.version]['publish_parent'] == '-':
187- logging.debug('Not setting publish parent as '
188- 'specified in override file.'
189- )
190- else:
191- raise ParentOverrideError(
192- "Specified publish parent override (%s) for version (%s) "
193- "not found in tags. Unable to proceed." % (
194- _PARENT_OVERRIDES[spi.version]['publish_parent'],
195- spi.version
196- )
197- )
198-
199 unapplied_changelog_parent_tag = repo.get_import_tag(
200 _PARENT_OVERRIDES[spi.version]['changelog_parent'],
201 namespace
202@@ -973,9 +912,7 @@ def override_parents(repo, spi, namespace):
203 )
204 )
205 return (
206- unapplied_publish_parent_commit,
207 unapplied_changelog_parent_commit,
208- applied_publish_parent_commit,
209 applied_changelog_parent_commit,
210 )
211
212@@ -1163,7 +1100,6 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
213
214 logging.debug('Tip version is %s', unapplied_tip_version)
215
216- unapplied_publish_parent_commit = None
217 unapplied_changelog_parent_commit = None
218 upload_parent_commit = None
219 unapplied_parent_commit = None
220@@ -1176,38 +1112,20 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
221
222 try:
223 (
224- unapplied_publish_parent_commit,
225 unapplied_changelog_parent_commit,
226- _,
227 _
228 ) = override_parents(repo, spi, namespace)
229 except ParentOverrideError as e:
230 logging.error("%s" % e)
231- return 1
232+ return
233 else:
234- # Get parent from publishing history (which is the last
235- # published version in the corresponding series)
236- try:
237- unapplied_publish_parent_commit = str(unapplied_tip_head.peel().id)
238- except AttributeError:
239- try:
240- unapplied_publish_parent_head = repo.get_head_by_name(spi.parent_head_name(namespace))
241- unapplied_publish_parent_commit = str(unapplied_publish_parent_head.peel().id)
242- except AttributeError:
243- pass
244- finally:
245- try:
246- unapplied_publish_parent_tag = repo.nearest_import_tag(unapplied_publish_parent_commit, namespace)
247- logging.debug('Publishing parent (tag) is %s',
248- repo.tag_to_pretty_name(unapplied_publish_parent_tag)
249- )
250- except AttributeError:
251- pass
252-
253 if version_compare(str(spi.version), unapplied_tip_version) <= 0:
254- logging.warn('Version to import (%s) is not after %s tip (%s)',
255- spi.version, pretty_head_name, unapplied_tip_version
256- )
257+ logging.warn(
258+ "Version to import (%s) is not after %s tip (%s)",
259+ spi.version,
260+ pretty_head_name,
261+ unapplied_tip_version,
262+ )
263
264 # Walk changelog backwards until we find an imported version
265 for version in import_tree_versions:
266@@ -1224,56 +1142,51 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
267 # tree's debian/changelog, as it wasn't used
268 if (version not in _PARENT_OVERRIDES and
269 parent_changelog_version != version
270- ):
271- logging.error('Found a tag corresponding to '
272- 'parent version %s, but d/changelog '
273- 'version (%s) differs. Will '
274- 'orphan commit.' % (
275- version,
276- parent_changelog_version
277- )
278- )
279+ ):
280+ logging.error(
281+ "Found a tag corresponding to parent version "
282+ "%s, but d/changelog version (%s) differs. Will "
283+ "orphan commit.",
284+ version,
285+ parent_changelog_version,
286+ )
287 else:
288 unapplied_changelog_parent_commit = str(unapplied_changelog_parent_tag.peel().id)
289- logging.debug('Changelog parent (tag) is %s',
290+ logging.debug("Changelog parent (tag) is %s",
291 repo.tag_to_pretty_name(unapplied_changelog_parent_tag)
292- )
293+ )
294 break
295
296- # If the two parents are tree-identical, then favor publication
297- # history. This deals with copy-forwards between series and with
298- # syncs.
299- if repo.treeishs_identical(unapplied_publish_parent_commit, unapplied_changelog_parent_commit):
300- unapplied_changelog_parent_commit = None
301-
302 # check if the version to import has already been uploaded to
303 # this head -- we leverage the above code to perform a 'dry-run'
304- # of the import tree, to obtain the (up to) two parents
305+ # of the import tree, to obtain the changelog parent
306 upload_tag = repo.get_upload_tag(spi.version, namespace)
307 import_tag = repo.get_import_tag(spi.version, namespace)
308- if upload_tag and not import_tag:
309+ if import_tag:
310+ if str(import_tag.peel().tree.id) != unapplied_import_tree_hash:
311+ logging.error(
312+ "Found import tag %s, but the corresponding tree "
313+ "does not match the published version. Will orphan commit.",
314+ repo.tag_to_pretty_name(import_tag),
315+ )
316+ unapplied_changelog_parent_commit = None
317+ else:
318+ repo.update_head_to_commit(
319+ spi.head_name(namespace),
320+ str(import_tag.peel().id),
321+ )
322+ return
323+ elif upload_tag:
324 if str(upload_tag.peel().tree.id) != unapplied_import_tree_hash:
325- logging.warn('Found upload tag %s, '
326- 'but the corresponding tree '
327- 'does not match the published '
328- 'version. Will import %s as '
329- 'normal, ignoring the upload tag.',
330- repo.tag_to_pretty_name(upload_tag),
331- spi.version
332- )
333+ logging.warn(
334+ "Found upload tag %s, but the corresponding tree "
335+ "does not match the published version. Will import %s as "
336+ "normal, ignoring the upload tag.",
337+ repo.tag_to_pretty_name(upload_tag),
338+ spi.version,
339+ )
340 else:
341 upload_parent_commit = str(upload_tag.peel().id)
342- if unapplied_publish_parent_commit is not None:
343- try:
344- repo.git_run(['merge-base', '--is-ancestor',
345- unapplied_publish_parent_commit,
346- upload_parent_commit
347- ]
348- )
349- unapplied_publish_parent_commit = None
350- except CalledProcessError as e:
351- if e.returncode != 1:
352- raise
353
354 if unapplied_changelog_parent_commit is not None:
355 try:
356@@ -1292,10 +1205,9 @@ def import_unapplied_spi(repo, spi, namespace, skip_orig, ubuntu_sinfo):
357 spi,
358 unapplied_import_tree_hash,
359 namespace,
360- unapplied_publish_parent_commit,
361 unapplied_changelog_parent_commit,
362 upload_parent_commit,
363- )
364+ )
365
366 update_devel_branches(
367 repo=repo,
368@@ -1349,7 +1261,6 @@ def import_applied_spi(repo, spi, namespace, ubuntu_sinfo):
369
370 logging.debug('Tip version is %s', applied_tip_version)
371
372- applied_publish_parent_commit = None
373 applied_changelog_parent_commit = None
374
375 if spi.version in _PARENT_OVERRIDES:
376@@ -1359,8 +1270,6 @@ def import_applied_spi(repo, spi, namespace, ubuntu_sinfo):
377
378 (
379 _,
380- _,
381- applied_publish_parent_commit,
382 applied_changelog_parent_commit,
383 ) = override_parents(
384 repo,
385@@ -1368,17 +1277,6 @@ def import_applied_spi(repo, spi, namespace, ubuntu_sinfo):
386 namespace,
387 )
388 else:
389- # Get parent from publishing history (which is the last
390- # published version in the corresponding series)
391- try:
392- applied_publish_parent_commit = str(applied_tip_head.peel().id)
393- except AttributeError:
394- try:
395- applied_publish_parent_head = repo.get_head_by_name(spi.applied_parent_head_name(namespace))
396- applied_publish_parent_head_commit = str(applied_publish_parent_head.peel().id)
397- except AttributeError:
398- pass
399-
400 if version_compare(str(spi.version), applied_tip_version) <= 0:
401 logging.warn('Version to import (%s) is not after %s tip (%s)',
402 spi.version, pretty_head_name, applied_tip_version
403@@ -1415,11 +1313,26 @@ def import_applied_spi(repo, spi, namespace, ubuntu_sinfo):
404 )
405 break
406
407- # If the two parents are tree-identical, then favor publication
408- # history. This deals with copy-forwards between series and with
409- # syncs.
410- if repo.treeishs_identical(applied_publish_parent_commit, applied_changelog_parent_commit):
411- applied_changelog_parent_commit = None
412+ applied_tag = repo.get_applied_tag(version, namespace)
413+ if applied_tag:
414+ # XXX: What should be checked here? The result of pushing all
415+ # the patches? How to do it most non-destructively? (Might be
416+ # able to use our new helper to get treeish after running a
417+ # command, in this case, `quilt push -a`)
418+ # if str(applied_tag.peel().tree.id) != applied_import_tree_hash:
419+ # logging.error(
420+ # "Found patches-applied import tag %s, but the "
421+ # "corresponding tree does not match the published "
422+ # "version. Will orphan commit.",
423+ # repo.tag_to_pretty_name(applied_tag),
424+ # )
425+ # applied_changelog_parent_commit = None
426+ #else:
427+ repo.update_head_to_commit(
428+ spi.applied_head_name(namespace),
429+ str(applied_tag.peel().id),
430+ )
431+ return
432
433 # Assume no patches to apply
434 applied_import_tree_hash = unapplied_import_tree_hash
435@@ -1459,7 +1372,6 @@ def import_applied_spi(repo, spi, namespace, ubuntu_sinfo):
436 spi,
437 applied_import_tree_hash,
438 namespace,
439- applied_publish_parent_commit,
440 applied_changelog_parent_commit,
441 unapplied_parent_commit,
442 )
443diff --git a/gitubuntu/importlocal.py b/gitubuntu/importlocal.py
444index 16f3a6b..13f8690 100644
445--- a/gitubuntu/importlocal.py
446+++ b/gitubuntu/importlocal.py
447@@ -209,7 +209,6 @@ def main(
448 changelog_entry = get_changelog_for_commit(
449 repo=repo,
450 tree_hash=unapplied_import_tree_hash,
451- publish_parent_commit=None,
452 changelog_parent_commit=unapplied_changelog_parent_commit,
453 )
454
455diff --git a/gitubuntu/parent_overrides.txt b/gitubuntu/parent_overrides.txt
456index 9393c8d..6045bfc 100644
457--- a/gitubuntu/parent_overrides.txt
458+++ b/gitubuntu/parent_overrides.txt
459@@ -1,4 +1,4 @@
460-# pkgname child-version publish-parent-version changelog-parent-version
461-clamav 0.91.2-3ubuntu2.1~feisty1 0.92~dfsg-2~feisty1 0.91.2-3ubuntu2.1
462-memcached 1.1.12-1 1.4.2-1 -
463-golang-golang-x-net-dev 1:0.0+git20150817.66f0418-1 0.0+git20151007.b846920+dfsg-1 0.0+git20150226.3d87fd6-3
464+# pkgname child-version changelog-parent-version
465+clamav 0.91.2-3ubuntu2.1~feisty1 0.91.2-3ubuntu2.1
466+memcached 1.1.12-1 -
467+golang-golang-x-net-dev 1:0.0+git20150817.66f0418-1 0.0+git20150226.3d87fd6-3
468diff --git a/man/man1/git-ubuntu-import.1 b/man/man1/git-ubuntu-import.1
469index 129ecd9..cbcc8cc 100644
470--- a/man/man1/git-ubuntu-import.1
471+++ b/man/man1/git-ubuntu-import.1
472@@ -33,9 +33,6 @@ Import the orig tarballs for <publish> using "gbp import-orig
473 --pristine-tar", unless they have already been imported and the imported
474 tarballs are identical.
475 .PP
476-Find a <publish parent>: the most recent patches-unapplied import to the
477-same series and pocket\&.
478-.PP
479 Find a <changelog parent>: the most recent changelog entry with a
480 corresponding patches-unapplied import\&.
481 .PP
482@@ -43,8 +40,7 @@ Find a <upload parent>: a upload-tag in the repository for the same
483 version as <publish> with git-tree-identical contents as <publish>\&.
484 .PP
485 Commit the git tree corresponding to a patches-unapplied extraction of
486-<publish> using all of <publish parent>, <changelog parent> and <upload
487-parent> as parents\&.
488+<publish> using <changelog parent> and <upload parent> as parents\&.
489 .PP
490 If this is the first patches-unapplied import of a given version, create
491 a tag in refs/tags/import/ pointing to the new commit\&.
492@@ -62,9 +58,6 @@ For each <publish> in <distribution> since the most recent
493 patches-applied import in the local repository\&:
494 .RS 4
495 .PP
496-Find a <publish parent>: the most recent patches-applied import to the
497-same series and pocket\&.
498-.PP
499 Find a <changelog parent>: the most recent changelog entry with a
500 corresponding patches-applied import\&.
501 .PP
502@@ -72,8 +65,8 @@ Find a <unapplied parent>: the corresponding patches-unapplied import of
503 <publish>'s version\&.
504 .PP
505 Commit each git tree corresponding to the application of the next quilt
506-patch in <publish> using all of <publish parent>, <changelog parent> and
507-<unapplied parent> as parent\&.
508+patch in <publish> using <changelog parent> and <unapplied parent> as
509+parents\&.
510 As each quilt patch is applied, the <unapplied parent> becomes the
511 result of the immediately prior patch's application\&.
512 .PP

Subscribers

People subscribed via source and target branches