Merge ~racb/usd-importer:nofetch.v2 into usd-importer:master

Proposed by Robie Basak on 2017-02-01
Status: Merged
Merged at revision: e2c126ad257b666e52003e56349b5e89826f6806
Proposed branch: ~racb/usd-importer:nofetch.v2
Merge into: usd-importer:master
Diff against target: 224 lines (+52/-29)
5 files modified
usd/build.py (+3/-1)
usd/clone.py (+9/-6)
usd/git_repository.py (+14/-9)
usd/importer.py (+20/-10)
usd/source_information.py (+6/-3)
Reviewer Review Type Date Requested Status
Nish Aravamudan 2017-02-01 Approve on 2017-02-03
Review via email: mp+316157@code.launchpad.net
To post a comment you must log in.
Robie Basak (racb) wrote :

Something has screwed up here. 5cfd5ea and parents are already in master, but Launchpad doesn't seem to think so. https://code.launchpad.net/~usd-import-team/usd-importer/+git/usd-importer/+ref/master is behind compared to https://git.launchpad.net/usd-importer/log/. So Launchpad is showing more in its preview diff than it should.

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/clone.py b/usd/clone.py
17index 91edc6a..d1f5882 100644
18--- a/usd/clone.py
19+++ b/usd/clone.py
20@@ -152,13 +152,16 @@ Example:
21 if self.lp_user == LP_USER_NONE:
22 usd_proto = self.proto
23
24- self.local_repo.add_and_fetch_lpusip(self.package, self.lp_user)
25+ self.local_repo.add_lpusip(self.package, self.lp_user)
26+ self.local_repo.fetch_remote('lpusip', ignore_nonexistent=True)
27 if self.lp_user != LP_USER_NONE:
28- self.local_repo.add_and_fetch_remote(self.package,
29- self.lp_user,
30- 'lpmep',
31- self.lp_user
32- )
33+ self.local_repo.add_remote(
34+ self.package,
35+ self.lp_user,
36+ 'lpmep',
37+ self.lp_user
38+ )
39+ self.local_repo.fetch_remote('lpmep', ignore_nonexistent=True)
40
41 logging.debug("added remote 'lpmep' -> %s",
42 self.local_repo.remotes['lpmep'].url
43diff --git a/usd/git_repository.py b/usd/git_repository.py
44index 93aa853..ed95fcd 100644
45--- a/usd/git_repository.py
46+++ b/usd/git_repository.py
47@@ -203,7 +203,18 @@ class USDGitRepository:
48 )
49 sys.exit(1)
50
51- def add_and_fetch_remote(self, pkgname, repo_owner, remote_name, lp_user):
52+ def fetch_remote(self, remote_name, ignore_nonexistent=False):
53+ try:
54+ # Does not seem to be working with https
55+ # self.local_repo.remotes[remote_name].fetch()
56+ self.git_run(['fetch', remote_name])
57+ except CalledProcessError:
58+ if ignore_nonexistent:
59+ logging.info('No objects found in remote %s', remote_name)
60+ else:
61+ raise
62+
63+ def add_remote(self, pkgname, repo_owner, remote_name, lp_user):
64 if not self.fetch_proto:
65 raise Exception('Cannot fetch using an object without a protocol')
66 remote_url = ('git.launchpad.net/~%s/ubuntu/+source/%s' %
67@@ -243,12 +254,6 @@ class USDGitRepository:
68 '--no-tags'
69 ]
70 )
71- try:
72- # Does not seem to be working with https
73- # self.local_repo.remotes[remote_name].fetch()
74- self.git_run(['fetch', remote_name])
75- except:
76- logging.info('No objects found in remote %s', remote_url)
77
78 self.local_repo.remotes.set_push_url(remote_name,
79 push_url
80@@ -265,8 +270,8 @@ class USDGitRepository:
81
82 self.remote_name = remote_name
83
84- def add_and_fetch_lpusip(self, pkgname, lp_user):
85- self.add_and_fetch_remote(pkgname, 'usd-import-team', 'lpusip', lp_user)
86+ def add_lpusip(self, pkgname, lp_user):
87+ self.add_remote(pkgname, 'usd-import-team', 'lpusip', lp_user)
88
89 @property
90 def env(self):
91diff --git a/usd/importer.py b/usd/importer.py
92index 73de6a6..f0b12f9 100755
93--- a/usd/importer.py
94+++ b/usd/importer.py
95@@ -77,6 +77,10 @@ class USDImport:
96 CACHE_PATH
97 ),
98 default=argparse.SUPPRESS)
99+ parser.add_argument('--no-fetch', action='store_true',
100+ help='Do not fetch from the remote (DANGEROUS; '
101+ 'only useful for debugging); implies '
102+ '--no-push')
103 parser.add_argument('--no-push', action='store_true',
104 help='Do not push to the remote')
105 parser.add_argument('--no-clean', action='store_true',
106@@ -374,7 +378,8 @@ class USDImport:
107 break
108 if extracted_dir is None:
109 logging.exception('No source extracted?')
110- raise SourceExtractionException
111+ raise SourceExtractionException("Failed to find an extracted "
112+ "directory from dpkg-source -x")
113
114 self.local_repo.git_run(['--work-tree', extracted_dir, 'add', '-f', '-A'])
115 cp = self.local_repo.git_run(['--work-tree', extracted_dir, 'write-tree'])
116@@ -411,7 +416,8 @@ class USDImport:
117 break
118 if extracted_dir is None:
119 logging.exception('No source extracted?')
120- raise SourceExtractionException
121+ raise SourceExtractionException("Failed to find an extracted "
122+ "directory from dpkg-source -x")
123
124 if os.path.isdir(os.path.join(extracted_dir, '.pc')):
125 self.local_repo.git_run(['--work-tree', extracted_dir, 'add', '-f', '-A'])
126@@ -425,7 +431,7 @@ class USDImport:
127 cp = run(['dpkg-source', '--print-format', extracted_dir])
128 fmt = decode_binary(cp.stdout).strip()
129 if '3.0 (quilt)' not in fmt:
130- raise StopIteration
131+ raise StopIteration()
132 except CalledProcessError as e:
133 try:
134 with open('debian/source/format', 'r') as f:
135@@ -433,10 +439,10 @@ class USDImport:
136 if re.match(r'3.0 (.*)', line):
137 break
138 else:
139- raise StopIteration
140+ raise StopIteration()
141 # `man dpkg-source` indicates no d/s/format implies 1.0
142 except OSError:
143- raise StopIteration
144+ raise StopIteration()
145
146 while True:
147 try:
148@@ -467,7 +473,7 @@ class USDImport:
149 # quilt returns 2 when done pushing
150 if e.returncode != 2:
151 raise
152- raise StopIteration
153+ raise StopIteration()
154 finally:
155 os.chdir(oldcwd)
156 shutil.rmtree(extract_dir)
157@@ -880,7 +886,7 @@ class USDImport:
158 no_clean = True
159 except AttributeError:
160 directory = None
161- no_push = args.no_push
162+ no_push = args.no_push or args.no_fetch # --no-fetch implies --no-push
163 try:
164 dl_cache = args.dl_cache
165 except AttributeError:
166@@ -897,10 +903,14 @@ class USDImport:
167 atexit.register(self.cleanup, no_clean, self.local_repo.local_dir)
168
169
170- if owner != 'usd-import-team':
171- self.local_repo.add_and_fetch_remote(pkgname, owner, owner, user)
172+ if owner == 'usd-import-team':
173+ self.local_repo.add_lpusip(pkgname, user)
174+ if not args.no_fetch:
175+ self.local_repo.fetch_remote('lpusip', ignore_nonexistent=True)
176 else:
177- self.local_repo.add_and_fetch_lpusip(pkgname, user)
178+ self.local_repo.add_remote(pkgname, owner, owner, user)
179+ if not args.no_fetch:
180+ self.local_repo.fetch_remote(owner, ignore_nonexistent=True)
181
182 debian_source_information = USDSourceInformation(
183 'debian',
184diff --git a/usd/source_information.py b/usd/source_information.py
185index c6a74be..f766ddf 100644
186--- a/usd/source_information.py
187+++ b/usd/source_information.py
188@@ -197,6 +197,7 @@ class USDSourceInformation(object):
189 retry_backoffs
190 ):
191 self.launchpad = launchpad_login()
192+ self.dist_name = dist_name
193 self.dist = self.launchpad.distributions[dist_name]
194 self.pkgname = pkgname
195 self.parse_pullfile(pull_overrides_filename)
196@@ -249,7 +250,8 @@ class USDSourceInformation(object):
197
198 spph = self.dist.main_archive.getPublishedSources(**args)
199 if len(spph) == 0:
200- raise NoPublicationHistoryException
201+ raise NoPublicationHistoryException("Is %s published in %s?" %
202+ (self.pkgname, self.dist_name))
203
204 for srcpkg in spph:
205 yield self.get_corrected_spi(srcpkg, workdir)
206@@ -280,7 +282,8 @@ class USDSourceInformation(object):
207 # Sanity check that the passed in srcpkg name has a publication
208 # history
209 if len(spph) == 0:
210- raise NoPublicationHistoryException
211+ raise NoPublicationHistoryException("Is %s published in %s?" %
212+ (self.pkgname, self.dist_name))
213 if len(head_versions) > 0:
214 _spph = list()
215 for spphr in spph:
216@@ -311,7 +314,7 @@ class USDSourceInformation(object):
217 )
218 )
219 yield self.get_corrected_spi(srcpkg, workdir)
220- raise StopIteration
221+ raise StopIteration()
222
223 def parse_pullfile(self, pullfile):
224 """Extract source file overrides from a file

Subscribers

People subscribed via source and target branches