Rev 103: Merge dpush changes. in http://people.samba.org/bzr/jelmer/bzr-git/trunk
Jelmer Vernooij
jelmer at samba.org
Fri Aug 29 16:20:46 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-git/trunk
------------------------------------------------------------
revno: 103
revision-id: jelmer at samba.org-20080829152045-vxuc7fuovh0ttlmn
parent: jelmer at samba.org-20080829150142-6kgyszl86htv9wyq
parent: jelmer at samba.org-20080829151756-e7o2t2nz4o1bgrni
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:20:45 +0200
message:
Merge dpush changes.
modified:
foreign/__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
------------------------------------------------------------
revno: 0.1.8
revision-id: jelmer at samba.org-20080829151756-e7o2t2nz4o1bgrni
parent: jelmer at samba.org-20080829151627-r3mhlflwdgtioy1c
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:17:56 +0200
message:
Remove references to svn.
modified:
__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
------------------------------------------------------------
revno: 0.1.7
revision-id: jelmer at samba.org-20080829151627-r3mhlflwdgtioy1c
parent: jelmer at samba.org-20080829150547-98hpxtt3k52vlwz8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:16:27 +0200
message:
Import dpush.
modified:
__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
------------------------------------------------------------
revno: 0.1.6
revision-id: jelmer at samba.org-20080829150547-98hpxtt3k52vlwz8
parent: jelmer at samba.org-20080829145637-f7z73y580w4ztcym
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Fri 2008-08-29 17:05:47 +0200
message:
Import FakeControlFiles.
modified:
__init__.py foreign.py-20080827193306-rxeku2c2obec90c4-1
=== modified file 'foreign/__init__.py'
--- a/foreign/__init__.py 2008-08-27 19:43:01 +0000
+++ b/foreign/__init__.py 2008-08-29 15:17:56 +0000
@@ -16,7 +16,8 @@
"""Foreign branch utilities."""
-from bzrlib import registry
+from bzrlib import errors, registry
+from bzrlib.commands import Command, Option
class VcsMapping(object):
@@ -53,3 +54,81 @@
"""Convenience function for obtaining the default mapping to use."""
return self.get(self._get_default_key())
+
+class FakeControlFiles(object):
+ """Dummy implementation of ControlFiles.
+
+ This is required as some code relies on controlfiles being
+ available."""
+ def get_utf8(self, name):
+ raise errors.NoSuchFile(name)
+
+ def get(self, name):
+ raise errors.NoSuchFile(name)
+
+ def break_lock(self):
+ pass
+
+
+class cmd_dpush(Command):
+ """Push diffs into a foreign version control system without any
+ Bazaar-specific metadata.
+
+ This will afterwards rebase the local Bazaar branch on the remote
+ branch unless the --no-rebase option is used, in which case
+ the two branches will be out of sync.
+ """
+ takes_args = ['location?']
+ takes_options = ['remember', Option('directory',
+ help='Branch to push from, '
+ 'rather than the one containing the working directory.',
+ short_name='d',
+ type=unicode,
+ ),
+ Option('no-rebase', help="Don't rebase after push")]
+
+ def run(self, location=None, remember=False, directory=None,
+ no_rebase=False):
+ from bzrlib import urlutils
+ from bzrlib.bzrdir import BzrDir
+ from bzrlib.branch import Branch
+ from bzrlib.errors import BzrCommandError, NoWorkingTree
+ from bzrlib.workingtree import WorkingTree
+
+ if directory is None:
+ directory = "."
+ try:
+ source_wt = WorkingTree.open_containing(directory)[0]
+ source_branch = source_wt.branch
+ except NoWorkingTree:
+ source_branch = Branch.open_containing(directory)[0]
+ source_wt = None
+ stored_loc = source_branch.get_push_location()
+ if location is None:
+ if stored_loc is None:
+ raise BzrCommandError("No push location known or specified.")
+ else:
+ display_url = urlutils.unescape_for_display(stored_loc,
+ self.outf.encoding)
+ self.outf.write("Using saved location: %s\n" % display_url)
+ location = stored_loc
+
+ bzrdir = BzrDir.open(location)
+ target_branch = bzrdir.open_branch()
+ target_branch.lock_write()
+ revid_map = source_branch.dpush(target_branch)
+ # We successfully created the target, remember it
+ if source_branch.get_push_location() is None or remember:
+ source_branch.set_push_location(target_branch.base)
+ if not no_rebase:
+ _, old_last_revid = source_branch.last_revision_info()
+ new_last_revid = revid_map[old_last_revid]
+ if source_wt is not None:
+ source_wt.pull(target_branch, overwrite=True,
+ stop_revision=new_last_revid)
+ else:
+ source_branch.pull(target_branch, overwrite=True,
+ stop_revision=new_last_revid)
+
+
+
More information about the bazaar-commits
mailing list