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
1=== modified file 'lib/config_manager/__init__.py'
2--- lib/config_manager/__init__.py 2006-03-16 12:13:06 +0000
3+++ lib/config_manager/__init__.py 2009-06-20 03:38:27 +0000
4@@ -160,13 +160,18 @@
5 def _build_bzr_url(self, path):
6 try:
7 import errno
8- from bzrlib.branch import (Branch,
9- DivergedBranches,
10+ from bzrlib.branch import Branch
11+ from bzrlib.revisionspec import RevisionSpec
12+ from bzrlib.errors import (DivergedBranches,
13 NotBranchError,
14 NoSuchRevision)
15-
16- revision = [None]
17- from_location = self.url
18+
19+ components = self.url.split(';revno=')
20+ from_location = components[0]
21+ if len(components) == 2:
22+ revision = RevisionSpec.from_string(components[1])
23+ else:
24+ revision = None
25 to_location = os.path.join(path, self.path)
26
27 #if from_location.startswith("file://"):
28@@ -178,10 +183,14 @@
29 except NotBranchError:
30 return False
31
32+ if revision is not None:
33+ revision_id = revision.as_revision_id(br_from)
34+ else:
35+ revision_id = br_from.last_revision()
36 os.mkdir(to_location)
37- to_dir = br_from.bzrdir.sprout(to_location)
38+ to_dir = br_from.bzrdir.sprout(to_location, revision_id)
39 # remove any local modifications
40- to_dir.open_workingtree().revert([])
41+ to_dir.open_workingtree().revert()
42 return True
43 except Exception, e:
44 print "%r" % e, e
45@@ -205,7 +214,13 @@
46 dir_to = BzrDir.open(path)
47 except NotBranchError:
48 return False
49- br_from = Branch.open(self.url)
50+ components = self.url.split(';revno=')
51+ url = components[0]
52+ if len(components) == 2:
53+ revno = components[1]
54+ else:
55+ revno = None
56+ br_from = Branch.open(url)
57 try:
58 dir_to.open_workingtree().pull(br_from)
59 return True

Subscribers

People subscribed via source and target branches