merge: exit early during a no-op update (BC)
authorSiddharth Agarwal <sid0@fb.com>
Tue, 01 Oct 2013 17:43:54 -0700
changeset 19929 ab2362e1672e
parent 19928 d1ac3790e10a
child 19930 b8316878a685
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.
mercurial/merge.py
tests/test-empty.t
tests/test-mq-qpush-exact.t
--- a/mercurial/merge.py	Thu Oct 17 21:45:17 2013 +0900
+++ b/mercurial/merge.py	Tue Oct 01 17:43:54 2013 -0700
@@ -719,6 +719,12 @@
                                        "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:
--- a/tests/test-empty.t	Thu Oct 17 21:45:17 2013 +0900
+++ b/tests/test-empty.t	Tue Oct 01 17:43:54 2013 -0700
@@ -42,8 +42,6 @@
   0 files, 0 changesets, 0 total revisions
   $ ls .hg
   00changelog.i
-  branch
-  dirstate
   hgrc
   requires
   store
--- a/tests/test-mq-qpush-exact.t	Thu Oct 17 21:45:17 2013 +0900
+++ b/tests/test-mq-qpush-exact.t	Tue Oct 01 17:43:54 2013 -0700
@@ -243,6 +243,7 @@
   +cp1
   $ hg qpop -aqf
   patch queue now empty
+  $ hg forget fp1
   $ rm fp1
   $ rm fp1.rej