Source

thg-qt-mq / email-base.diff

Full commit
# HG changeset patch
# Parent ea8b6409d709a683d4648780d0dee09861338e53
diff --git a/tortoisehg/hgqt/hgemail.py b/tortoisehg/hgqt/hgemail.py
--- a/tortoisehg/hgqt/hgemail.py
+++ b/tortoisehg/hgqt/hgemail.py
@@ -19,7 +19,7 @@ from tortoisehg.hgqt.hgemail_ui import U
 
 class EmailDialog(QDialog):
     """Dialog for sending patches via email"""
-    def __init__(self, repo, revs, parent=None):
+    def __init__(self, repo, revs, base=None, parent=None):
         super(EmailDialog, self).__init__(parent)
         self._repo = repo
 
@@ -27,7 +27,7 @@ class EmailDialog(QDialog):
         self._qui.setupUi(self)
         self._qui.bundle_radio.setEnabled(False)  # TODO: bundle support
 
-        self._initchangesets(revs)
+        self._initchangesets(revs, base)
         self._initpreviewtab()
         self._initenvelopebox()
         self._initintrobox()
@@ -82,10 +82,18 @@ class EmailDialog(QDialog):
             w = getattr(self._qui, '%s_edit' % k)
             s.setValue('email/%s_history' % k, list(itercombo(w))[:10])
 
-    def _initchangesets(self, revs):
-        def purerevs(revs):
+    def _initchangesets(self, revs, base):
+        def revrange(revs):
             return cmdutil.revrange(self._repo,
                                     iter(str(e) for e in revs))
+        def purerevs(revs):
+            if not base:
+                return revrange(revs)
+            revns = [self._repo.lookup(r) for r in revrange(revs)]
+            basens = [self._repo.lookup(r) for r in revrange(base)]
+            nodes = self._repo.changelog.nodesbetween(basens, revns)[0]
+            # XXX: make base exclusive
+            return map(self._repo.changelog.rev, nodes)
 
         self._changesets = _ChangesetsModel(self._repo,
                                             # TODO: [':'] is inefficient
@@ -416,12 +424,13 @@ def run(ui, *revs, **opts):
         if revs:
             raise util.Abort(_('use only one form to specify the revision'))
         revs = opts.get('rev')
+    base = opts.get('base')
 
     # TODO: repo should be a required argument?
     repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())
 
     try:
-        return EmailDialog(repo, revs)
+        return EmailDialog(repo, revs, base)
     except error.RepoLookupError, e:
         qtlib.ErrorMsgBox(_('Failed to open Email dialog'),
                           hglib.tounicode(e.message))
diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -960,7 +960,9 @@ table = {
     "^init": (init, [], _('thg init [DEST]')),
     "^email":
         (email,
-         [('r', 'rev', [], _('a revision to send')),],
+         [('r', 'rev', [], _('a revision to send')),
+          ('', 'base', [],
+           _('a base changeset assumed to be available at the destination'))],
          _('thg email [REVS]')),
     "^log|history|explorer|workbench":
         (log,