[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] #2246: repos_get_commit_editor API

From: Chia-liang Kao <clkao_at_clkao.org>
Date: 2005-03-28 13:59:25 CEST

[[[

* include/svn_repos.h:
  (svn_repos_get_txn_commit_editor): New.
  (svn_repos_get_commit_editor): Correct doc.

* libsvn_repos/commit.c:
  (struct edit_baton): Remove user and log_msg from baton. Add txn_cleanup.
  (open_root): Don't call begin_txn here.
  (svn_repos_get_commit_editor): begin_txn here, and make use
    of new txn_commit_editor api, and override txn_cleanup.
  (svn_repos_get_txn_commit_editor): New.

]]]

Auto-merging (0, 13262) /trunk-txn-editor to /svn/trunk (base /svn/trunk:13258).
Patching locally against mirror source http://svn.collab.net/repos/svn.
U subversion/include/svn_repos.h
U subversion/libsvn_repos/commit.c
==== Patch <-> level 1
Source: fb19c23e-4be0-0310-9262-a6fb3aa7f174:/trunk-txn-editor:13262
Target: 65390229-12b7-0310-b90b-f21a5aa7ec8e:/trunk:13715
        (http://svn.collab.net/repos/svn)
Log:
 r13150@ab: clkao | 2005-03-28 10:50:09 +0800
 branch for repos_get_txn_commit_editor api
 r13261@ab: clkao | 2005-03-28 14:37:09 +0800
 * include/svn_repos.h:
   (svn_repos_get_txn_commit_editor): New.
   (svn_repos_get_commit_editor): Correct doc.
 
 * libsvn_repos/commit.c:
   (struct edit_baton): Remove user and log_msg from baton.
   (open_root): Don't call begin_txn here.
   (svn_repos_get_commit_editor): begin_txn here, and make use
     of new txn_commit_editor api.
   (svn_repos_get_txn_commit_editor): New.
 
 r13262@ab: clkao | 2005-03-28 18:58:04 +0800
 Don't call abort_txn upon abort_edit for the editor returned by
 svn_repos_get_txn_commit_editor. But override this behaviour for
 the one from svn_repos_get_commit_editor.
 

=== subversion/include/svn_repos.h
==================================================================
--- subversion/include/svn_repos.h (revision 13715)
+++ subversion/include/svn_repos.h (patch - level 1)
@@ -557,7 +557,7 @@
 
 /* Making commits. */
 
-/** Return an @a editor and @a edit_baton to commit changes to @a session->fs,
+/** Return an @a editor and @a edit_baton to commit changes to @a repos->fs,
  * beginning at location 'rev:@a base_path', where "rev" is the argument
  * given to @c open_root(). Store @a user as the author of the commit and
  * @a log_msg as the commit message.
@@ -586,6 +586,38 @@
                                           apr_pool_t *pool);
 
 
+/**
+ * @since New in 1.2.
+ *
+ * Return an @a editor and @a edit_baton to commit changes to @a txn->fs,
+ *
+ * @a repos is a previously opened repository. @a repos_url is the decoded
+ * URL to the base of the repository, and is used to check copyfrom paths.
+ * @a txn is a previously prepared transaction object that the editor calls
+ * will be based on.
+ *
+ * Calling @a (*editor)->close_edit completes the commit. Before
+ * @c close_edit returns, but after the commit has succeeded, it will
+ * invoke @a callback with the new revision number, the commit date (as a
+ * <tt>const char *</tt>), commit author (as a <tt>const char *</tt>), and
+ * @a callback_baton as arguments. If @a callback returns an error, that
+ * error will be returned from @c close_edit, otherwise if there was a
+ * post-commit hook failure, then that error will be returned and will
+ * have code SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED.
+ *
+ * Note that calling @ (*editor)->abort_edit will leave @a txn not aborted.
+ */
+
+svn_error_t *svn_repos_get_txn_commit_editor (const svn_delta_editor_t **editor,
+ void **edit_baton,
+ svn_repos_t *repos,
+ const char *repos_url,
+ const char *base_path,
+ svn_fs_txn_t *txn,
+ svn_commit_callback_t callback,
+ void *callback_baton,
+ apr_pool_t *pool);
+
 /* ---------------------------------------------------------------*/
 
 /* Finding particular revisions. */
=== subversion/libsvn_repos/commit.c
==================================================================
--- subversion/libsvn_repos/commit.c (revision 13715)
+++ subversion/libsvn_repos/commit.c (patch - level 1)
@@ -42,13 +42,9 @@
 
   /** Supplied when the editor is created: **/
 
- /* The user doing the commit. Presumably, some higher layer has
- already authenticated this user. */
- const char *user;
+ /* Should transaction be cleaned upon abort_edit? */
+ svn_boolean_t clean_txn;
 
- /* Commit message for this commit. */
- const char *log_msg;
-
   /* Callback to run when the commit is done. */
   svn_commit_callback_t callback;
   void *callback_baton;
@@ -130,23 +126,7 @@
 {
   struct dir_baton *dirb;
   struct edit_baton *eb = edit_baton;
- svn_revnum_t youngest;
- svn_fs_txn_t *txn;
 
- /* Ignore BASE_REVISION. We always build our transaction against
- HEAD. However, we will keep it in our dir baton for out of
- dateness checks. */
- SVN_ERR (svn_fs_youngest_rev (&youngest, eb->fs, eb->pool));
-
- /* Begin a subversion transaction, cache its name, and get its
- root object. */
- SVN_ERR (svn_repos_fs_begin_txn_for_commit (&txn,
- eb->repos,
- youngest,
- eb->user,
- eb->log_msg,
- eb->pool));
- eb->txn = txn;
   SVN_ERR (svn_fs_txn_root (&(eb->txn_root), eb->txn, eb->pool));
   SVN_ERR (svn_fs_txn_name (&(eb->txn_name), eb->txn, eb->pool));
   
@@ -612,7 +592,7 @@
             apr_pool_t *pool)
 {
   struct edit_baton *eb = edit_baton;
- return (eb->txn ? svn_fs_abort_txn (eb->txn, pool) : SVN_NO_ERROR);
+ return eb->clean_txn ? svn_fs_abort_txn (eb->txn, pool): SVN_NO_ERROR;
 }
 
 
@@ -632,6 +612,49 @@
                              void *callback_baton,
                              apr_pool_t *pool)
 {
+ svn_revnum_t youngest;
+ struct edit_baton *eb;
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+
+ /* Ignore BASE_REVISION. We always build our transaction against
+ HEAD. However, we will keep it in our dir baton for out of
+ dateness checks. */
+ fs = svn_repos_fs (repos);
+
+ SVN_ERR (svn_fs_youngest_rev (&youngest, fs, pool));
+
+ /* Begin a subversion transaction, cache its name, and get its
+ root object. */
+
+ SVN_ERR (svn_repos_fs_begin_txn_for_commit (&txn,
+ repos,
+ youngest,
+ user ? apr_pstrdup (pool, user) : NULL,
+ apr_pstrdup (pool, log_msg),
+ pool));
+
+ SVN_ERR (svn_repos_get_txn_commit_editor (editor, (void **)&eb,
+ repos, repos_url, base_path,
+ txn, callback, callback_baton,
+ pool));
+ eb->clean_txn = TRUE;
+ *edit_baton = eb;
+ return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_repos_get_txn_commit_editor (const svn_delta_editor_t **editor,
+ void **edit_baton,
+ svn_repos_t *repos,
+ const char *repos_url,
+ const char *base_path,
+ svn_fs_txn_t *txn,
+ svn_commit_callback_t callback,
+ void *callback_baton,
+ apr_pool_t *pool)
+{
+
   svn_delta_editor_t *e = svn_delta_default_editor (pool);
   apr_pool_t *subpool = svn_pool_create (pool);
   struct edit_baton *eb = apr_pcalloc (subpool, sizeof (*eb));
@@ -652,18 +675,17 @@
 
   /* Set up the edit baton. */
   eb->pool = subpool;
- eb->user = user ? apr_pstrdup (subpool, user) : NULL;
- eb->log_msg = apr_pstrdup (subpool, log_msg);
   eb->callback = callback;
   eb->callback_baton = callback_baton;
   eb->base_path = apr_pstrdup (subpool, base_path);
   eb->repos = repos;
   eb->repos_url = repos_url;
   eb->fs = svn_repos_fs (repos);
- eb->txn = NULL;
+ eb->txn = txn;
+ eb->clean_txn = FALSE;
 
   *edit_baton = eb;
   *editor = e;
-
+
   return SVN_NO_ERROR;
 }

==== BEGIN SVK PATCH BLOCK ====
Version: svk 0.30 (freebsd)

eJydV82P20QU94FTEBISUiWEKs0hXZI02bXHsZ141TS0bAu02kXbLQcEssb2eGPW8UT+2HaFKXG7
PfAhwZV+IA6IE8cCEhIg/gH+Ef4ArrwZx0l2Sbq7ZFeJZ+a935v33m/ePF+Ldtb7StbryVlVkbNb
790wzXdJ4gwuKO2sqmfU9RMWVbUsoPs0qKpZwHar7SwkQwqrMUsjhz8kJNqlCX/wnT2a9HoKwHUK
uA0BUcIKVJskLIyrXQFvJRGlVSXT+0bWV/m/VVW6WUxhRcBaEd33Y5+FsA1FxToGEZBXQJ+NaGhF
jCViyVD0PubacuYELKYWh4eZvsblcRVcEgquH1EH9nTAJePU3qeRgOeYJY7YhTbBmVPIFL5HAagu
AuzMAa75oROkLhXGS2Chqi1Qxeq8auDb8T74RkcsPqK/dGN46mm7jIznB7Sqygu2tDYFXx0IV06E
Vwt4sUpGo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8WVB6y6UTSvDSz7zeWTJ05pp+IqLgPGSI44lMVT6uAO6idF174+atDUHpRQmbxJOPhcyS
BC68ZEQF11ydagQTmxC9Q2xbxQqWiULhT5YVuSN6QEOTMxQpqqLJfWKbEMlgjzCUISzLWktWW7iD
FNnUZFPuootyR5YryIay7AwQ1Bz0PK6QkV/h0FhXlkO3TdWYg26gBU2byaN+0mmHwg2N0OoC0eNi
V1nEb0LkMgfEuc2FN+nE6vFaDwDbdMigExE1k7dVk5qGvIgNkRAqtjHt2EHnTRa+XvQ5aFq10YBG
9DQ7PqrRFEaHZE9soWAk81AIbeDCJCyysDx8k5Th5SnrmFrHlNtlyuY8m12qx65owZW5trDgMlzl
9kEFnbCzVYSupAmCiEeR7/KGERpSmw4I70cjjlwR0CykRQaeE0vuH9C+1evhrIpx8dK2I968TPN2
6PPWigQX9Aze+3gFgZdAuJBhkKa+W1WMbA3oEO61eIs8fV0U4aqqeubBW4CDVdpq21SGaClyC1ol
3CK6Z6uEGJ5itHt1nC3D1yfwk/5N45i6pnZljLstBdtGgWl3ZbvFu0UNMKnTgZdS+VS2zf/s3hR7
/xdQw7E6
==== END SVK PATCH BLOCK ====

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Mar 28 14:02:59 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.