Ticket #277 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

fix mercurial checkouts w/ revision

Reported by: bhearsum Owned by: bsmedberg
Priority: major Milestone: 0.7.11
Version: 0.7.9 Keywords: review
Cc: warner, dustin, afri, even, bsmedberg, Pike, marcusl, fqueze

Description

Mercurial checkouts that specify a revision *always* clobber. This is really terrible for large trees. By separating 'pull' and 'update' we can update to a certain revision without clobbering.

Through my own tests and asking around in #mercurial on Freenode I've confirmed that 'hg clone --rev [num]' and 'hg pull' && 'hg update --rev [num]' leave the working directory in the exact same state. (When doing a clone --rev you won't have any revisions later than the specified one in your repository, but I don't think we care about that.)

Patch incoming.

Attachments

fixMercurialUpdate.diff Download (1.7 KB) - added by bhearsum 5 years ago.
fix mercurial checkouts with a revision
buildbot-hg-pull-command.patch Download (2.6 KB) - added by bsmedberg 5 years ago.
patch for commands.py
buildbot-bug277.patch Download (3.3 KB) - added by bsmedberg 5 years ago.
Updated patch
bug277-bug187-fix.patch Download (1.6 KB) - added by marcusl 4 years ago.
Fix #277 -patch to work with #187 fix
patch Download (664 bytes) - added by even 4 years ago.
Remove an useless test causing the bug.

Change History

Changed 5 years ago by bhearsum

fix mercurial checkouts with a revision

comment:1 Changed 5 years ago by bhearsum

  • Owner set to bhearsum
  • Status changed from new to assigned

I was going to write a test for this but I'm pretty sure it gets tested as part of Mercurial.test_checkout. self.do_vctest() seems to do a lot of things, including adding revisions and checking out.

comment:2 Changed 5 years ago by bhearsum

Just wanted to note that we've been running this for the past few weeks without issue.

comment:3 Changed 5 years ago by bhearsum

  • Cc warner, dustin added

Any chance this will make 0.7.8?

comment:4 Changed 5 years ago by warner

  • Owner changed from bhearsum to warner
  • Status changed from assigned to new

I'll look at it

comment:5 Changed 5 years ago by afri

  • Cc afri added

comment:6 Changed 5 years ago by dustin

warner, does this look OK? I don't have hg installed, and don't want to go down that particular rabbit hole, so I haven't committed it yet.

comment:7 in reply to: ↑ description Changed 5 years ago by even

  • Cc even added

comment:8 Changed 5 years ago by bsmedberg

I've tried this patch and have the following problem. If a pull occurs and there are no changes, the build fails, because the code in _handleEmptyUpdate is operating on the wrong command (the update command, instead of the pull command). I'm going to try and upload a patch in a bit.

comment:9 Changed 5 years ago by bsmedberg

  • Cc bsmedberg added

Changed 5 years ago by bsmedberg

patch for commands.py

comment:10 Changed 5 years ago by bsmedberg

The patch attached makes the following changes from the previous patch:

1) the ordering is doVCUpdate/_handleEmptyUpdate/_doUpdate 2) _doUpdate doesn't set self.command because AFAICT the only reason we set self.command was so _handleEmptyUpdate would have the correct command log to grep 3) when no revision is specified, explicitly specify 'default' to match the default behavior of a revision-less clone... if the previous checkout was on a branch, we want to revert to the default branch

comment:11 Changed 5 years ago by dustin

  • Keywords review added

comment:12 Changed 5 years ago by dustin

  • Keywords review removed
  • Milestone changed from undecided to 0.7.9

The first of these patches (Ben's) applies, but the second (bsmedberg) doesn't.

 http://repo.or.cz/w/buildbot.git?a=shortlog;h=refs/remotes/dustin/bug277

bsmedberg, can you update it?

comment:13 Changed 5 years ago by Pike

  • Cc Pike added

comment:14 Changed 5 years ago by even

The bsmedberg's patch includes the Ben's patch so if you tried to apply them one after one, the second one logically fail. I tried to apply the bsmedberg's patch on a 0.7.8 base and it applied without problem.

Changed 5 years ago by bsmedberg

Updated patch

comment:15 Changed 5 years ago by marcusl

  • Cc marcusl added

comment:16 Changed 5 years ago by even

  • Keywords review added
  • Version changed from 0.7.7 to 0.7.9
  • Milestone changed from 0.8.0 to 0.7.10

I marked that bug to be on the 0.7.10 Milestone since it has been waiting too long and that a lot of people looks like to be waiting for it (including me).

Adding keyword review since it should work now.

comment:17 Changed 4 years ago by dustin

  • Keywords review removed

in my branch

comment:18 Changed 4 years ago by even

Why did you let the bug open ? Is there a specific reason for it to stay unresolved ?

comment:19 Changed 4 years ago by dustin

  • Status changed from new to closed
  • Resolution set to fixed

nope, thanks

comment:20 Changed 4 years ago by dustin

  • Status changed from closed to reopened
  • Resolution fixed deleted

Actually, this change is failing tests on my system, so I've reverted it in my branch, but it's available at

 http://github.com/djmitche/buildbot/tree/bug277

if you want to fork the repository and hack on it. I'll attach test.log.

comment:21 Changed 4 years ago by dustin

  • Owner changed from warner to bsmedberg
  • Status changed from reopened to new

comment:22 Changed 4 years ago by marcusl

I did some related work when fixing #187, which has been merged. Perhaps someone could look at that and see how it works?

comment:23 follow-up: ↓ 24 Changed 4 years ago by dustin

I rebased my branch onto master and re-ran the tests, and I'm still seeing failures.

[FAIL]: buildbot.test.test_vc.MercurialInRepo.testCheckoutHTTP

Traceback (most recent call last):
  File "/home/dustin/devel/projects/buildbot/t/buildbot/buildbot/test/test_vc.py", line 546, in _do_vctest_clobber_1
    self.checkGotRevisionIsLatest(bs)
  File "/home/dustin/devel/projects/buildbot/t/buildbot/buildbot/test/test_vc.py", line 492, in checkGotRevisionIsLatest
    self.checkGotRevision(bs, expected)
  File "/home/dustin/devel/projects/buildbot/t/buildbot/buildbot/test/test_vc.py", line 486, in checkGotRevision
    self.failUnlessEqual(bs.getProperty("got_revision"), str(expected))
twisted.trial.unittest.FailTest: not equal:
a = '35bf7e302caf'
b = '33e6135447df'
===============================================================================
[ERROR]: buildbot.test.test_vc.MercurialInRepo.testCheckoutBranch

Traceback (most recent call last):
Failure: twisted.internet.defer.TimeoutError: <buildbot.test.test_vc.MercurialInRepo testMethod=testCheckoutBranch> (testCheckoutBranch) still running at 120.0 secs

There are more, but I think they're fallout from these failures.

comment:24 in reply to: ↑ 23 ; follow-up: ↓ 25 Changed 4 years ago by even

Replying to dustin:

I rebased my branch onto master and re-ran the tests, and I'm still seeing failures. There are more, but I think they're fallout from these failures.

Can we see the protocol of the failing test and the description of the expected result since I read the patch and started to believe that the test is wrong and not the patch.

comment:25 in reply to: ↑ 24 Changed 4 years ago by dustin

Replying to even:

Can we see the protocol of the failing test and the description of the expected result since I read the patch and started to believe that the test is wrong and not the patch.

I'm not sure what you mean by "protocol". The code is in

 http://github.com/djmitche/buildbot/commit/116e0808017f218abc57cf3bcfaff535572e1633

As for the expected results -- I don't know. Marcus?

comment:26 Changed 4 years ago by marcusl

dustin: I'll see if I can run som tests and see what happens.

even: The actual test class (MercurialInRepo?) is in buildbot/test/test_vc.py, but most of it happens in BaseHelper? in the same file.

comment:27 Changed 4 years ago by even

I'm reading the tests done on Mercurial and I'm starting to think that the whole thing looks inconsistent.

I can see in the code of the test that the whole branching is done using different directories (which is ugly since Mercurial has its own branching system, but I will let that aside since it has nothing to do with the current issue). What looks strange is in buildbot/test/test_vc.py line 2629. Since you are using directories to do the branching, why is there "inrepo" written there and not "dirname". I really don't understand the logic here.

I don't know if this is the reason for the whole thing failing though. It would really be great to have the complete log of the test (what commands are executed, what their result is, what the expected result was, etc) to know if the error is coming from the mercurial object or from the test.

Is it possible to retrieve those informations ?

comment:28 Changed 4 years ago by marcusl

Mercurial supports branches in two ways, inrepo or as separate dirs, so BuildBot supports both of these (with inrepo being the latest addition, that has received a lot of attention lately).

If you look at the tests in Dustin's repo, he has merged #187 which added extra support for inrepo branches and an extra testcase, (written by me, being the first real attempt at hacking BuildBot), that creates branches in the same repo then uses 'inrepo' to tell the Mercurial source step to work with that.

So, the MercurialInRepo? test ckass uses inrepo branches. The Mercurial class uses branch names.

Hope it clears things up.

comment:29 Changed 4 years ago by marcusl

Oh, and logging is available by uncommenting some lines at the top of test_vc.py, then re-running the tests.

comment:30 Changed 4 years ago by marcusl

The #277 fix didn't take the branch value into account, but always used 'default', which then made the testCheckoutBranch loop forever, as it failed to clobber back and find the correct repo.

I've attached a patch that fixes this. Basically, use my _update() which does 'hg identify --num --branch' before deciding to clobber or updating, instead of the provided _doUpdate().

I was a bit worried that we've uncovered another bug, namely eternal looping if a requested branch isn't found. But that causes '_update2' to fail instead. (I've checked this.)

Changed 4 years ago by marcusl

Fix #277 -patch to work with #187 fix

comment:31 Changed 4 years ago by even

  • Status changed from new to closed
  • Resolution set to fixed

Ok. That's why this one is failing. It can't just be applied on #187. But #187 already do what we want to do in this. No need to apply the given patch since update is called whatever. I'm closing this : changes needed are done in #187.

comment:32 Changed 4 years ago by marcusl

You're right. I didn't spot that I already did that.

Too much context switching lately. :)

comment:33 Changed 4 years ago by even

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Milestone changed from 0.7.10 to 0.7.11

A change in another bug makes me repon this bug. Since there's a really trivial patch to this, I'll post it in a few minutes.

Changed 4 years ago by even

Remove an useless test causing the bug.

comment:34 Changed 4 years ago by even

  • Cc fqueze added
  • Keywords review added

Here, I just added the patch I mentioned earlier. Also adding review keyword since I just tested it and it works well.

comment:35 Changed 4 years ago by marcusl

Right. That shouldn't be there. I actually thought this was fixed, so thanks for spotting it.

comment:36 Changed 4 years ago by marcusl

  • Status changed from reopened to closed
  • Resolution set to fixed

Fixed in  389f9c251b11:

    Fixes #277: Remove unnecessary test

@@ -2444,10 +2444,7 @@ class Mercurial(SourceBase):
         if os.path.exists(os.path.join(self.builder.basedir,
                                        self.srcdir, ".buildbot-patched")):
             return False
-        # like Darcs, to check out a specific (old) revision, we have to do a
-        # full checkout. TODO: I think 'hg pull' plus 'hg update' might work
-        if self.revision:
-            return False
+
         return os.path.isdir(os.path.join(self.builder.basedir,
                                           self.srcdir, ".hg"))
Note: See TracTickets for help on using tickets.