Merge lp:~quickly-committers/quickly/702153 into lp:quickly

Proposed by Michael Terry
Status: Needs review
Proposed branch: lp:~quickly-committers/quickly/702153
Merge into: lp:quickly
Diff against target: 89 lines (+48/-3)
3 files modified
quickly/builtincommands.py (+10/-1)
quickly/templatetools.py (+23/-2)
quickly/test/quickly.sh (+15/-0)
To merge this branch: bzr merge lp:~quickly-committers/quickly/702153
Reviewer Review Type Date Requested Status
Tony Byrne Needs Fixing
Review via email: mp+67048@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tony Byrne (tony-badwolf) wrote :

Hi Michael
 I looked at this quite a while ago and couldn't make up my mind if is was a bug or not. We will agree it is a bug because it generates a false error message.

 If the derived template was produced by an earlier version of quickly we would like to call upgrade on the project. Quickly marks *all* projects for upgrade that are created from derived templates, probably because it is difficult to discover which version of quickly produced the template.

templatetools contains the comment
# initialize with an empty project version to force first upgrade

Calling upgrade fails for templates produced by version 11.04 because it expects old code to be present in the project. I added a patch to https://bugs.launchpad.net/quickly/+bug/702153 which seems to directly address the problem.

I've marked this branch as needs fixing because I suspect that it will skip upgrade for old templates in ~/quickly-templates. I don't have a codebase to be sure.

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

OK, I applied your patch from the bug. I guess that means this branch is no longer quite needed? I can close it out if so.

Unmerged revisions

622. By Michael Terry

when creating a project, record version of parent templates

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quickly/builtincommands.py'
2--- quickly/builtincommands.py 2010-11-29 15:18:46 +0000
3+++ quickly/builtincommands.py 2011-07-06 14:29:39 +0000
4@@ -63,9 +63,18 @@
5 os.mkdir(project_name)
6
7 # creating quickly file
8- configurationhandler.project_config['version'] = quicklyconfig.__version__
9 configurationhandler.project_config['project'] = project_name
10 configurationhandler.project_config['template'] = project_template
11+
12+ # Set version for this template and all parent templates too
13+ version = templatetools.get_template_version(project_template)
14+ configurationhandler.project_config['version'] = version
15+ parent = templatetools.get_parent_template(project_template)
16+ while parent:
17+ version = templatetools.get_template_version(parent)
18+ configurationhandler.project_config['version_%s' % parent] = version
19+ parent = templatetools.get_parent_template(parent)
20+
21 configurationhandler.saveConfig(config_file_path=project_name)
22
23 os.chdir(project_name)
24
25=== modified file 'quickly/templatetools.py'
26--- quickly/templatetools.py 2011-06-06 10:14:40 +0000
27+++ quickly/templatetools.py 2011-07-06 14:29:39 +0000
28@@ -150,8 +150,22 @@
29 return True
30 return False
31
32-def get_project_and_template_versions(template_name):
33- """Return project and template version"""
34+def get_parent_template(template_name):
35+ """Return name of parent template or None"""
36+
37+ try:
38+ template_path = tools.get_template_directory(template_name)
39+ config = file(os.path.join(template_path, 'commandsconfig'), 'rb').read()
40+ re_result = re.search('^\[(.*)\]$', config, re.MULTILINE)
41+ if re_result:
42+ return re_result.group(1)
43+ else:
44+ return None
45+ except Exception:
46+ return None
47+
48+def get_template_version(template_name):
49+ """Return template version"""
50
51 # take template version. Default is current Quickly version
52 template_version = quicklyconfig.__version__
53@@ -167,6 +181,13 @@
54 if targeted_property == 'TEMPLATE_VERSION':
55 template_version = value
56 break
57+
58+ return template_version
59+
60+def get_project_and_template_versions(template_name):
61+ """Return project and template version"""
62+
63+ template_version = get_template_version(template_name)
64
65 # get current project version for this template. Default is no migration (ie take current version)
66 configurationhandler.loadConfig()
67
68=== modified file 'quickly/test/quickly.sh'
69--- quickly/test/quickly.sh 2011-03-02 22:59:32 +0000
70+++ quickly/test/quickly.sh 2011-07-06 14:29:39 +0000
71@@ -50,3 +50,18 @@
72 diff -qr data/templates/ubuntu-application/store /tmp/quickly-test/quickly-templates/test-template/store
73
74 diff -qr data/templates/ubuntu-application/test /tmp/quickly-test/quickly-templates/test-template/test
75+
76+cd /tmp/quickly-test
77+
78+export HOME=/tmp/quickly-test; quickly create test-template test-project
79+# Creating bzr repository and committing
80+# Congrats, your new project is setup! cd /tmp/quickly-test/test-project/ to start hacking.
81+# Creating project directory test-project
82+
83+cd test-project
84+
85+cat .quickly | VER=$(quickly --version | head -n1 | cut -d' ' -f2-) sh -c 'sed "s/$VER/X.X.X/"'
86+# project = test-project
87+# version_ubuntu-application = X.X.X
88+# version = X.X.X
89+# template = test-template

Subscribers

People subscribed via source and target branches