Merge lp:~maxb/udd/keep-temp into lp:udd

Proposed by Max Bowsher
Status: Merged
Merged at revision: 365
Proposed branch: lp:~maxb/udd/keep-temp
Merge into: lp:udd
Diff against target: 62 lines (+12/-5)
1 file modified
import_package.py (+12/-5)
To merge this branch: bzr merge lp:~maxb/udd/keep-temp
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+37409@code.launchpad.net

Description of the change

When learning about the function of the UDD import or debugging an import failure, it can be helpful for it to not delete its temporary working area when done. This branch adds a new option --keep-temp for this purpose.

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

Looks good.

I would recommend --no-push too, but it's clear that
--no-push isn't sufficient.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import_package.py'
2--- import_package.py 2010-10-03 01:42:50 +0000
3+++ import_package.py 2010-10-03 17:36:43 +0000
4@@ -46,6 +46,9 @@
5 parser.add_option("--no-existing", dest="no_existing", action="store_true")
6 parser.add_option("--extra-debian", dest="extra_debian")
7 parser.add_option("--verbose", dest="verbose", action="store_true")
8+parser.add_option("--keep-temp", dest="keep_temp", action="store_true",
9+ help="Do not delete the temporary directory at "
10+ "BASE_DIR/updates/PACKAGE_NAME when done")
11 parser.add_option("-D", dest="debug_flags", action="append", default=[],
12 help="Set debug flags, see 'bzr help debug-flags'")
13 parser.add_option("--lp-cache", dest="lp_cache", default=None,
14@@ -901,7 +904,8 @@
15 return filtered_versions
16
17
18-def main(package, push=True, check=False, extra_debian=None, no_existing=False):
19+def main(package, push=True, check=False, extra_debian=None, no_existing=False,
20+ keep_temp=False):
21 if not os.path.exists(icommon.logs_dir):
22 os.makedirs(icommon.logs_dir)
23 log_name = os.path.join(icommon.logs_dir, package)
24@@ -962,7 +966,8 @@
25 icommon.possibly_generate_ubuntu_merges(lp, temp_dir, package,
26 bstore, possible_transports=possible_transports)
27 print "Nothing new"
28- shutil.rmtree(temp_dir)
29+ if not keep_temp:
30+ shutil.rmtree(temp_dir)
31 return 0
32 # First grab all the branches locally
33 create_update_branches(package, versions, temp_dir, bstore,
34@@ -977,7 +982,7 @@
35 import_package(temp_dir, importp, revid_db, bstore, possible_transports=possible_transports)
36 revid_db.commit_outstanding()
37 except:
38- if push:
39+ if push and not keep_temp:
40 shutil.rmtree(temp_dir)
41 raise
42 if check:
43@@ -990,7 +995,8 @@
44 possible_transports=possible_transports)
45 icommon.generate_ubuntu_merges(lp, temp_dir, package, bstore,
46 possible_transports=possible_transports)
47- shutil.rmtree(temp_dir)
48+ if not keep_temp:
49+ shutil.rmtree(temp_dir)
50 revid_db.commit()
51 mutter("Imported %s" % str(versions))
52 print "Imported %s" % str(versions)
53@@ -1044,7 +1050,8 @@
54 try:
55 sys.exit(main(args[0], push=not options.no_push,
56 extra_debian=options.extra_debian, check=options.check,
57- no_existing=options.no_existing))
58+ no_existing=options.no_existing,
59+ keep_temp=options.keep_temp))
60 except HTTPError, e:
61 print e.content.decode("utf-8", "replace")
62 raise

Subscribers

People subscribed via source and target branches