monotone

monotone Mtn Source Tree

Root/epoch.cc

1// Copyright (C) 2005 Nathaniel Smith <njs@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#include "base.hh"
11#include "epoch.hh"
12#include "netio.hh"
13#include "constants.hh"
14#include "transforms.hh"
15
16
17using std::string;
18
19void
20read_epoch(string const & in,
21 branch_name & branch, epoch_data & epoch)
22{
23 size_t pos = 0;
24 string raw_branch;
25 data raw_epoch;
26 extract_variable_length_string(in, raw_branch, pos, "epoch, branch name");
27 raw_epoch = data(extract_substring(in, pos, constants::epochlen_bytes,
28 "epoch, epoch data"));
29 branch = branch_name(raw_branch);
30 epoch = epoch_data(raw_epoch);
31}
32
33void
34write_epoch(branch_name const & branch, epoch_data const & epoch,
35 string & out)
36{
37 insert_variable_length_string(branch(), out);
38 out += epoch.inner()();
39}
40
41void
42epoch_hash_code(branch_name const & branch, epoch_data const & epoch,
43 epoch_id & eid)
44{
45 string tmp(branch() + ":" + encode_hexenc(epoch.inner()()));
46 data tdat(tmp);
47 id out;
48 calculate_ident(tdat, out);
49 eid = epoch_id(out);
50}
51
52// Local Variables:
53// mode: C++
54// fill-column: 76
55// c-file-style: "gnu"
56// indent-tabs-mode: nil
57// End:
58// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status