changeset 1054:131cb06dca76

svnwrap & pushmod: return a Revision when committing
author Dan Villiom Podlaski Christiansen <dan@cabo.dk>
date Fri, 09 Aug 2013 19:19:44 +0200
parents 04f15d38a500
children 2d7398fffd0d
files hgsubversion/pushmod.py hgsubversion/svnwrap/subvertpy_wrapper.py hgsubversion/svnwrap/svn_swig_wrapper.py
diffstat 3 files changed, 26 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/pushmod.py
+++ b/hgsubversion/pushmod.py
@@ -196,9 +196,9 @@ def commit(ui, repo, rev_ctx, meta, base
     if not new_target_files:
         raise NoFilesException()
     try:
-        svn.commit(new_target_files, rev_ctx.description(), file_data,
-                   base_revision, set(addeddirs), set(deleteddirs),
-                   props, newcopies)
+        return svn.commit(new_target_files, rev_ctx.description(), file_data,
+                          base_revision, set(addeddirs), set(deleteddirs),
+                          props, newcopies)
     except svnwrap.SubversionException, e:
         if len(e.args) > 0 and e.args[1] in (svnwrap.ERR_FS_TXN_OUT_OF_DATE,
                                              svnwrap.ERR_FS_CONFLICT,
@@ -211,5 +211,3 @@ def commit(ui, repo, rev_ctx, meta, base
             raise hgutil.Abort(e.args[0])
         else:
             raise
-
-    return True
--- a/hgsubversion/svnwrap/subvertpy_wrapper.py
+++ b/hgsubversion/svnwrap/subvertpy_wrapper.py
@@ -380,10 +380,14 @@ class SubversionRepo(object):
     def commit(self, paths, message, file_data, base_revision, addeddirs,
                deleteddirs, props, copies):
         """Commits the appropriate targets from revision in editor's store.
+
+        Return the committed revision as a common.Revision instance.
         """
-        def commitcb(*args):
-            commit_info.append(args)
-        commit_info = []
+        def commitcb(rev, date, author):
+            r = common.Revision(rev, author, message, date)
+            committedrev.append(r)
+
+        committedrev = []
         revprops = { properties.PROP_REVISION_LOG: message }
         # revprops.update(props)
         commiteditor = self.remote.get_commit_editor(revprops, commitcb)
@@ -464,6 +468,8 @@ class SubversionRepo(object):
             raise
         commiteditor.close()
 
+        return committedrev.pop()
+
     def get_replay(self, revision, editor, oldestrev=0):
 
         try:
--- a/hgsubversion/svnwrap/svn_swig_wrapper.py
+++ b/hgsubversion/svnwrap/svn_swig_wrapper.py
@@ -368,11 +368,20 @@ class SubversionRepo(object):
     def commit(self, paths, message, file_data, base_revision, addeddirs,
                deleteddirs, properties, copies):
         """Commits the appropriate targets from revision in editor's store.
+
+        Return the committed revision as a common.Revision instance.
         """
         self.init_ra_and_client()
-        commit_info = []
-        def commit_cb(_commit_info, pool):
-            commit_info.append(_commit_info)
+
+        def commit_cb(commit_info, pool):
+            # disregard commit_info.post_commit_err for now
+            r = common.Revision(commit_info.revision, commit_info.author,
+                                message, commit_info.date)
+
+            committedrev.append(r)
+
+        committedrev = []
+
         editor, edit_baton = ra.get_commit_editor2(self.ra,
                                                    message,
                                                    commit_cb,
@@ -446,6 +455,8 @@ class SubversionRepo(object):
 
         editor.close_edit(edit_baton, self.pool)
 
+        return committedrev.pop()
+
     def get_replay(self, revision, editor, oldest_rev_i_have=0):
         # this method has a tendency to chew through RAM if you don't re-init
         self.init_ra_and_client()