Merge lp:~henninge/launchpad/on-edge into lp:launchpad

Proposed by Henning Eggers
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~henninge/launchpad/on-edge
Merge into: lp:launchpad
Diff against target: 79 lines (+43/-8)
1 file modified
utilities/on-edge (+43/-8)
To merge this branch: bzr merge lp:~henninge/launchpad/on-edge
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+18454@code.launchpad.net

Commit message

Improved the on-edge script to display the last automatic merge on db-stable.

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Improved jml's "on-edge" script to show the last automatic merge on db-stable. Very useful if you can't wait to QA your branch on staging!

Also fixed a bug where the code was passing a string into dotted_revno_to_revision_id instead of a tuple, thus causing it to always throw an exception.

Finally, the script now also dectects when the local copy of a branch is actually older than what's on edge/staging.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Looks fine. A few nits: "res" is not a very good variable name, so use "match" instead. Double blank line above get_last_automatic_stable_merge_revno. That's about it.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utilities/on-edge'
--- utilities/on-edge 2010-02-01 23:41:00 +0000
+++ utilities/on-edge 2010-02-02 18:36:26 +0000
@@ -61,25 +61,58 @@
61 return os.path.dirname(os.path.dirname(os.path.dirname(this_file)))61 return os.path.dirname(os.path.dirname(os.path.dirname(this_file)))
6262
6363
64def print_revisions(branch, end_id):
65 """Output revision messages up to end_id."""
66 rev_iter = branch.iter_merge_sorted_revisions(
67 None, end_id, 'include')
68 for rev_info in rev_iter:
69 (rev_id, depth, revno, end_of_merge) = rev_info
70 if depth > 0:
71 continue
72 revision = branch.repository.get_revision(rev_id)
73 revno_str = ".".join(map(str, revno))
74 print "r%s:\n%s" % (revno_str, revision.message)
75
76
64def report_difference_to_server(server, branch_path, revno, verbose):77def report_difference_to_server(server, branch_path, revno, verbose):
78 """Output if and how the local branch differs from the server."""
65 branch = Branch.open(branch_path)79 branch = Branch.open(branch_path)
66 print '%s is running %s r%s' % (server, branch.nick, revno)80 print '%s is running %s r%d.' % (server, branch.nick, revno)
67 try:81 try:
68 branch.dotted_revno_to_revision_id(str(revno + 1))82 current_id = branch.dotted_revno_to_revision_id((revno,))
69 except errors.NoSuchRevision:83 except errors.NoSuchRevision:
70 print '%s is up-to-date' % (server,)84 print '%s has newer revisions than %s.' % (server, branch.nick)
71 else:85 else:
72 if verbose:86 if current_id == branch.last_revision():
73 command = 'bzr log -r%s.. %s' % (revno, branch_path)87 print '%s is up-to-date.' % (server,)
74 os.system(command)88 else:
75 print89 if verbose:
90 print_revisions(branch, current_id)
91
92
93automatic_merge_regex = re.compile(
94 "automatic merge from stable[.] "
95 "Revisions:[0-9,\s]*\s+([0-9]+)\s+included")
96
97
98def get_last_automatic_stable_merge_revno(branch_path):
99 """Find out which stable revision was last commited to db-stable."""
100 branch = Branch.open(branch_path)
101 for rev_info in branch.iter_merge_sorted_revisions():
102 (rev_id, depth, revno, end_of_merge) = rev_info
103 if depth > 0:
104 continue
105 revision = branch.repository.get_revision(rev_id)
106 match = automatic_merge_regex.search(revision.message)
107 if match is not None:
108 return match.group(1)
76109
77110
78def get_opt_parse():111def get_opt_parse():
79 parser = optparse.OptionParser(112 parser = optparse.OptionParser(
80 description="Show local revisions that aren't on beta servers.")113 description="Show local revisions that aren't on beta servers.")
81 parser.add_option(114 parser.add_option(
82 '-v', '--verbose', action='store_true', help="Show revision log")115 '-v', '--verbose', action='store_true', help="Show revision log.")
83 parser.add_option(116 parser.add_option(
84 '--edge-only', action='store_true',117 '--edge-only', action='store_true',
85 help="Only show revisions not on edge. Do not consult staging.")118 help="Only show revisions not on edge. Do not consult staging.")
@@ -103,6 +136,8 @@
103 db_stable_branch = os.path.join(parent_dir, 'db-stable')136 db_stable_branch = os.path.join(parent_dir, 'db-stable')
104 report_difference_to_server(137 report_difference_to_server(
105 'staging', db_stable_branch, staging_revision, verbose)138 'staging', db_stable_branch, staging_revision, verbose)
139 print "Last automatic merge on db-stable was stable r%s." % (
140 get_last_automatic_stable_merge_revno(db_stable_branch),)
106141
107142
108def main(argv):143def main(argv):