Make "rename" command an alias for "mv"?

Robert Widhopf-Fenk hack at robf.de
Mon Oct 24 01:20:58 BST 2005


I was wondering why there are three commands which can do
renames and if there was any special voodoo in "rename" and
"move", but beside a TODO note I can not see a need to have
them as a commands of their own instead of an alias to "mv".

While it is slow to invoke bzr for each rename it makes more
sense to me to have something more generic solving the
slowness, e.g. a "bzr command-pipe" for feeding in a set of
commands which will be processed within one run of bzr and
can be used right from the shell without writing python code.

This would improve speed of all batched bzr commands.

BTW is it save to do several commands within one bzr run,
e.g. having a plugin combining several commands into a
single one?

Some programs do not behave well here due to globals not
having their startup values anymore after running the first
command.

Robert.

=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py
+++ bzrlib/builtins.py
@@ -246,45 +246,6 @@
                 print path


-class cmd_move(Command):
-    """Move files to a different directory.
-
-    examples:
-        bzr move *.txt doc
-
-    The destination must be a versioned directory in the same branch.
-    """
-    takes_args = ['source$', 'dest']
-    def run(self, source_list, dest):
-        b = Branch.open_containing('.')[0]
-
-        # TODO: glob expansion on windows?
-        tree = WorkingTree(b.base, b)
-        b.move([tree.relpath(s) for s in source_list], tree.relpath(dest))
-
-
-class cmd_rename(Command):
-    """Change the name of an entry.
-
-    examples:
-      bzr rename frob.c frobber.c
-      bzr rename src/frob.c lib/frob.c
-
-    It is an error if the destination name exists.
-
-    See also the 'move' command, which moves files into a different
-    directory without changing their name.
-    """
-    # TODO: Some way to rename multiple files without invoking
-    # bzr for each one?"""
-    takes_args = ['from_name', 'to_name']
-
-    def run(self, from_name, to_name):
-        b = Branch.open_containing('.')[0]
-        tree = WorkingTree(b.base, b)
-        b.rename_one(tree.relpath(from_name), tree.relpath(to_name))
-
-
 class cmd_mv(Command):
     """Move or rename a file.

@@ -299,6 +260,7 @@
     Files cannot be moved between branches.
     """
     takes_args = ['names*']
+    aliases = ['rename', 'move']
     def run(self, names_list):
         if len(names_list) < 2:
             raise BzrCommandError("missing file argument")





More information about the bazaar mailing list