How to work with local copy of the project

Using project-command

Date: 2009/11/26
Version: 0.5 (dev)

Contents

About

There is planned set of dedicated commands to work with local checkout of the project, but many commands is not implemented yet. But scmproj plugin already provides generic engine to run standard bzr commands for components in the checkout. This document aims to provide useful hints how-to emulate lacking commands with project-command.

Local copy of the project

Every component branch is usual bzr branch, so project-command iterate over components, cd to component directory (optionally) and execute command(s) there.

Using templates to specify commands to execute with project-command

To run command for every component there should be the way to specify paths and URLs suitable for processed component branch. To achieve this simple templating approach is used. There is set of predefined variables you can use while constructing command. These variables provides values depend on currently processed component branch. You can refer to these variables using {name} syntax. Most of the variables names equals to the project.cfg variables.

Most often used template variables:

Also there is 3 user-defined template variables (var1, var2, var3) which can be useful with commands aliases. E.g specifiyng following alias:

bzr alias pmiss="pcmd 'missing --line {var1}/{RELPATH}'"

You can run pmiss to compare current local project with other local project:

bzr pmiss --var1=/path/to/other/local/project

See full list of available template variables.

(NOTE: Values of branch-related variables are always for specified alt in the command line. If there is no alt specified then current alt will be used.)

Get local project copy

Some operations you can do with dedicated command. Others you can do with project-command (alias is pcmd). Currently all project-wide commands should be running from the project root directory. This will be changed in the future to provide more convenient user interface.

NOTE: by default project-command will try to change current directory to component subdirectory and execute commands there. This is suitable for many commands working with checkouts. If you want to run commands from the project root (or from another directory using helper chdir command) then you should supply option --no-cd to project-command.

Get the project copy

Builtin command: bzr project-get PROJECT_URL

Working with the local project copy

Some operations you can do with dedicated command. Others you can do with project-command (alias is pcmd). Currently all project-wide commands should be running from the project root directory. This will be changed in the future to provide more convenient user interface.

This section shows examples how to execute commands project-wide, i.e. for components available in current project subset. Of course, you can run individual bzr commands for every component separately.

NOTE: by default project-command will try to change current directory to component subdirectory and execute commands there. This is suitable for many commands working with checkouts. If you want to run commands from the project root (or from another directory using helper chdir command) then you should supply option --no-cd to project-command.

Inspect changes in working copies

  • bzr status: bzr pcmd status
  • bzr diff: bzr pcmd diff

Unversion all newly added files

bzr pcmd "rm --new --keep"

Revert changes

  • Revert changes and forget merges: bzr pcmd revert
  • Revert changes but keep pending merges: bzr pcmd "revert ."
  • Keep changes but forget merges: bzr pcmd "revert --forget-merges"

Commit changes

Builtin command: bzr project-commit

Also you can emulate it with bzr pcmd ci, but we strongly recommended to use builtin command because it better handles situation when some components have changed and others are not. Once snapshot support will be implemented builtin command will allow user to commit new snapshots as well as components changes.

Some tips for emulated version:

In most cases you may want to provide one commit message for all components, please be careful with quotes inside quotes:

bzr pcmd "ci -m \"My commit message\" "``

Much simpler to save commit message to file first:

bzr pcmd "ci -F file.txt"

Very often you'll need to commit project where only some of components have changed. First component without changes will break operation. To continue operation anyway you'll need to use --ignore-errors option of pcmd command.

Tag committed revision

bzr pcmd "tag XXX"

Push changes back to server

Builtin command: bzr project-publish (aliases: pback, ppush)

Pull new changes from server

Builtin command: bzr project-update (aliases: pup, pupdate)

Update working copies

bzr pcmd update

Merge changes from other alt branches

  • Other branches are on the server: bzr pcmd --alt=OTHER "merge {BRANCH_URL}"
  • Other branches are available locally: bzr pcmd --alt=OTHER "merge {LOCAL_BRANCH}"

See notes about BRANCH_URL and LOCAL_BRANCH from previos section.

Auto-resolve conflicts

bzr pcmd resolve