List:Commits« Previous MessageNext Message »
From:Daniel Fischer Date:June 18 2008 6:57pm
Subject:bzr commit into mysql_plugins branch (df:131)
View as plain text  
#At file:///shared/home/df/mysql/bazaar/mysql_plugins-unmerged/

  131 Daniel Fischer	2008-06-18
      Implement 'bzr unmerged', which shows revisions present in one branch and
      not in another. Similar to what bzr missing does, but also displays non-
      mainline revisions. Only supports branches that share one repository now.
added:
  unmerged.py
modified:
  __init__.py

=== modified file '__init__.py'
--- a/__init__.py	2008-06-18 13:03:09 +0000
+++ b/__init__.py	2008-06-18 16:57:10 +0000
@@ -32,12 +32,14 @@ import collapse
 import parent
 import hooks
 import sanity
+import unmerged
 """)
 
 version_info = (0, 3, 10)
 
 register_command(parent.cmd_parent)
 register_command(collapse.cmd_collapse)
+register_command(unmerged.cmd_unmerged)
 try:
   import importmbox
   register_command(importmbox.cmd_importmbox)

=== added file 'unmerged.py'
--- a/unmerged.py	1970-01-01 00:00:00 +0000
+++ b/unmerged.py	2008-06-18 16:57:10 +0000
@@ -0,0 +1,66 @@
+import sys
+from bzrlib.commands import Command
+from bzrlib.option import Option
+from bzrlib.bzrdir import BzrDir
+from bzrlib.graph import Graph
+from bzrlib.log import LogRevision, log_formatter_registry
+from bzrlib.tsort import MergeSorter
+
+class cmd_unmerged(Command):
+	""" Show list of individual revisions present in one branch, but missing in another.
+
+	"""
+
+	takes_args = [
+		'locationL?',
+		'locationR?'
+	]
+	takes_options = [
+	]
+	def run(self, locationL=None, locationR=None, log_format=None):
+		if locationR is None and locationL is not None:
+			locationR = locationL
+			locationL = '.'
+		elif locationR is None and locationL is None:
+			locationL = '.'
+			locationR = PARENT
+
+		treeL, branchL, pathL = BzrDir.open_containing_tree_or_branch(locationL)
+		treeR, branchR, pathR = BzrDir.open_containing_tree_or_branch(locationR)
+		try:
+			branchL.lock_read()
+			branchR.lock_read()
+
+			repoL = branchL.repository
+			repoR = branchR.repository
+			graphL = repoL.get_graph()
+			graphR = None
+			if repoL.has_same_location(repoR):
+				repoR = repoL
+				graphR = graphL
+			else:
+				graphR = repoR.get_graph()
+		
+			revmapL = branchL._gen_revno_map() # unfortunately, revision_id_to_revno() forgets
about revno 1...
+
+			if log_format is None:
+				log_format = log_formatter_registry.get_default(branchL)
+			lf = log_format(show_ids=True, to_file=sys.stdout, show_timezone="original")
+
+			if graphL == graphR:
+				diff = graphL.find_difference(branchL.last_revision(), branchR.last_revision())
+				revision_ids = set(diff[0])
+				r = branchL.last_revision()
+				ms = MergeSorter([(revid, [x for x in graphL.get_parent_map((revid,))[revid] if x in
revision_ids]) for revid in revision_ids], branchL.last_revision(), None, False)
+				for seqno, revid, merge_depth, end_of_merge in ms.iter_topo_order():
+					revno = '.'.join(['%d' %(x) for x in revmapL[revid]])
+					lr = LogRevision(repoL.get_revision(revid), revno, merge_depth, None, None)
+					lf.log_revision(lr)
+			else:
+				print 'bzr unmerged across repositories is not implemented yet'
+
+		finally:
+			branchL.unlock()
+			branchR.unlock()
+
+		

Thread
bzr commit into mysql_plugins branch (df:131) Daniel Fischer18 Jun