Patchwork [04,of,10,shelve-ext,v2] shelve: add a function to check whether obs-based shelve is enabled

login
register
mail settings
Submitter Kostia Balytskyi
Date Jan. 19, 2017, 3:10 p.m.
Message ID <ceb709491816f84789b7.1484838631@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18253/
State Deferred
Headers show

Comments

Kostia Balytskyi - Jan. 19, 2017, 3:10 p.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1484740179 28800
#      Wed Jan 18 03:49:39 2017 -0800
# Node ID ceb709491816f84789b77a18bfcab15eaa9860fe
# Parent  249273f6db8bf0fdfbbf36bcbd9e3553e5715212
shelve: add a function to check whether obs-based shelve is enabled

A central place to check whether code should use traditional or
obsolescense-based shelve behavior.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -40,6 +40,7 @@  from mercurial import (
     mdiff,
     merge,
     node as nodemod,
+    obsolete,
     patch,
     phases,
     repair,
@@ -70,6 +71,18 @@  patchextension = 'patch'
 # generic user for all shelve operations
 shelveuser = 'shelve@localhost'
 
+def isobsshelve(repo, ui):
+    """Check whether obsolescense-based shelve is enabled"""
+    obsshelve = ui.configbool('experimental', 'obsshelve')
+    if not obsshelve:
+        return False
+    if not obsolete.isenabled(repo, obsolete.createmarkersopt):
+        w = _('ignoring experimental.obsshelve because createmarkers option '
+              'is disabled')
+        ui.warn(w)
+        return False
+    return True
+
 class obsshelvefile(scmutil.simplekeyvaluefile):
     KEYS = [('node', True)]