Patchwork tests: fix reference to undefined variable

login
register
mail settings
Submitter via Mercurial-devel
Date July 6, 2017, 9:20 p.m.
Message ID <3ba21e3240f233f061bd.1499376014@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22043/
State Accepted
Headers show

Comments

via Mercurial-devel - July 6, 2017, 9:20 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1499375822 25200
#      Thu Jul 06 14:17:02 2017 -0700
# Node ID 3ba21e3240f233f061bdeaee19e18414a4e00248
# Parent  f08a178adadfc36f3ce9c4e275227f8e39b3e750
tests: fix reference to undefined variable

The delaypush() function had a reference to "repo" that was clearly
supposed to be "pushop.repo". Instead of just fixing that, let's
extract "pushop.repo.ui" to a variable, since that's the only
piece of the repo that's needed in the function.

I have not looked into why I saw a different result in the test to
start with, but that's for another patch anyway.
Sean Farley - July 6, 2017, 10:49 p.m.
Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> writes:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1499375822 25200
> #      Thu Jul 06 14:17:02 2017 -0700
> # Node ID 3ba21e3240f233f061bdeaee19e18414a4e00248
> # Parent  f08a178adadfc36f3ce9c4e275227f8e39b3e750
> tests: fix reference to undefined variable
>
> The delaypush() function had a reference to "repo" that was clearly
> supposed to be "pushop.repo". Instead of just fixing that, let's
> extract "pushop.repo.ui" to a variable, since that's the only
> piece of the repo that's needed in the function.
>
> I have not looked into why I saw a different result in the test to
> start with, but that's for another patch anyway.

Great, queued!

Patch

diff --git a/tests/test-push-race.t b/tests/test-push-race.t
--- a/tests/test-push-race.t
+++ b/tests/test-push-race.t
@@ -27,21 +27,22 @@ 
   > 
   > def delaypush(orig, pushop):
   >     # notify we are done preparing
-  >     readypath = pushop.repo.ui.config('delaypush', 'ready-path', None)
+  >     ui = pushop.repo.ui
+  >     readypath = ui.config('delaypush', 'ready-path', None)
   >     if readypath is not None:
   >         with open(readypath, 'w') as r:
   >             r.write('foo')
-  >         pushop.repo.ui.status('wrote ready: %s\n' % readypath)
+  >         ui.status('wrote ready: %s\n' % readypath)
   >     # now wait for the other process to be done
-  >     watchpath = pushop.repo.ui.config('delaypush', 'release-path', None)
+  >     watchpath = ui.config('delaypush', 'release-path', None)
   >     if watchpath is not None:
-  >         pushop.repo.ui.status('waiting on: %s\n' % watchpath)
+  >         ui.status('waiting on: %s\n' % watchpath)
   >         limit = 100
   >         while 0 < limit and not os.path.exists(watchpath):
   >             limit -= 1
   >             time.sleep(0.1)
   >         if limit <= 0:
-  >             repo.ui.warn('exiting without watchfile: %s' % watchpath)
+  >             ui.warn('exiting without watchfile: %s' % watchpath)
   >         else:
   >             # delete the file at the end of the push
   >             def delete():