GitRepository: allow to use '..' instead of '...'
authorGuido Günther <agx@sigxcpu.org>
Sat, 24 Aug 2013 09:06:11 +0000 (11:06 +0200)
committerGuido Günther <agx@sigxcpu.org>
Sat, 24 Aug 2013 09:30:22 +0000 (11:30 +0200)
The symmetric difference isn't always useful since it includes changes
from both branches. See #680705.

gbp/git/repository.py

index 502a391483b0d9ce5c61f42d9e0fd30c68b1ace6..3fe8d6f74e61f918b802dadd5007641e07c5988a 100644 (file)
@@ -1443,14 +1443,27 @@ class GitRepository(object):
                 'files' : files}
 
 #{ Patches
-    def format_patches(self, start, end, output_dir, signature=True, thread=None):
+    def format_patches(self, start, end, output_dir,
+                       signature=True,
+                       thread=None,
+                       symmetric=True):
         """
-        Output the commits between start and end as patches in output_dir
+        Output the commits between start and end as patches in output_dir.
+
+        This outputs the revisions I{start...end} by default. When using
+        I{symmetric} to C{false} it uses I{start..end} instead.
+
+        @param start: the commit on the left side of the revision range
+        @param end: the commit on the right hand side of the revisino range
+        @param output_dir: directory to write the patches to
+        @param signature: whether to output a signature
+        @param thread: whether to include In-Reply-To references
+        @param symmetric: whether to use the symmetric difference (see above)
         """
         options = GitArgs('-N', '-k',
                           '-o', output_dir)
         options.add_cond(not signature, '--no-signature')
-        options.add('%s...%s' % (start, end))
+        options.add('%s%s%s' % (start, '...' if symmetric else '..', end))
         options.add_cond(thread, '--thread=%s' % thread, '--no-thread')
 
         output, ret = self._git_getoutput('format-patch', options.args)