Permalink
Browse files

implement bzr support (revision number)

  • Loading branch information...
1 parent 2cbedfa commit 674dd4abc1b1a17d8c83d4d5bb8115eeb773fd52 @avsej committed Jun 20, 2011
Showing with 42 additions and 2 deletions.
  1. +33 −0 src/bzr.c
  2. +8 −0 src/bzr.h
  3. +1 −2 src/vcprompt.c
View
@@ -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);
+}
View
@@ -0,0 +1,8 @@
+#ifndef BZR_H
+#define BZR_H
+
+#include "common.h"
+
+vccontext_t* get_bzr_context(options_t* options);
+
+#endif
View
@@ -9,9 +9,7 @@
#include "git.h"
#include "hg.h"
#include "svn.h"
-/*
#include "bzr.h"
-*/
void parse_args(int argc, char** argv, options_t* options)
{
@@ -165,6 +163,7 @@ int main(int argc, char** argv)
get_git_context(&options),
get_hg_context(&options),
get_svn_context(&options),
+ get_bzr_context(&options),
};
int num_contexts = sizeof(contexts) / sizeof(vccontext_t*);

0 comments on commit 674dd4a

Please sign in to comment.