1294 |
14 Nov 10 |
peter |
// $Id$ |
1294 |
14 Nov 10 |
peter |
2 |
|
1294 |
14 Nov 10 |
peter |
3 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2010 Peter Johansson |
1294 |
14 Nov 10 |
peter |
5 |
|
1294 |
14 Nov 10 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
1294 |
14 Nov 10 |
peter |
7 |
|
1294 |
14 Nov 10 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
1294 |
14 Nov 10 |
peter |
under the terms of the GNU General Public License as published by |
1294 |
14 Nov 10 |
peter |
the Free Software Foundation; either version 3 of the License, or |
1294 |
14 Nov 10 |
peter |
(at your option) any later version. |
1294 |
14 Nov 10 |
peter |
12 |
|
1294 |
14 Nov 10 |
peter |
svndigest is distributed in the hope that it will be useful, but |
1294 |
14 Nov 10 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1294 |
14 Nov 10 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1294 |
14 Nov 10 |
peter |
General Public License for more details. |
1294 |
14 Nov 10 |
peter |
17 |
|
1294 |
14 Nov 10 |
peter |
You should have received a copy of the GNU General Public License |
1294 |
14 Nov 10 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
1294 |
14 Nov 10 |
peter |
20 |
*/ |
1294 |
14 Nov 10 |
peter |
21 |
|
1294 |
14 Nov 10 |
peter |
22 |
#include <config.h> // this header file is created by configure |
1294 |
14 Nov 10 |
peter |
23 |
|
1294 |
14 Nov 10 |
peter |
24 |
#include "svndigest_copy_cacheParameter.h" |
1294 |
14 Nov 10 |
peter |
25 |
|
1294 |
14 Nov 10 |
peter |
26 |
#include "lib/utility.h" |
1294 |
14 Nov 10 |
peter |
27 |
|
1294 |
14 Nov 10 |
peter |
28 |
#include <string> |
1294 |
14 Nov 10 |
peter |
29 |
|
1294 |
14 Nov 10 |
peter |
30 |
namespace theplu { |
1294 |
14 Nov 10 |
peter |
31 |
namespace svndigest { |
1294 |
14 Nov 10 |
peter |
32 |
|
1294 |
14 Nov 10 |
peter |
33 |
svndigest_copy_cacheParameter::svndigest_copy_cacheParameter(void) |
1513 |
23 Sep 12 |
peter |
34 |
: AbstractParameter(), |
1294 |
14 Nov 10 |
peter |
35 |
target_(cmd_, "t,target", "svn wc cache is copied to") |
1294 |
14 Nov 10 |
peter |
36 |
{ |
1294 |
14 Nov 10 |
peter |
37 |
} |
1294 |
14 Nov 10 |
peter |
38 |
|
1294 |
14 Nov 10 |
peter |
39 |
|
1294 |
14 Nov 10 |
peter |
40 |
svndigest_copy_cacheParameter::~svndigest_copy_cacheParameter(void) |
1294 |
14 Nov 10 |
peter |
41 |
{ |
1294 |
14 Nov 10 |
peter |
42 |
} |
1294 |
14 Nov 10 |
peter |
43 |
|
1294 |
14 Nov 10 |
peter |
44 |
|
1294 |
14 Nov 10 |
peter |
45 |
void svndigest_copy_cacheParameter::analyse1(void) |
1294 |
14 Nov 10 |
peter |
46 |
{ |
1294 |
14 Nov 10 |
peter |
47 |
analyse_root(root_.value()); |
1513 |
23 Sep 12 |
peter |
// check target |
1294 |
14 Nov 10 |
peter |
49 |
check_existence(target_.value()); |
1294 |
14 Nov 10 |
peter |
50 |
check_readable(target_.value()); |
1294 |
14 Nov 10 |
peter |
51 |
check_is_dir(target_.value()); |
1294 |
14 Nov 10 |
peter |
52 |
std::string save_wd = pwd(); |
1294 |
14 Nov 10 |
peter |
53 |
chdir(target_.value()); |
1294 |
14 Nov 10 |
peter |
54 |
target_.value(pwd()); |
1294 |
14 Nov 10 |
peter |
55 |
chdir(save_wd); |
1294 |
14 Nov 10 |
peter |
// FIXME: should check inodeno to handle symlinks |
1294 |
14 Nov 10 |
peter |
57 |
if (root()==target()) { |
1294 |
14 Nov 10 |
peter |
58 |
std::stringstream ss; |
1513 |
23 Sep 12 |
peter |
59 |
ss << cmd_.program_name() << ": '" << root() << "' and '" |
1294 |
14 Nov 10 |
peter |
60 |
<< target() << "' are identical (no copy)\n"; |
1294 |
14 Nov 10 |
peter |
61 |
throw yat::utility::cmd_error(ss.str()); |
1294 |
14 Nov 10 |
peter |
62 |
} |
1294 |
14 Nov 10 |
peter |
63 |
} |
1294 |
14 Nov 10 |
peter |
64 |
|
1294 |
14 Nov 10 |
peter |
65 |
|
1294 |
14 Nov 10 |
peter |
66 |
void svndigest_copy_cacheParameter::init1(void) |
1294 |
14 Nov 10 |
peter |
67 |
{ |
1294 |
14 Nov 10 |
peter |
68 |
target_.print_arg("=TARGET"); |
1294 |
14 Nov 10 |
peter |
69 |
root_.description("svn wc cache is copied from"); |
1513 |
23 Sep 12 |
peter |
70 |
help_.synopsis() = |
1294 |
14 Nov 10 |
peter |
71 |
"Copy svndigest cache from one working copy to another.\n"; |
1294 |
14 Nov 10 |
peter |
72 |
version_.program_name("svndigest-copy-cache"); |
1294 |
14 Nov 10 |
peter |
73 |
} |
1294 |
14 Nov 10 |
peter |
74 |
|
1294 |
14 Nov 10 |
peter |
75 |
|
1294 |
14 Nov 10 |
peter |
76 |
void svndigest_copy_cacheParameter::set_default1(void) |
1294 |
14 Nov 10 |
peter |
77 |
{ |
1294 |
14 Nov 10 |
peter |
78 |
if (!target_.present()) |
1294 |
14 Nov 10 |
peter |
79 |
target_.value("."); |
1294 |
14 Nov 10 |
peter |
80 |
} |
1294 |
14 Nov 10 |
peter |
81 |
|
1294 |
14 Nov 10 |
peter |
82 |
std::string svndigest_copy_cacheParameter::target(void) const |
1294 |
14 Nov 10 |
peter |
83 |
{ |
1294 |
14 Nov 10 |
peter |
84 |
return target_.value(); |
1294 |
14 Nov 10 |
peter |
85 |
} |
1294 |
14 Nov 10 |
peter |
86 |
|
1294 |
14 Nov 10 |
peter |
87 |
}} // of namespace svndigest and namespace theplu |