Patchwork [3,of,5] obsolete: add createmarkers option

login
register
mail settings
Submitter Durham Goode
Date Oct. 14, 2014, 9:51 p.m.
Message ID <70613113a0765b0e7133.1413323510@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6259/
State Superseded
Headers show

Comments

Durham Goode - Oct. 14, 2014, 9:51 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1413318232 25200
#      Tue Oct 14 13:23:52 2014 -0700
# Node ID 70613113a0765b0e7133db0e0bad42a7254b3531
# Parent  d399a51365763f19603de80323da3331ab381a6a
obsolete: add createmarkers option

The basic obsolete option is allowing the creation of obsolete markers. This
does not enable other features, such as allowing unstable commits or exchanging
obsolete markers.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -640,7 +640,7 @@  def _histedit(ui, repo, *freeargs, **opt
         if mapping:
             movebookmarks(ui, repo, mapping, topmost, ntm)
             # TODO update mq state
-        if obsolete._enabled:
+        if obsolete.isenabled(repo, obsolete.createmarkersopt):
             markers = []
             # sort by revision number because it sound "right"
             for prec in sorted(mapping, key=repo.changelog.rev):
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -928,7 +928,7 @@  def clearrebased(ui, repo, state, skippe
 
     If `collapsedas` is not None, the rebase was a collapse whose result if the
     `collapsedas` node."""
-    if obsolete._enabled:
+    if obsolete.isenabled(repo, obsolete.createmarkersopt):
         markers = []
         for rev, newrev in sorted(state.items()):
             if newrev >= 0:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2283,7 +2283,8 @@  def amend(ui, repo, commitfunc, old, ext
                         marks[bm] = newid
                     marks.write()
             #commit the whole amend process
-            if obsolete._enabled and newid != old.node():
+            createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
+            if createmarkers and newid != old.node():
                 # mark the new changeset as successor of the rewritten one
                 new = repo[newid]
                 obs = [(old, (new,))]
@@ -2294,7 +2295,7 @@  def amend(ui, repo, commitfunc, old, ext
             tr.close()
         finally:
             tr.release()
-        if (not obsolete._enabled) and newid != old.node():
+        if not createmarkers and newid != old.node():
             # Strip the intermediate commit (if there was one) and the amended
             # commit
             if node:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -406,9 +406,10 @@  class localrepository(object):
         kwargs = {}
         if defaultformat is not None:
             defaultformat['defaultformat'] = defaultformat
-        kwargs['readonly'] = not obsolete._enabled
+        if not obsolete.isenabled(self, obsolete.createmarkers):
+            kwargs['readonly'] = True
         store = obsolete.obsstore(self.sopener, **kwargs)
-        if store and not obsolete._enabled:
+        if store and not obsolete.isenabled(self, obsolete.createmarkersopt):
             # message is rare enough to not be translated
             msg = 'obsolete feature not enabled but %i markers found!\n'
             self.ui.warn(msg % len(list(store)))
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -80,6 +80,8 @@  from i18n import _
 # the obsolete feature is not mature enough to be enabled by default.
 # you have to rely on third party extension extension to enable this.
 _enabled = False
+# Enablable options for obsolesence
+createmarkersopt = 'createmarkers'
 
 ### obsolescence marker flag