Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

implement bzr support (revision number)

  • Loading branch information...
commit 674dd4abc1b1a17d8c83d4d5bb8115eeb773fd52 1 parent 2cbedfa
Sergey Avseyev authored

Showing 3 changed files with 42 additions and 2 deletions. Show diff stats Hide diff stats

  1. +33 0 src/bzr.c
  2. +8 0 src/bzr.h
  3. +1 2  src/vcprompt.c
33 src/bzr.c
... ... @@ -0,0 +1,33 @@
  1 +#include <string.h>
  2 +#include "common.h"
  3 +#include "bzr.h"
  4 +
  5 +static int
  6 +bzr_probe(vccontext_t* context)
  7 +{
  8 + return isdir(".bzr");
  9 +}
  10 +
  11 +static result_t*
  12 +bzr_get_info(vccontext_t* context)
  13 +{
  14 + result_t* result = init_result();
  15 + char buf[1024];
  16 +
  17 + if (read_first_line(".bzr/branch/last-revision", buf, 1024)) {
  18 + debug("read first line from .bzr/branch/last-revision: '%s'", buf);
  19 + result->revision = strdup(buf); /* XXX mem leak */
  20 + *(strchr(result->revision, ' ')) = '\0';
  21 + }
  22 + else {
  23 + debug("failed to read from .bzr/branch/last-revision: assuming not an bzr repo");
  24 + return NULL;
  25 + }
  26 +
  27 + return result;
  28 +}
  29 +
  30 +vccontext_t* get_bzr_context(options_t* options)
  31 +{
  32 + return init_context("bzr", options, bzr_probe, bzr_get_info);
  33 +}
8 src/bzr.h
... ... @@ -0,0 +1,8 @@
  1 +#ifndef BZR_H
  2 +#define BZR_H
  3 +
  4 +#include "common.h"
  5 +
  6 +vccontext_t* get_bzr_context(options_t* options);
  7 +
  8 +#endif
3  src/vcprompt.c
@@ -9,9 +9,7 @@
9 9 #include "git.h"
10 10 #include "hg.h"
11 11 #include "svn.h"
12   -/*
13 12 #include "bzr.h"
14   -*/
15 13
16 14 void parse_args(int argc, char** argv, options_t* options)
17 15 {
@@ -165,6 +163,7 @@ int main(int argc, char** argv)
165 163 get_git_context(&options),
166 164 get_hg_context(&options),
167 165 get_svn_context(&options),
  166 + get_bzr_context(&options),
168 167 };
169 168 int num_contexts = sizeof(contexts) / sizeof(vccontext_t*);
170 169

0 comments on commit 674dd4a

Please sign in to comment.
Something went wrong with that request. Please try again.