tests/test-merge-revert2.t
author Gregory Szorc <gregory.szorc@gmail.com>
Sat, 18 Jul 2015 10:57:20 -0700
changeset 25823 2406e2baa937
parent 21693 9c35f3a8cac4
child 26614 ef1eb6df7071
permissions -rw-r--r--
changegroup: compute seen files as changesets are added (issue4750) Before this patch, addchangegroup() would walk the changelog and compute the set of seen files between applying changesets and applying manifests. When cloning large repositories such as mozilla-central, this consumed a non-trivial amount of time. On my MBP, this walk takes ~10s. On a dainty EC2 instance, this was measured to take ~125s! On the latter machine, this delay was enough for the Mercurial server to disconnect the client, thinking it had timed out, thus causing a clone to abort. This patch enables the changelog to compute the set of changed files as new revisions are added. By doing so, we: * avoid a potentially heavy computation between changelog and manifest processing by spreading the computation across all changelog additions * avoid extra reads from the changelog by operating on the data as it is added The downside of this is that the add revision callback does result in extra I/O. Before, we would perform a flush (and subsequent read to construct the full revision) when new delta chains were created. For changelogs, this is typically every 2-4 revisions. Using the callback guarantees there will be a flush after every added revision *and* an open + read of the changelog to obtain the full revision in order to read the added files. So, this increases the frequency of these operations by the average chain length. In the future, the revlog should be smart enough to know how to read revisions that haven't been flushed yet, thus eliminating this extra I/O. On my MBP, the total CPU times for an `hg unbundle` with a local mozilla-central gzip bundle containing 251,934 changesets and 211,065 files did not have a statistically significant change with this patch, holding steady around 360s. So, the increased revlog flushing did not have an effect. With this patch, there is no longer a visible pause between applying changeset and manifest data. Before, it sure felt like Mercurial was lethargic making this transition. Now, the transition is nearly instantaneous, giving the impression that Mercurial is faster. Of course, eliminating this pause means that the potential for network disconnect due to channel inactivity during the changelog walk is eliminated as well. And that is the impetus behind this change.

  $ hg init

  $ echo "added file1" > file1
  $ echo "another line of text" >> file1
  $ echo "added file2" > file2
  $ hg add file1 file2
  $ hg commit -m "added file1 and file2"

  $ echo "changed file1" >> file1
  $ hg commit -m "changed file1"

  $ hg -q log
  1:dfab7f3c2efb
  0:c3fa057dd86f
  $ hg id
  dfab7f3c2efb tip

  $ hg update -C 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg id
  c3fa057dd86f

  $ echo "changed file1" >> file1
  $ hg id
  c3fa057dd86f+

  $ hg revert --no-backup --all
  reverting file1
  $ hg diff
  $ hg status
  $ hg id
  c3fa057dd86f

  $ hg update
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg diff
  $ hg status
  $ hg id
  dfab7f3c2efb tip

  $ hg update -C 0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo "changed file1 different" >> file1

  $ hg update
  merging file1
  warning: conflicts during merge.
  merging file1 incomplete! (edit conflicts, then use 'hg resolve --mark')
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
  use 'hg resolve' to retry unresolved file merges
  [1]

  $ hg diff --nodates
  diff -r dfab7f3c2efb file1
  --- a/file1
  +++ b/file1
  @@ -1,3 +1,7 @@
   added file1
   another line of text
  +<<<<<<< working copy: c3fa057dd86f  - test: added file1 and file2
  +changed file1 different
  +=======
   changed file1
  +>>>>>>> destination:  dfab7f3c2efb - test: changed file1

  $ hg status
  M file1
  ? file1.orig
  $ hg id
  dfab7f3c2efb+ tip

  $ hg revert --no-backup --all
  reverting file1
  $ hg diff
  $ hg status
  ? file1.orig
  $ hg id
  dfab7f3c2efb tip

  $ hg revert -r tip --no-backup --all
  $ hg diff
  $ hg status
  ? file1.orig
  $ hg id
  dfab7f3c2efb tip

  $ hg update -C
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg diff
  $ hg status
  ? file1.orig
  $ hg id
  dfab7f3c2efb tip