[PATCH 05 of 16] mq: drop `_cacheabletip` usage

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Jan 1 19:09:27 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1356662541 -3600
# Node ID 0e12b59cb6494470d08837d26d6b2753a34d8fea
# Parent  dfb763787bd5eeff1d791e40d65460a80137985f
mq: drop `_cacheabletip` usage

Strip have dedicated work around to solve the same problem, strip is even a
fraction faster without that thanks to simpler update process of the branchcache.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3467,30 +3467,10 @@ def reposetup(ui, repo):
                 else:
                     tags[patch[1]] = patch[0]
 
             return result
 
-        def _cacheabletip(self):
-            q = self.mq
-            cl = self.changelog
-            qbase = None
-            if not q.applied:
-                if getattr(self, '_committingpatch', False):
-                    # Committing a new patch, must be tip
-                    qbase = len(cl) - 1
-            else:
-                qbasenode = q.applied[0].node
-                try:
-                    qbase = self.unfiltered().changelog.rev(qbasenode)
-                except error.LookupError:
-                    self.ui.warn(_('mq status file refers to unknown node %s\n')
-                                 % short(qbasenode))
-            ret = super(mqrepo, self)._cacheabletip()
-            if qbase is not None:
-                ret = min(qbase - 1, ret)
-            return ret
-
     if repo.local():
         repo.__class__ = mqrepo
 
         repo._phasedefaults.append(mqphasedefaults)
 
diff --git a/tests/test-mq-caches.t b/tests/test-mq-caches.t
deleted file mode 100644
--- a/tests/test-mq-caches.t
+++ /dev/null
@@ -1,126 +0,0 @@
-  $ branches=.hg/cache/branchheads
-  $ echo '[extensions]' >> $HGRCPATH
-  $ echo 'mq =' >> $HGRCPATH
-
-  $ show_branch_cache()
-  > {
-  >     # force cache (re)generation
-  >     hg log -r does-not-exist 2> /dev/null
-  >     hg log -r tip --template 'tip: {rev}\n'
-  >     if [ -f $branches ]; then
-  >       sort $branches
-  >     else
-  >       echo No branch cache
-  >     fi
-  >     if [ "$1" = 1 ]; then
-  >       for b in foo bar; do
-  >         hg log -r $b --template "branch $b: "'{rev}\n'
-  >       done
-  >     fi
-  > }
-
-  $ hg init a
-  $ cd a
-  $ hg qinit -c
-
-
-mq patch on an empty repo
-
-  $ hg qnew -d '0 0' p1
-  $ show_branch_cache
-  tip: 0
-  No branch cache
-
-  $ echo > pfile
-  $ hg add pfile
-  $ hg qrefresh -m 'patch 1'
-  $ show_branch_cache
-  tip: 0
-  d986d5caac23a7d44a46efc0ddaf5eb9665844cf 0
-  d986d5caac23a7d44a46efc0ddaf5eb9665844cf default
-
-some regular revisions
-
-  $ hg qpop
-  popping p1
-  patch queue now empty
-  $ echo foo > foo
-  $ hg add foo
-  $ echo foo > .hg/branch
-  $ hg ci -m 'branch foo'
-
-  $ echo bar > bar
-  $ hg add bar
-  $ echo bar > .hg/branch
-  $ hg ci -m 'branch bar'
-  $ show_branch_cache
-  tip: 1
-  c229711f16da3d7591f89b1b8d963b79bda22714 1
-  c229711f16da3d7591f89b1b8d963b79bda22714 bar
-  dc25e3827021582e979f600811852e36cbe57341 foo
-
-add some mq patches
-
-  $ hg qpush
-  applying p1
-  now at: p1
-  $ show_branch_cache
-  tip: 2
-  c229711f16da3d7591f89b1b8d963b79bda22714 1
-  c229711f16da3d7591f89b1b8d963b79bda22714 bar
-  dc25e3827021582e979f600811852e36cbe57341 foo
-
-  $ hg qnew -d '0 0' p2
-  $ echo foo > .hg/branch
-  $ echo foo2 >> foo
-  $ hg qrefresh -m 'patch 2'
-  $ show_branch_cache 1
-  tip: 3
-  982611f6955f9c48d3365decea203217c945ef0d 2
-  982611f6955f9c48d3365decea203217c945ef0d bar
-  dc25e3827021582e979f600811852e36cbe57341 foo
-  branch foo: 3
-  branch bar: 2
-
-removing the cache
-
-  $ rm $branches
-  $ show_branch_cache 1
-  tip: 3
-  c229711f16da3d7591f89b1b8d963b79bda22714 1
-  c229711f16da3d7591f89b1b8d963b79bda22714 bar
-  dc25e3827021582e979f600811852e36cbe57341 foo
-  branch foo: 3
-  branch bar: 2
-
-importing rev 1 (the cache now ends in one of the patches)
-
-  $ hg qimport -r 1 -n p0
-  $ show_branch_cache 1
-  tip: 3
-  c229711f16da3d7591f89b1b8d963b79bda22714 1
-  c229711f16da3d7591f89b1b8d963b79bda22714 bar
-  dc25e3827021582e979f600811852e36cbe57341 foo
-  branch foo: 3
-  branch bar: 2
-  $ hg log -r qbase --template 'qbase: {rev}\n'
-  qbase: 1
-
-detect an invalid cache
-
-  $ hg qpop -a
-  popping p2
-  popping p1
-  popping p0
-  patch queue now empty
-  $ hg qpush -a
-  applying p0
-  applying p1
-  applying p2
-  now at: p2
-  $ show_branch_cache
-  tip: 3
-  dc25e3827021582e979f600811852e36cbe57341 0
-  dc25e3827021582e979f600811852e36cbe57341 foo
-
-  $ cd ..
diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t
--- a/tests/test-mq-qpush-fail.t
+++ b/tests/test-mq-qpush-fail.t
@@ -59,11 +59,10 @@ test corrupt status file
   $ hg qpop
   popping patch1
   patch queue now empty
   $ cp .hg/patches/status.orig .hg/patches/status
   $ hg qpush
-  mq status file refers to unknown node * (glob)
   abort: working directory revision is not qtip
   [255]
   $ rm .hg/patches/status .hg/patches/status.orig
 
 


More information about the Mercurial-devel mailing list