diff hgext/patchbomb.py @ 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 399c8aafc9f9
children d4a1bfe1de63
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