mercurial tasks extension March 9, 2009
Mercurial bookmarks offer a way to work on separate short-lived tasks in the same repo without having to create a separate clone.
For me bookmarks lack two features: tracking all changesets belonging to a particular task, and being able to push completed tasks easily while ensuring that incomplete tasks are not pushed.
I decided to try to extend the bookmarks extension into something different. I call it ‘tasks’ and use it as my todo list. It’s amateur python/hg and I would love some help/feedback on it. You can see it here: http://bitbucket.org/alu/hgtasks
Below is a similar workflow to my other post about bookmarks, except it allows me to safely push changes from one completed task while keeping my incomplete task local.
You might start off your day by looking at issues in your project tracker and creating a todo list of what issues you want to tackle. Instead of writing them on a post-it, let’s use tasks:
$ hg task issue11 $ hg task issue12 $ hg tasks issue11 >2:b8df77fa20d7 issue12 >2:b8df77fa20d7
You’ll notice none of them appear “active” even though they point to the current changeset which matches our working copy.
Let’s start hacking on issue11:
$ hg up issue11 0 files updated, 0 files merged, 0 files removed, 0 files unresolved current task: issue11 $ hg tasks * issue11 >2:b8df77fa20d7 issue12 >2:b8df77fa20d7
Now that issue11 is marked as current, future commits will be applied to this task:
*hack* *hack* $ hg ci -m"fixing issue11" *hack* *hack* $ hg ci -m"still fixing 11" $ hg tasks * issue11 4:6c8236430e56 (2 csets) issue12 >2:b8df77fa20d7 $ hg task issue11 --info task: issue11 parent: 2:2ed12f44801b state: active changesets (2): 4:31f77916d497 3:9ab60daf8b43
We see that we have two changesets assigned to this task. Our work on issue11 is still not finished, but issue12 has just been bumped up to high priority and we want to work on it right away leaving issue11 half done.
$ hg up -C issue12 1 files updated, 0 files merged, 0 files removed, 0 files unresolved current task: issue12 *hack* *hack* $ hg ci -m"fixing issue12" created new head *hack* *hack* $ hg ci -m"done fixing 12" $ hg tasks issue11 4:6c8236430e56 (2 csets) * issue12 6:8672b6e96787 (2 csets)
Let’s mark issue12 as complete:
$ hg task issue12 -c $ hg tasks issue11 4:6c8236430e56 (2 csets) $ hg tasks --all issue11 4:6c8236430e56 (2 csets) issue12 6:8672b6e96787 (2 csets - complete)
By default, the task list will only include incomplete tasks unless we use the –all option.
We want to push this fix right away as it is high priority:
$ hg push pushing to /some/other/repo abort: pushing incomplete tasks (use --all-tasks to force or --completed-tasks to prune) $ hg push --completed-tasks pushing to /some/other/repo searching for completed tasks searching for changes adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files
Notice that push will warn you that incomplete tasks would be pushed (this is even before the standard warning of creating additional heads on the remote repo). So we can choose to use –all-tasks option to push everything (at which point we would be told to use –force if we really want to create new heads) or we can do what makes more sense, only push completed tasks with the –completed-tasks option. Now we can go back to working on issue11:
$ hg up -C issue11 0 files updated, 0 files merged, 0 files removed, 0 files unresolved current task: issue11 *hack* *hack* $ hg ci -m"done fixing 11" $ hg task -c issue11
Merge in changes from issue12:
$ hg merge issue12 merging file 0 files updated, 1 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg ci -m"merge"
We can leave completed tasks around but if you have no reason to keep them around, might as well delete them:
$ hg task -d issue11 $ hg task -d issue12
To see more features of this extension and details on how it was implemented, check out: http://bitbucket.org/alu/hgtasks.