Patchwork shelve: add a maxchanges option

login
register
mail settings
Submitter Jun Wu
Date June 21, 2017, 12:17 a.m.
Message ID <1429a9c16c6b64cd7f1f.1498004222@x1c>
Download mbox | patch
Permalink /patch/21564/
State Superseded
Delegated to: Jun Wu
Headers show

Comments

Jun Wu - June 21, 2017, 12:17 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1498003277 25200
#      Tue Jun 20 17:01:17 2017 -0700
# Node ID 1429a9c16c6b64cd7f1f399c8fe3ee8b5fa0686b
# Parent  0ce2cbebd74964ffe61e79de8941461bccc9371b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 1429a9c16c6b
shelve: add a maxchanges option

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -20,4 +20,10 @@  You can have more than one shelved chang
 shelved change has a distinct name. For details, see the help for "hg
 shelve".
+
+Config::
+
+    [shelve]
+    # maximum shelved changes per name (active bookmark or branch)
+    maxchanges = 100
 """
 from __future__ import absolute_import
@@ -317,5 +323,5 @@  def getshelvename(repo, parent, opts):
     def gennames():
         yield label
-        for i in xrange(1, 100):
+        for i in xrange(1, repo.ui.configint('shelve', 'maxchanges', 100)):
             yield '%s-%02d' % (label, i)
     name = opts.get('name')
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -1782,2 +1782,23 @@  mercurial does not crash
   $ cd ..
 
+Config shelve.maxchanges limits how many changes for a name are allowed
+  $ cd $TESTTMP
+  $ hg init maxchanges
+  $ cd maxchanges
+  $ cat >> .hg/hgrc<<EOF
+  > [shelve]
+  > maxchanges=2
+  > EOF
+  $ touch a
+  $ hg ci -m a -A a
+  $ for i in 1 2 3; do
+  >    echo $i >> a
+  >    hg shelve
+  > done
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  shelved as default-01
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  abort: too many shelved changes named 'default'
+  [255]
+