~ubuntu-branches/debian/stretch/gource/stretch

« back to all changes in this revision

Viewing changes to src/formats/bzr.cpp

  • Committer: Package Import Robot
  • Author(s): Andrew Caudwell
  • Date: 2014-04-15 16:30:17 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20140415163017-ucdr2josj1spzrga
Tags: 0.41-1
* New upstream release
* Made VCS URIs canonical
* Changed watch file to look at Github for releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
*/
17
17
 
18
18
#include "bzr.h"
 
19
#include "../gource_settings.h"
 
20
 
 
21
#include <boost/format.hpp>
19
22
 
20
23
Regex bzr_commit_regex("^ *([\\d.]+) (.+)\t(\\d{4})-(\\d+)-(\\d+)(?: \\{[^}]+})?(?: \\[merge\\])?$");
21
24
Regex bzr_file_regex("^ *([AMDR])  (.*[^/])$");
22
25
 
23
26
// parse Bazaar log entries (using the gource.style template)
24
27
 
25
 
std::string gGourceBzrLogCommand() {
26
 
    return std::string("bzr log --verbose -r 1..-1 --short -n0 --forward");
 
28
std::string BazaarLog::logCommand() {
 
29
 
 
30
    std::string start = (!gGourceSettings.start_date.empty()) ? gGourceSettings.start_date : "1";
 
31
    std::string stop  = (!gGourceSettings.stop_date.empty())  ? gGourceSettings.stop_date  : "-1";
 
32
 
 
33
    std::string range = str(boost::format("date:%s..%s") % start % stop);
 
34
 
 
35
    std::string log_command = str(boost::format("bzr log --verbose -r %s --short -n0 --forward") % range);
 
36
 
 
37
    return log_command;
27
38
}
28
39
 
29
40
BazaarLog::BazaarLog(const std::string& logfile) : RCommitLog(logfile) {
30
41
 
31
 
    log_command = gGourceBzrLogCommand();
 
42
    log_command = logCommand();
32
43
 
33
44
    //can generate log from directory
34
45
    if(!logf && is_dir) {
61
72
    if(temp_file.size()==0) return 0;
62
73
 
63
74
    char cmd_buff[2048];
64
 
    sprintf(cmd_buff, "%s %s > %s", command.c_str(), dir.c_str(), temp_file.c_str());
 
75
    snprintf(cmd_buff, 2048, "%s %s > %s", command.c_str(), dir.c_str(), temp_file.c_str());
65
76
 
66
77
    int command_rc = systemCommand(cmd_buff);
67
78
 
82
93
 
83
94
    if(!logf->getNextLine(line)) return false;
84
95
 
85
 
    debugLog("read %s\n", line.c_str());
86
96
    if (!bzr_commit_regex.match(line, &entries)) {
87
 
        debugLog("regex failed\n");
 
97
        //debugLog("regex failed\n");
88
98
        return false;
89
99
    }
 
100
 
90
101
    commit.username = entries[1];
91
102
 
92
103
    year  = atoi(entries[2].c_str());