PageRenderTime 72ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/skola/Fel_bc/subversion-1.6.1/subversion/libsvn_subr/log.c

https://github.com/wox2/migrace_databaze
C | 377 lines | 316 code | 44 blank | 17 comment | 34 complexity | 1fe94e490d299b877513bbece28535a8 MD5 | raw file
  1. /*
  2. * log.c : Functions for logging Subversion operations
  3. *
  4. * ====================================================================
  5. * Copyright (c) 2008 CollabNet. All rights reserved.
  6. *
  7. * This software is licensed as described in the file COPYING, which
  8. * you should have received as part of this distribution. The terms
  9. * are also available at http://subversion.tigris.org/license-1.html.
  10. * If newer versions of this license are posted there, you may use a
  11. * newer version instead, at your option.
  12. *
  13. * This software consists of voluntary contributions made by many
  14. * individuals. For exact contribution history, see the revision
  15. * history and logs, available at http://subversion.tigris.org/.
  16. * ====================================================================
  17. */
  18. #include <stdarg.h>
  19. #define APR_WANT_STRFUNC
  20. #include <apr_want.h>
  21. #include <apr_strings.h>
  22. #include "svn_types.h"
  23. #include "svn_error.h"
  24. #include "svn_mergeinfo.h"
  25. #include "svn_path.h"
  26. #include "svn_pools.h"
  27. #include "svn_string.h"
  28. #include "private/svn_log.h"
  29. static const char *
  30. log_depth(svn_depth_t depth, apr_pool_t *pool)
  31. {
  32. if (depth == svn_depth_unknown)
  33. return "";
  34. return apr_pstrcat(pool, " depth=", svn_depth_to_word(depth), NULL);
  35. }
  36. static const char *
  37. log_include_merged_revisions(svn_boolean_t include_merged_revisions)
  38. {
  39. if (include_merged_revisions)
  40. return " include-merged-revisions";
  41. return "";
  42. }
  43. const char *
  44. svn_log__reparent(const char *path, apr_pool_t *pool)
  45. {
  46. return apr_psprintf(pool, "reparent %s", svn_path_uri_encode(path, pool));
  47. }
  48. const char *
  49. svn_log__change_rev_prop(svn_revnum_t rev, const char *name, apr_pool_t *pool)
  50. {
  51. return apr_psprintf(pool, "change-rev-prop r%ld %s", rev,
  52. svn_path_uri_encode(name, pool));
  53. }
  54. const char *
  55. svn_log__rev_proplist(svn_revnum_t rev, apr_pool_t *pool)
  56. {
  57. return apr_psprintf(pool, "rev-proplist r%ld", rev);
  58. }
  59. const char *
  60. svn_log__rev_prop(svn_revnum_t rev, const char *name, apr_pool_t *pool)
  61. {
  62. return apr_psprintf(pool, "rev-prop r%ld %s", rev,
  63. svn_path_uri_encode(name, pool));
  64. }
  65. const char *
  66. svn_log__commit(svn_revnum_t rev, apr_pool_t *pool)
  67. {
  68. return apr_psprintf(pool, "commit r%ld", rev);
  69. }
  70. const char *
  71. svn_log__get_file(const char *path, svn_revnum_t rev,
  72. svn_boolean_t want_contents, svn_boolean_t want_props,
  73. apr_pool_t *pool)
  74. {
  75. return apr_psprintf(pool, "get-file %s r%ld%s%s",
  76. svn_path_uri_encode(path, pool), rev,
  77. want_contents ? " text" : "",
  78. want_props ? " props" : "");
  79. }
  80. const char *
  81. svn_log__get_dir(const char *path, svn_revnum_t rev,
  82. svn_boolean_t want_contents, svn_boolean_t want_props,
  83. apr_uint64_t dirent_fields,
  84. apr_pool_t *pool)
  85. {
  86. return apr_psprintf(pool, "get-dir %s r%ld%s%s",
  87. svn_path_uri_encode(path, pool), rev,
  88. want_contents ? " text" : "",
  89. want_props ? " props" : "");
  90. }
  91. const char *
  92. svn_log__get_mergeinfo(const apr_array_header_t *paths,
  93. svn_mergeinfo_inheritance_t inherit,
  94. svn_boolean_t include_descendants,
  95. apr_pool_t *pool)
  96. {
  97. int i;
  98. apr_pool_t *iterpool = svn_pool_create(pool);
  99. svn_stringbuf_t *space_separated_paths = svn_stringbuf_create("", pool);
  100. for (i = 0; i < paths->nelts; i++)
  101. {
  102. const char *path = APR_ARRAY_IDX(paths, i, const char *);
  103. svn_pool_clear(iterpool);
  104. if (i != 0)
  105. svn_stringbuf_appendcstr(space_separated_paths, " ");
  106. svn_stringbuf_appendcstr(space_separated_paths,
  107. svn_path_uri_encode(path, iterpool));
  108. }
  109. svn_pool_destroy(iterpool);
  110. return apr_psprintf(pool, "get-mergeinfo (%s) %s%s",
  111. space_separated_paths->data,
  112. svn_inheritance_to_word(inherit),
  113. include_descendants ? " include-descendants" : "");
  114. }
  115. const char *
  116. svn_log__checkout(const char *path, svn_revnum_t rev, svn_depth_t depth,
  117. apr_pool_t *pool)
  118. {
  119. return apr_psprintf(pool, "checkout-or-export %s r%ld%s",
  120. svn_path_uri_encode(path, pool), rev,
  121. log_depth(depth, pool));
  122. }
  123. const char *
  124. svn_log__update(const char *path, svn_revnum_t rev, svn_depth_t depth,
  125. svn_boolean_t send_copyfrom_args,
  126. apr_pool_t *pool)
  127. {
  128. return apr_psprintf(pool, "update %s r%ld%s%s",
  129. svn_path_uri_encode(path, pool), rev,
  130. log_depth(depth, pool),
  131. (send_copyfrom_args
  132. ? " send-copyfrom-args"
  133. : ""));
  134. }
  135. const char *
  136. svn_log__switch(const char *path, const char *dst_path, svn_revnum_t revnum,
  137. svn_depth_t depth, apr_pool_t *pool)
  138. {
  139. return apr_psprintf(pool, "switch %s %s@%ld%s",
  140. svn_path_uri_encode(path, pool),
  141. svn_path_uri_encode(dst_path, pool), revnum,
  142. log_depth(depth, pool));
  143. }
  144. const char *
  145. svn_log__status(const char *path, svn_revnum_t rev, svn_depth_t depth,
  146. apr_pool_t *pool)
  147. {
  148. return apr_psprintf(pool, "status %s r%ld%s",
  149. svn_path_uri_encode(path, pool), rev,
  150. log_depth(depth, pool));
  151. }
  152. const char *
  153. svn_log__diff(const char *path, svn_revnum_t from_revnum,
  154. const char *dst_path, svn_revnum_t revnum,
  155. svn_depth_t depth, svn_boolean_t ignore_ancestry,
  156. apr_pool_t *pool)
  157. {
  158. const char *log_ignore_ancestry = (ignore_ancestry
  159. ? " ignore-ancestry"
  160. : "");
  161. if (strcmp(path, dst_path) == 0)
  162. return apr_psprintf(pool, "diff %s r%ld:%ld%s%s",
  163. svn_path_uri_encode(path, pool), from_revnum, revnum,
  164. log_depth(depth, pool), log_ignore_ancestry);
  165. return apr_psprintf(pool, "diff %s@%ld %s@%ld%s%s",
  166. svn_path_uri_encode(path, pool), from_revnum,
  167. svn_path_uri_encode(dst_path, pool), revnum,
  168. log_depth(depth, pool), log_ignore_ancestry);
  169. }
  170. const char *
  171. svn_log__log(const apr_array_header_t *paths,
  172. svn_revnum_t start, svn_revnum_t end,
  173. int limit, svn_boolean_t discover_changed_paths,
  174. svn_boolean_t strict_node_history,
  175. svn_boolean_t include_merged_revisions,
  176. const apr_array_header_t *revprops, apr_pool_t *pool)
  177. {
  178. int i;
  179. apr_pool_t *iterpool = svn_pool_create(pool);
  180. svn_stringbuf_t *space_separated_paths = svn_stringbuf_create("", pool);
  181. svn_stringbuf_t *options = svn_stringbuf_create("", pool);
  182. for (i = 0; i < paths->nelts; i++)
  183. {
  184. const char *path = APR_ARRAY_IDX(paths, i, const char *);
  185. svn_pool_clear(iterpool);
  186. if (i != 0)
  187. svn_stringbuf_appendcstr(space_separated_paths, " ");
  188. svn_stringbuf_appendcstr(space_separated_paths,
  189. svn_path_uri_encode(path, iterpool));
  190. }
  191. if (limit)
  192. {
  193. const char *tmp = apr_psprintf(pool, " limit=%d", limit);
  194. svn_stringbuf_appendcstr(options, tmp);
  195. }
  196. if (discover_changed_paths)
  197. svn_stringbuf_appendcstr(options, " discover-changed-paths");
  198. if (strict_node_history)
  199. svn_stringbuf_appendcstr(options, " strict");
  200. if (include_merged_revisions)
  201. svn_stringbuf_appendcstr(options,
  202. log_include_merged_revisions(include_merged_revisions));
  203. if (revprops == NULL)
  204. svn_stringbuf_appendcstr(options, " revprops=all");
  205. else if (revprops->nelts > 0)
  206. {
  207. svn_stringbuf_appendcstr(options, " revprops=(");
  208. for (i = 0; i < revprops->nelts; i++)
  209. {
  210. const char *name = APR_ARRAY_IDX(revprops, i, const char *);
  211. svn_pool_clear(iterpool);
  212. if (i != 0)
  213. svn_stringbuf_appendcstr(options, " ");
  214. svn_stringbuf_appendcstr(options, svn_path_uri_encode(name,
  215. iterpool));
  216. }
  217. svn_stringbuf_appendcstr(options, ")");
  218. }
  219. svn_pool_destroy(iterpool);
  220. return apr_psprintf(pool, "log (%s) r%ld:%ld%s",
  221. space_separated_paths->data, start, end,
  222. options->data);
  223. }
  224. const char *
  225. svn_log__get_locations(const char *path, svn_revnum_t peg_revision,
  226. const apr_array_header_t *location_revisions,
  227. apr_pool_t *pool)
  228. {
  229. const svn_revnum_t *revision_ptr, *revision_ptr_start, *revision_ptr_end;
  230. apr_pool_t *iterpool = svn_pool_create(pool);
  231. svn_stringbuf_t *space_separated_revnums = svn_stringbuf_create("", pool);
  232. revision_ptr_start = (const svn_revnum_t *)location_revisions->elts;
  233. revision_ptr = revision_ptr_start;
  234. revision_ptr_end = revision_ptr + location_revisions->nelts;
  235. while (revision_ptr < revision_ptr_end)
  236. {
  237. svn_pool_clear(iterpool);
  238. if (revision_ptr != revision_ptr_start)
  239. svn_stringbuf_appendcstr(space_separated_revnums, " ");
  240. svn_stringbuf_appendcstr(space_separated_revnums,
  241. apr_psprintf(iterpool, "%ld", *revision_ptr));
  242. ++revision_ptr;
  243. }
  244. svn_pool_destroy(iterpool);
  245. return apr_psprintf(pool, "get-locations %s@%ld (%s)",
  246. svn_path_uri_encode(path, pool),
  247. peg_revision, space_separated_revnums->data);
  248. }
  249. const char *
  250. svn_log__get_location_segments(const char *path, svn_revnum_t peg_revision,
  251. svn_revnum_t start, svn_revnum_t end,
  252. apr_pool_t *pool)
  253. {
  254. return apr_psprintf(pool, "get-location-segments %s@%ld r%ld:%ld",
  255. svn_path_uri_encode(path, pool),
  256. peg_revision, start, end);
  257. }
  258. const char *
  259. svn_log__get_file_revs(const char *path, svn_revnum_t start, svn_revnum_t end,
  260. svn_boolean_t include_merged_revisions,
  261. apr_pool_t *pool)
  262. {
  263. return apr_psprintf(pool, "get-file-revs %s r%ld:%ld%s",
  264. svn_path_uri_encode(path, pool), start, end,
  265. log_include_merged_revisions(include_merged_revisions));
  266. }
  267. const char *
  268. svn_log__lock(const apr_array_header_t *paths,
  269. svn_boolean_t steal, apr_pool_t *pool)
  270. {
  271. int i;
  272. apr_pool_t *iterpool = svn_pool_create(pool);
  273. svn_stringbuf_t *space_separated_paths = svn_stringbuf_create("", pool);
  274. for (i = 0; i < paths->nelts; i++)
  275. {
  276. const char *path = APR_ARRAY_IDX(paths, i, const char *);
  277. svn_pool_clear(iterpool);
  278. if (i != 0)
  279. svn_stringbuf_appendcstr(space_separated_paths, " ");
  280. svn_stringbuf_appendcstr(space_separated_paths,
  281. svn_path_uri_encode(path, iterpool));
  282. }
  283. svn_pool_destroy(iterpool);
  284. return apr_psprintf(pool, "lock (%s)%s", space_separated_paths->data,
  285. steal ? " steal" : "");
  286. }
  287. const char *
  288. svn_log__unlock(const apr_array_header_t *paths,
  289. svn_boolean_t break_lock, apr_pool_t *pool)
  290. {
  291. int i;
  292. apr_pool_t *iterpool = svn_pool_create(pool);
  293. svn_stringbuf_t *space_separated_paths = svn_stringbuf_create("", pool);
  294. for (i = 0; i < paths->nelts; i++)
  295. {
  296. const char *path = APR_ARRAY_IDX(paths, i, const char *);
  297. svn_pool_clear(iterpool);
  298. if (i != 0)
  299. svn_stringbuf_appendcstr(space_separated_paths, " ");
  300. svn_stringbuf_appendcstr(space_separated_paths,
  301. svn_path_uri_encode(path, iterpool));
  302. }
  303. svn_pool_destroy(iterpool);
  304. return apr_psprintf(pool, "unlock (%s)%s", space_separated_paths->data,
  305. break_lock ? " break" : "");
  306. }
  307. const char *
  308. svn_log__lock_one_path(const char *path, svn_boolean_t steal,
  309. apr_pool_t *pool)
  310. {
  311. apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(path));
  312. APR_ARRAY_PUSH(paths, const char *) = path;
  313. return svn_log__lock(paths, steal, pool);
  314. }
  315. const char *
  316. svn_log__unlock_one_path(const char *path, svn_boolean_t break_lock,
  317. apr_pool_t *pool)
  318. {
  319. apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(path));
  320. APR_ARRAY_PUSH(paths, const char *) = path;
  321. return svn_log__unlock(paths, break_lock, pool);
  322. }
  323. const char *
  324. svn_log__replay(const char *path, svn_revnum_t rev, apr_pool_t *pool)
  325. {
  326. const char *log_path;
  327. if (path && path[0] != '\0')
  328. log_path = svn_path_uri_encode(path, pool);
  329. else
  330. log_path = "/";
  331. return apr_psprintf(pool, "replay %s r%ld", log_path, rev);
  332. }