Merge lp:~statik/config-manager/specific-revisions into lp:config-manager

Proposed by Elliot Murphy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~statik/config-manager/specific-revisions
Merge into: lp:config-manager
Diff against target: None lines
To merge this branch: bzr merge lp:~statik/config-manager/specific-revisions
Reviewer Review Type Date Requested Status
Tom Haddon Pending
Robert Collins Pending
Review via email: mp+7702@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Elliot Murphy (statik) wrote :

This implements basic support for building configs that pull specific revisions of bzr branches. I've tested with a config file like so:

#Sample config file
./cm1 bzr+ssh://bazaar.launchpad.net/~lifeless/config-manager/trunk
./cm2 bzr+ssh://bazaar.launchpad.net/~lifeless/config-manager/trunk;revno=40

In order to be able to test, I had to temporarily short-circuit pybaz imports, I could not figure out where to get pybaz from. I have not committed those changes, but am mentioning it as a note to anyone trying to review this branch.

No support was added for updating a set of source trees when the branches specify particular versions, but I did provide enough code that update won't be broken when parsing a config that specifies a revno, it will just ignore the revno.

I also changed what seemed to be a typo in the imports. With this set of changes, and the sample config file I mentioned earlier, I was able to successfully run ./cm.py build config.txt, and see that the branches were built as expected with the expected revisions.

Revision history for this message
Tom Haddon (mthaddon) wrote :

> This implements basic support for building configs that pull specific
> revisions of bzr branches. I've tested with a config file like so:
>
> #Sample config file
> ./cm1 bzr+ssh://bazaar.launchpad.net/~lifeless/config-manager/trunk
> ./cm2 bzr+ssh://bazaar.launchpad.net/~lifeless/config-
> manager/trunk;revno=40
>
> In order to be able to test, I had to temporarily short-circuit pybaz imports,
> I could not figure out where to get pybaz from. I have not committed those
> changes, but am mentioning it as a note to anyone trying to review this
> branch.
>
> No support was added for updating a set of source trees when the branches
> specify particular versions, but I did provide enough code that update won't
> be broken when parsing a config that specifies a revno, it will just ignore
> the revno.

I got the following errors when testing:

http://pastebin.ubuntu.com/199767/

Basically was able to confirm the "build" part works okay, but changing the revno in the sample config file and then running "update" caused problems.

>
> I also changed what seemed to be a typo in the imports. With this set of
> changes, and the sample config file I mentioned earlier, I was able to
> successfully run ./cm.py build config.txt, and see that the branches were
> built as expected with the expected revisions.

Revision history for this message
Robert Collins (lifeless) wrote :

On Sat, 2009-06-20 at 03:45 +0000, Elliot Murphy wrote:
>
> + else:
> + revision_id = br_from.last_revision()

here, revision_id=None would be correct and avoid lookups outside of
locks.

Otherwise good, I'll merge Monday.

-Rob

Revision history for this message
Elliot Murphy (statik) wrote :

Hi Tom, thanks for testing and reviewing. I'm pasting the patch that I apply locally to disable pybaz, and when I use this patch, update at least 'does no harm'. I believe the error you are seeing on update is an existing problem with the pybaz code.

I've also revised the patch so update now partially supports revno. If you specify a revno, then build a set of trees, then advance the revno on one of the trees, update will update that tree only to the given revno. However, if you move the revno backward on one of the trees, update will not currently revert the tree back to the older revision.

Revision history for this message
Elliot Murphy (statik) wrote :

=== modified file 'lib/config_manager/__init__.py'
--- lib/config_manager/__init__.py 2009-06-20 03:38:27 +0000
+++ lib/config_manager/__init__.py 2009-06-20 16:02:24 +0000
@@ -29,7 +29,7 @@
 import config_manager.implementations
 #TODO import implementations dynamically.
 import config_manager.implementations.fake_vcs
-import config_manager.implementations.arch_vcs
+#import config_manager.implementations.arch_vcs
 fake_updates = []

 class UnsupportedScheme(KeyError):
@@ -135,6 +135,7 @@
         os.system("svn checkout %s %s" % (url, os.path.normpath(os.path.join(path, self.path))))

     def _build_pybaz_name(self, path):
+ return False
         import pybaz
         try:
             # try as registered name
@@ -146,6 +147,7 @@
             return False

     def _build_pybaz_url(self, path):
+ return None
         import pybaz
         try:
             lastslash = self.url.rfind('/')
@@ -265,6 +267,7 @@
                 raise ValueError("unknown url type '%s'" % self.url)

     def _update_pybaz(self, path):
+ return False
         import pybaz
         try:
             tree = pybaz.WorkingTree(os.path.join(path, self.path))

Revision history for this message
Elliot Murphy (statik) wrote :

Thanks for the review! I've made the change you asked for, and added partial support for updating trees to a newer revision. It doesn't yet handle the case where a tree is at revision 50, and you update the config to drop it back to an older revision yet. I've pushed rev 161 which should be ready to merge.

161. By Elliot Murphy

Changes from code review, and added partial support for revno in update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/config_manager/__init__.py'
--- lib/config_manager/__init__.py 2006-03-16 12:13:06 +0000
+++ lib/config_manager/__init__.py 2009-06-20 03:38:27 +0000
@@ -160,13 +160,18 @@
160 def _build_bzr_url(self, path):160 def _build_bzr_url(self, path):
161 try:161 try:
162 import errno162 import errno
163 from bzrlib.branch import (Branch,163 from bzrlib.branch import Branch
164 DivergedBranches,164 from bzrlib.revisionspec import RevisionSpec
165 from bzrlib.errors import (DivergedBranches,
165 NotBranchError,166 NotBranchError,
166 NoSuchRevision)167 NoSuchRevision)
167 168
168 revision = [None]169 components = self.url.split(';revno=')
169 from_location = self.url170 from_location = components[0]
171 if len(components) == 2:
172 revision = RevisionSpec.from_string(components[1])
173 else:
174 revision = None
170 to_location = os.path.join(path, self.path)175 to_location = os.path.join(path, self.path)
171176
172 #if from_location.startswith("file://"):177 #if from_location.startswith("file://"):
@@ -178,10 +183,14 @@
178 except NotBranchError:183 except NotBranchError:
179 return False184 return False
180185
186 if revision is not None:
187 revision_id = revision.as_revision_id(br_from)
188 else:
189 revision_id = br_from.last_revision()
181 os.mkdir(to_location)190 os.mkdir(to_location)
182 to_dir = br_from.bzrdir.sprout(to_location)191 to_dir = br_from.bzrdir.sprout(to_location, revision_id)
183 # remove any local modifications192 # remove any local modifications
184 to_dir.open_workingtree().revert([])193 to_dir.open_workingtree().revert()
185 return True194 return True
186 except Exception, e:195 except Exception, e:
187 print "%r" % e, e196 print "%r" % e, e
@@ -205,7 +214,13 @@
205 dir_to = BzrDir.open(path)214 dir_to = BzrDir.open(path)
206 except NotBranchError:215 except NotBranchError:
207 return False216 return False
208 br_from = Branch.open(self.url)217 components = self.url.split(';revno=')
218 url = components[0]
219 if len(components) == 2:
220 revno = components[1]
221 else:
222 revno = None
223 br_from = Branch.open(url)
209 try:224 try:
210 dir_to.open_workingtree().pull(br_from)225 dir_to.open_workingtree().pull(br_from)
211 return True226 return True

Subscribers

People subscribed via source and target branches