From 58e6dfbbdb4548b00bdf298045f5a7fe7550ef9f Mon Sep 17 00:00:00 2001
From: Benjamin Drung <bdrung@ubuntu.com>
Date: Sat, 10 Dec 2011 12:51:53 +0100
Subject: [PATCH] sponsor-patch: Use syncpackage instead of subscribing
 ubuntu-archive for sync requests, because syncpackage supports sponsorship
 now.

---
 debian/changelog                            |  7 +++++++
 doc/sponsor-patch.1                         |  3 ---
 ubuntutools/sponsor_patch/source_package.py | 10 ++++------
 ubuntutools/sponsor_patch/sponsor_patch.py  |  3 +--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 702db68..3cda22c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ubuntu-dev-tools (0.138) UNRELEASED; urgency=low
+
+  * sponsor-patch: Use syncpackage instead of subscribing ubuntu-archive for
+    sync requests, because syncpackage supports sponsorship now.
+
+ -- Benjamin Drung <bdrung@debian.org>  Sat, 10 Dec 2011 12:46:33 +0100
+
 ubuntu-dev-tools (0.137) unstable; urgency=low
 
   [ Stefano Rivera ]
diff --git a/doc/sponsor-patch.1 b/doc/sponsor-patch.1
index 96809ab..b462a7c 100644
--- a/doc/sponsor-patch.1
+++ b/doc/sponsor-patch.1
@@ -14,9 +14,6 @@ builds it, runs
 .BR lintian (1)
 and, after review and confirmation, can upload it.
 
-For syncs, sponsor\-patch will follow the usual procedure of commenting
-on \fIbug\fR, marking it confirmed, and subscribing \fBubuntu-archive\fR.
-
 \fBsponsor\-patch\fR can be used for sponsoring patches, syncs and
 merges from Debian, SRUs, and creating debdiffs from patches.
 If \fIbug\fR has multiple patches or branches linked, it will prompt the
diff --git a/ubuntutools/sponsor_patch/source_package.py b/ubuntutools/sponsor_patch/source_package.py
index b50b5a1..77f0b76 100644
--- a/ubuntutools/sponsor_patch/source_package.py
+++ b/ubuntutools/sponsor_patch/source_package.py
@@ -437,14 +437,12 @@ class SourcePackage(object):
 
         return lintian_filename
 
-    def sync(self, upload, bug_number, keyid):
+    def sync(self, upload, bug_number, requester):
         """Does a sync of the source package."""
 
         if upload == "ubuntu":
-            cmd = ["syncpackage", self._package, "-b", str(bug_number),
-                   "-V", str(self._version)]
-            if keyid is not None:
-                cmd += ["-k", keyid]
+            cmd = ["syncpackage", self._package, "-b", str(bug_number), "-f",
+                   "-s", requester, "-V", str(self._version)]
             Logger.command(cmd)
             if subprocess.call(cmd) != 0:
                 Logger.error("Syncing of %s %s failed.", self._package,
@@ -452,7 +450,7 @@ class SourcePackage(object):
                 sys.exit(1)
         else:
             # FIXME: Support this use case!
-            Logger.error("Uploading a synced package other than to ubuntu "
+            Logger.error("Uploading a synced package other than to Ubuntu "
                          "is not supported yet!")
             sys.exit(1)
         return True
diff --git a/ubuntutools/sponsor_patch/sponsor_patch.py b/ubuntutools/sponsor_patch/sponsor_patch.py
index f905e15..cc4c415 100644
--- a/ubuntutools/sponsor_patch/sponsor_patch.py
+++ b/ubuntutools/sponsor_patch/sponsor_patch.py
@@ -277,8 +277,7 @@ def sponsor_patch(bug_number, build, builder, edit, keyid, lpinstance, update,
                                                          previous_version)
 
         if successful:
-            #if source_package.sync(upload, bug_number, keyid):
-            if source_package.ack_sync(upload, task.get_lp_task(), launchpad):
+            if source_package.sync(upload, bug_number, bug.owner.name):
                 return
             else:
                 edit = True