Cheaper branching under consideration?

James Blackwell jblack at merconline.com
Mon Sep 5 13:14:46 BST 2005


Does anybody know what happened to this?


On Sat, Aug 27, 2005 at 07:33:55AM +0100, Magnus Therning wrote:
> 
> Yes it will fulfill my needs.
> 
> However, until it's implemented I've cooked together a small plugin that
> does a "shallow branch", a branch with only the last revision. Bzr seems
> to work just fine, even though the revno is decreased to 1.
> 
> My idea was to use it to make micro-branching cheaper. (Also I wanted to
> play with bzr :-)
> 
> /M
> 
> *** added file '.bzrignore'
> --- /dev/null 
> +++ .bzrignore 
> @@ -0,0 +1,1 @@
> +*.pyc
> 
> *** added file '__init__.py'
> --- /dev/null 
> +++ __init__.py 
> @@ -0,0 +1,9 @@
> +import bzrlib.commands
> +
> +import shallow_branch
> +
> +_commands = [shallow_branch.cmd_shallow_branch]
> +
> +if hasattr(bzrlib.commands, 'register_command'):
> +    for cmd in _commands:
> +        bzrlib.commands.register_command(cmd)
> 
> *** added file 'shallow_branch.py'
> --- /dev/null 
> +++ shallow_branch.py 
> @@ -0,0 +1,47 @@
> +from bzrlib.commands import Command
> +
> +class cmd_shallow_branch(Command):
> +    '''Make a shallow branch.
> +
> +    A shallow branch is a branch without any history.
> +
> +    If TO_LOCATION is omitted, the last component of FROM_LOCATION will be
> +    used. In other words, "shallow-branch ../foo/bar" will attempt to create
> +    "./bar".
> +
> +    To retrieve a shallow branch of a particular revision, supply the
> +    --revision parameter, as in "shallow-branch foo/bar --revision 5".
> +    '''
> +
> +    takes_args = ['from_location', 'to_location?']
> +    takes_options = ['revision']
> +
> +    def run(self, from_location, to_location=None, revision=[-1]):
> +        import os
> +        from bzrlib.branch import Branch
> +        from bzrlib.merge import merge
> +
> +        if to_location == None:
> +            to_location = os.path.basename(from_location.rstrip("/\\"))
> +
> +        try:
> +            os.mkdir(to_location)
> +        except OSError, e:
> +            if e.errno == errno.EEXIST:
> +                raise BzrCommandError('Target directory "%s" already'
> +                        ' exists.' % to_location)
> +            elif e.errno == errno.ENOENT:
> +                raise BzrCommandError('Parent of "%s" does not exist.'
> +                        % to_location)
> +            else:
> +                raise
> +
> +        br_to = Branch(to_location, init=True)
> +        br_from = Branch(from_location)
> +
> +        revno, rev_id = br_from.get_revision_info(revision[0])
> +        br_to.install_revisions(br_from, [rev_id], None)
> +        br_to.append_revision(rev_id)
> +
> +        merge((to_location, -1), (to_location, None),
> +                this_dir=to_location, check_clean=False)
> 
> 
> -- 
> Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
> magnus at therning.org
> http://therning.org/magnus
> 
> Software is not manufactured, it is something you write and publish.
> Keep Europe free from software patents, we do not want censorship
> by patent law on written works.
> 
> I should be able to whisper something in your ear, even if your ear is
> 1000 miles away, and the government disagrees with that. GQ [magazine
> in England] quoted me on that -- they changed one letter. It said I
> should be able to whisper something in your *car*, even though I am
> 1000 miles away. I wonder what the people in England think of me.
>       -- Philip Zimmermann



-- 
 James Blackwell      |   Life is made of the stuff that hasn't killed
 Tell someone a joke! |   you yet.                       - yours truly
----------------------------------------------------------------------
GnuPG (ID 06357400) AAE4 8C76 58DA 5902 761D  247A 8A55 DA73 0635 7400




More information about the bazaar mailing list