Skip to content

Commit

Permalink
implement bzr support (revision number)
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Jun 20, 2011
1 parent 2cbedfa commit 674dd4a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/bzr.c
@@ -0,0 +1,33 @@
#include <string.h>
#include "common.h"
#include "bzr.h"

static int
bzr_probe(vccontext_t* context)
{
return isdir(".bzr");
}

static result_t*
bzr_get_info(vccontext_t* context)
{
result_t* result = init_result();
char buf[1024];

if (read_first_line(".bzr/branch/last-revision", buf, 1024)) {
debug("read first line from .bzr/branch/last-revision: '%s'", buf);
result->revision = strdup(buf); /* XXX mem leak */
*(strchr(result->revision, ' ')) = '\0';
}
else {
debug("failed to read from .bzr/branch/last-revision: assuming not an bzr repo");
return NULL;
}

return result;
}

vccontext_t* get_bzr_context(options_t* options)
{
return init_context("bzr", options, bzr_probe, bzr_get_info);
}
8 changes: 8 additions & 0 deletions src/bzr.h
@@ -0,0 +1,8 @@
#ifndef BZR_H
#define BZR_H

#include "common.h"

vccontext_t* get_bzr_context(options_t* options);

#endif
3 changes: 1 addition & 2 deletions src/vcprompt.c
Expand Up @@ -9,9 +9,7 @@
#include "git.h" #include "git.h"
#include "hg.h" #include "hg.h"
#include "svn.h" #include "svn.h"
/*
#include "bzr.h" #include "bzr.h"
*/


void parse_args(int argc, char** argv, options_t* options) void parse_args(int argc, char** argv, options_t* options)
{ {
Expand Down Expand Up @@ -165,6 +163,7 @@ int main(int argc, char** argv)
get_git_context(&options), get_git_context(&options),
get_hg_context(&options), get_hg_context(&options),
get_svn_context(&options), get_svn_context(&options),
get_bzr_context(&options),
}; };
int num_contexts = sizeof(contexts) / sizeof(vccontext_t*); int num_contexts = sizeof(contexts) / sizeof(vccontext_t*);


Expand Down

0 comments on commit 674dd4a

Please sign in to comment.