Merge ~racb/usd-importer:lp/1661092 into usd-importer:master

Proposed by Robie Basak on 2017-02-02
Status: Merged
Merged at revision: 13eccc083fa323df25227c5614fdb2dac8469225
Proposed branch: ~racb/usd-importer:lp/1661092
Merge into: usd-importer:master
Diff against target: 158 lines (+35/-16)
4 files modified
usd/build.py (+3/-1)
usd/git_repository.py (+18/-6)
usd/importer.py (+8/-6)
usd/source_information.py (+6/-3)
Reviewer Review Type Date Requested Status
Nish Aravamudan 2017-02-02 Approve on 2017-02-03
Review via email: mp+316208@code.launchpad.net
To post a comment you must log in.
Nish Aravamudan (nacc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/usd/build.py b/usd/build.py
2index dc689e1..69574f7 100644
3--- a/usd/build.py
4+++ b/usd/build.py
5@@ -211,7 +211,9 @@ class USDBuild:
6 pkgname, distname)
7
8 if not upstream_version_found:
9- raise NoUpstreamFoundException
10+ raise NoUpstreamFoundException("Unable to find any prior "
11+ "publish with a matching upstream "
12+ "version to %s" % changelog.full_version)
13
14 # symlink orig tarballs
15 for entry in dsc['Files']:
16diff --git a/usd/git_repository.py b/usd/git_repository.py
17index 93aa853..3132c44 100644
18--- a/usd/git_repository.py
19+++ b/usd/git_repository.py
20@@ -247,7 +247,7 @@ class USDGitRepository:
21 # Does not seem to be working with https
22 # self.local_repo.remotes[remote_name].fetch()
23 self.git_run(['fetch', remote_name])
24- except:
25+ except CalledProcessError:
26 logging.info('No objects found in remote %s', remote_url)
27
28 self.local_repo.remotes.set_push_url(remote_name,
29@@ -367,16 +367,28 @@ class USDGitRepository:
30 else:
31 raise Exception('Unknown changelog field %s' % field)
32
33+ # We cannot use "git show" since it does not follow symlinks (LP:
34+ # #1661092). Instead, use "git cat-file --batch --follow-symlinks" and
35+ # parse the batch output (first line) to ensure that we get a blob
36+ # rather than a symlink following failure. If we don't get a blob, then
37+ # print what we got and exit 1.
38+ cat_changelog_cmd = (
39+ "echo %s:debian/changelog | "
40+ "git cat-file --batch --follow-symlinks | "
41+ "sed -n '1{/^[^ ]* blob/!{p;q1}};2,$p'"
42+ % treeish
43+ )
44+
45 try:
46 cp = run(
47- 'git show %s:debian/changelog | dpkg-parsechangelog -l- %s' %
48- (treeish, parse_params),
49+ '%s | dpkg-parsechangelog -l- %s' %
50+ (cat_changelog_cmd, parse_params),
51 shell=True, env=self._env)
52 except CalledProcessError:
53 try:
54- cp = run('git show %s:debian/changelog | %s' % (treeish,
55- shell_cmd),
56- shell=True, env=self._env)
57+ cp = run(
58+ '%s | %s' % (cat_changelog_cmd, shell_cmd),
59+ shell=True, env=self._env)
60 except CalledProcessError:
61 raise Exception('Unable to parse changelog')
62
63diff --git a/usd/importer.py b/usd/importer.py
64index 73de6a6..594b271 100755
65--- a/usd/importer.py
66+++ b/usd/importer.py
67@@ -374,7 +374,8 @@ class USDImport:
68 break
69 if extracted_dir is None:
70 logging.exception('No source extracted?')
71- raise SourceExtractionException
72+ raise SourceExtractionException("Failed to find an extracted "
73+ "directory from dpkg-source -x")
74
75 self.local_repo.git_run(['--work-tree', extracted_dir, 'add', '-f', '-A'])
76 cp = self.local_repo.git_run(['--work-tree', extracted_dir, 'write-tree'])
77@@ -411,7 +412,8 @@ class USDImport:
78 break
79 if extracted_dir is None:
80 logging.exception('No source extracted?')
81- raise SourceExtractionException
82+ raise SourceExtractionException("Failed to find an extracted "
83+ "directory from dpkg-source -x")
84
85 if os.path.isdir(os.path.join(extracted_dir, '.pc')):
86 self.local_repo.git_run(['--work-tree', extracted_dir, 'add', '-f', '-A'])
87@@ -425,7 +427,7 @@ class USDImport:
88 cp = run(['dpkg-source', '--print-format', extracted_dir])
89 fmt = decode_binary(cp.stdout).strip()
90 if '3.0 (quilt)' not in fmt:
91- raise StopIteration
92+ raise StopIteration()
93 except CalledProcessError as e:
94 try:
95 with open('debian/source/format', 'r') as f:
96@@ -433,10 +435,10 @@ class USDImport:
97 if re.match(r'3.0 (.*)', line):
98 break
99 else:
100- raise StopIteration
101+ raise StopIteration()
102 # `man dpkg-source` indicates no d/s/format implies 1.0
103 except OSError:
104- raise StopIteration
105+ raise StopIteration()
106
107 while True:
108 try:
109@@ -467,7 +469,7 @@ class USDImport:
110 # quilt returns 2 when done pushing
111 if e.returncode != 2:
112 raise
113- raise StopIteration
114+ raise StopIteration()
115 finally:
116 os.chdir(oldcwd)
117 shutil.rmtree(extract_dir)
118diff --git a/usd/source_information.py b/usd/source_information.py
119index c6a74be..f766ddf 100644
120--- a/usd/source_information.py
121+++ b/usd/source_information.py
122@@ -197,6 +197,7 @@ class USDSourceInformation(object):
123 retry_backoffs
124 ):
125 self.launchpad = launchpad_login()
126+ self.dist_name = dist_name
127 self.dist = self.launchpad.distributions[dist_name]
128 self.pkgname = pkgname
129 self.parse_pullfile(pull_overrides_filename)
130@@ -249,7 +250,8 @@ class USDSourceInformation(object):
131
132 spph = self.dist.main_archive.getPublishedSources(**args)
133 if len(spph) == 0:
134- raise NoPublicationHistoryException
135+ raise NoPublicationHistoryException("Is %s published in %s?" %
136+ (self.pkgname, self.dist_name))
137
138 for srcpkg in spph:
139 yield self.get_corrected_spi(srcpkg, workdir)
140@@ -280,7 +282,8 @@ class USDSourceInformation(object):
141 # Sanity check that the passed in srcpkg name has a publication
142 # history
143 if len(spph) == 0:
144- raise NoPublicationHistoryException
145+ raise NoPublicationHistoryException("Is %s published in %s?" %
146+ (self.pkgname, self.dist_name))
147 if len(head_versions) > 0:
148 _spph = list()
149 for spphr in spph:
150@@ -311,7 +314,7 @@ class USDSourceInformation(object):
151 )
152 )
153 yield self.get_corrected_spi(srcpkg, workdir)
154- raise StopIteration
155+ raise StopIteration()
156
157 def parse_pullfile(self, pullfile):
158 """Extract source file overrides from a file

Subscribers

People subscribed via source and target branches