changeset 26546:500386e65759

patchbomb: add experimental config of a "pullurl" and export it This config allows to specify a public location where your changeset can be found. It then include a dedicated patch header show a command to be used to retrieve the change. See the test for example. This is flagged as experimental because this feature is not safe until we have more logic to test that: - changeset actually exists on destination - changeset is draft on destination. As all this is experimental, bike shedding can happily happens before we remove the experimental flag.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 06 Oct 2015 01:49:04 -0700
parents e99c3846d78a
children b9be8ab6e628
files hgext/patchbomb.py tests/test-patchbomb.t
diffstat 2 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Mon Oct 05 23:17:01 2015 -0700
+++ b/hgext/patchbomb.py	Tue Oct 06 01:49:04 2015 -0700
@@ -73,6 +73,24 @@
 # leave the attribute unspecified.
 testedwith = 'internal'
 
+def _addpullheader(seq, ctx):
+    """Add a header pointing to a public URL where the changeset is available
+    """
+    repo = ctx.repo()
+    # experimental config: patchbomb.publicurl
+    # waiting for some logic that check that the changeset are available on the
+    # destination before patchbombing anything.
+    pullurl = repo.ui.config('patchbomb', 'publicurl')
+    if pullurl is not None:
+        return ('Available At %s\n'
+                '#              hg pull %s -r %s' % (pullurl, pullurl, ctx))
+    return None
+
+def uisetup(ui):
+    cmdutil.extraexport.append('pullurl')
+    cmdutil.extraexportmap['pullurl'] = _addpullheader
+
+
 def prompt(ui, prompt, default=None, rest=':'):
     if default:
         prompt += ' [%s]' % default
--- a/tests/test-patchbomb.t	Mon Oct 05 23:17:01 2015 -0700
+++ b/tests/test-patchbomb.t	Tue Oct 06 01:49:04 2015 -0700
@@ -2800,3 +2800,18 @@
    d
   +d
   
+Test pull url header
+=================================
+
+  $ echo 'intro=auto' >> $HGRCPATH
+  $ echo 'publicurl=http://example.com/myrepo/' >> $HGRCPATH
+  $ hg email --date '1980-1-1 0:1' -n -t foo -s test -r '10' | grep '^#'
+  # HG changeset patch
+  # User test
+  # Date 5 0
+  #      Thu Jan 01 00:00:05 1970 +0000
+  # Branch test
+  # Node ID 3b6f1ec9dde933a40a115a7990f8b320477231af
+  # Parent  2f9fa9b998c5fe3ac2bd9a2b14bfcbeecbc7c268
+  # Available At http://example.com/myrepo/
+  #              hg pull http://example.com/myrepo/ -r 3b6f1ec9dde9