Commits

Anonymous committed 6fe94d2

Allow sourcebranch configuration.

  • Participants
  • Parent commits 6cfbfac

Comments (0)

Files changed (2)

File extensions/create_patch.py

 class NotChanged(ValueError):
     pass
 
-def download_patch(source, lastrev, patchbranch):
+def download_patch(source, lastrev, sourcebranch, patchbranch):
     from mercurial import hg, ui, localrepo, commands, bundlerepo
     UI = ui.ui()
     bundle = tempfile.mktemp(dir="/var/tmp")
             raise NotChanged
         repo=bundlerepo.bundlerepository(UI, ".", bundle)
         repo.ui.pushbuffer()
-        old = 'max(p1(min(outgoing() and branch(%s))) or p2(max(merge() and outgoing() and branch(%s))))' % (patchbranch, patchbranch)
+        old = 'max(p1(min(outgoing() and branch(%s))) or max(p2(merge() and outgoing() and branch(%s)) and branch(%s)))' % (patchbranch, patchbranch, sourcebranch)
         commands.diff(repo.ui, repo, rev=[old, patchbranch])
         result = repo.ui.popbuffer()
     finally:
             self.client.error_message.append('unknown hgrepo url')
             return
         lastrev = db.hgrepo.get(repo, 'lastrev')
-        branch = db.hgrepo.get(repo, 'patchbranch')
-        if not branch:
-            branch = 'default'
+        sourcebranch = db.hgrepo.get(repo, 'sourcebranch')
+        if not sourcebranch:
+            sourcebranch = 'default'
+        patchbranch = db.hgrepo.get(repo, 'patchbranch')
+        if not patchbranch:
+            patchbranch = 'default'
         try:
-            diff, head = download_patch(url, lastrev, branch)
+            diff, head = download_patch(url, lastrev, sourcebranch, patchbranch)
         except NotChanged:
             self.client.error_message.append('%s.diff is already available' % lastrev)
             return
 hgrepo = Class(db, "hgrepo",
                url=String(),
                lastrev=String(),
+               sourcebranch=String(),
                patchbranch=String(),
                )
 
     return userid == db.hgrepo.get(itemid, "creator")
 db.security.addPermissionToRole('User', 'Create', 'hgrepo')
 p = db.security.addPermission(name='Edit', klass='hgrepo', check=may_edit_hgrepo,
-                              properties=['url', 'patchbranch'])
+                              properties=['url', 'sourcebranch', 'patchbranch'])
 db.security.addPermissionToRole('User', p)
 
 class may_view_spam: