Patchwork [RFC] merge: exit early during a no-op update (BC)

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 3, 2013, 1:40 a.m.
Message ID <21cbc4e20803db7c80dc.1380764422@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2717/
State Superseded
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Siddharth Agarwal - Oct. 3, 2013, 1:40 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1380674634 25200
#      Tue Oct 01 17:43:54 2013 -0700
# Node ID 21cbc4e20803db7c80dcdde20a653d2fdab6a1fe
# Parent  6b93dc02a882c11e61a199ce96df19683fa32298
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.
Siddharth Agarwal - Oct. 3, 2013, 1:43 a.m.
On 10/02/2013 06:40 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1380674634 25200
> #      Tue Oct 01 17:43:54 2013 -0700
> # Node ID 21cbc4e20803db7c80dcdde20a653d2fdab6a1fe
> # Parent  6b93dc02a882c11e61a199ce96df19683fa32298
> merge: exit early during a no-op update (BC)

This is just a wild idea I had. I'd be completely OK if this isn't accepted.
Matt Mackall - Oct. 20, 2013, 1:29 a.m.
On Wed, 2013-10-02 at 18:40 -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1380674634 25200
> #      Tue Oct 01 17:43:54 2013 -0700
> # Node ID 21cbc4e20803db7c80dcdde20a653d2fdab6a1fe
> # Parent  6b93dc02a882c11e61a199ce96df19683fa32298
> 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.

Seems fine. Queued for default, thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -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:
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 @@ 
   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 @@ 
   +cp1
   $ hg qpop -aqf
   patch queue now empty
+  $ hg forget fp1
   $ rm fp1
   $ rm fp1.rej