# HG changeset patch # User Siddharth Agarwal # Date 2013-10-02 00:43:54 # Node ID ab2362e1672e341d13b0f2546b672122b2eb5ced # Parent d1ac3790e10a44a3e55e7fe2a86e3e2a849382e9 merge: exit early during a no-op update (BC) hg update . (or equivalents) are effectively no-ops in just about all circumstances. These sorts of updates can be especially common in a bookmark-oriented workflow. This saves us a status check and a manifest decompression, which means that on a repo with over 210,000 files, this brings hg update . down from 2.5 seconds to 0.15. There is one change in behavior: a file that was added, not committed, and then deleted but not removed used to be removed from the dirstate. With this patch it isn't. This is what causes the change in test-mq-qpush-exact.t. This seems like it's enough of an edge case to not be worth handling. The output of test-empty.t changes because those files are not yet created. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -719,6 +719,12 @@ def update(repo, node, branchmerge, forc "subrepository '%s'") % s) elif not overwrite: + if p1 == p2: # no-op update + # call the hooks and exit early + repo.hook('preupdate', throw=True, parent1=xp2, parent2='') + repo.hook('update', parent1=xp2, parent2='', error=0) + return 0, 0, 0, 0 + if pa not in (p1, p2): # nolinear dirty = wc.dirty(missing=True) if dirty or onode is None: diff --git a/tests/test-empty.t b/tests/test-empty.t --- a/tests/test-empty.t +++ b/tests/test-empty.t @@ -42,8 +42,6 @@ Poke at a clone: 0 files, 0 changesets, 0 total revisions $ ls .hg 00changelog.i - branch - dirstate hgrc requires store diff --git a/tests/test-mq-qpush-exact.t b/tests/test-mq-qpush-exact.t --- a/tests/test-mq-qpush-exact.t +++ b/tests/test-mq-qpush-exact.t @@ -243,6 +243,7 @@ qpush --exact --force with changes to a +cp1 $ hg qpop -aqf patch queue now empty + $ hg forget fp1 $ rm fp1 $ rm fp1.rej