Rev 185: Merged PatchCommand work. in http://bzr.daniel-watkins.co.uk/pqm/tag

Daniel Watkins daniel at daniel-watkins.co.uk
Tue Jul 22 21:00:08 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/tag

------------------------------------------------------------
revno: 185
revision-id: daniel at daniel-watkins.co.uk-20080722195836-waxuq7vg3pcejsui
parent: daniel at daniel-watkins.co.uk-20080722195819-7w0aowx88rci80vv
parent: daniel at daniel-watkins.co.uk-20080722184357-1f1yi38i0zbi82pn
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: tag
timestamp: Tue 2008-07-22 20:58:36 +0100
message:
  Merged PatchCommand work.
modified:
  pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
  pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
  pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
  pqm/ui/tests/test_twisted.py   x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
    ------------------------------------------------------------
    revno: 182.2.31
    revision-id: daniel at daniel-watkins.co.uk-20080722184357-1f1yi38i0zbi82pn
    parent: daniel at daniel-watkins.co.uk-20080722183423-eapvg922g9ou8yck
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:43:57 +0100
    message:
      Fixed UI display of patch commands.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.30
    revision-id: daniel at daniel-watkins.co.uk-20080722183423-eapvg922g9ou8yck
    parent: daniel at daniel-watkins.co.uk-20080722182738-me0v1knbtrwodnq9
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:34:23 +0100
    message:
      Removed now un-needed do_patch from CommandRunner.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.29
    revision-id: daniel at daniel-watkins.co.uk-20080722182738-me0v1knbtrwodnq9
    parent: daniel at daniel-watkins.co.uk-20080722181939-b4rupgy8j6a8hshu
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:27:38 +0100
    message:
      Renamed confusingly named variable.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.28
    revision-id: daniel at daniel-watkins.co.uk-20080722181939-b4rupgy8j6a8hshu
    parent: daniel at daniel-watkins.co.uk-20080722181915-2e90z3wentgvby5n
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:19:39 +0100
    message:
      Fixed indentation in tests.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.27
    revision-id: daniel at daniel-watkins.co.uk-20080722181915-2e90z3wentgvby5n
    parent: daniel at daniel-watkins.co.uk-20080722180836-duk15azwrfjveity
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:19:15 +0100
    message:
      Extracted common test code to a helper method.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.26
    revision-id: daniel at daniel-watkins.co.uk-20080722180836-duk15azwrfjveity
    parent: daniel at daniel-watkins.co.uk-20080722180606-jin7oe29x63yhx8s
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:08:36 +0100
    message:
      Added test for backreferencing paths.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.25
    revision-id: daniel at daniel-watkins.co.uk-20080722180606-jin7oe29x63yhx8s
    parent: daniel at daniel-watkins.co.uk-20080722173426-7we2a37o6gbirsy2
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 19:06:06 +0100
    message:
      Fixed test.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.24
    revision-id: daniel at daniel-watkins.co.uk-20080722173426-7we2a37o6gbirsy2
    parent: daniel at daniel-watkins.co.uk-20080722172630-kumd4al0u7eaum6b
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 18:34:26 +0100
    message:
      Added test for patches with absolute paths, as well as fix thrown up by said test.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.23
    revision-id: daniel at daniel-watkins.co.uk-20080722172630-kumd4al0u7eaum6b
    parent: daniel at daniel-watkins.co.uk-20080722171533-4i9swhj7tkadfz2n
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 18:26:30 +0100
    message:
      Wrapped long lines.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.22
    revision-id: daniel at daniel-watkins.co.uk-20080722171533-4i9swhj7tkadfz2n
    parent: daniel at daniel-watkins.co.uk-20080720154125-l9swnh5sjv2taakp
    parent: daniel at daniel-watkins.co.uk-20080722171149-aut0g1391q5zdpjv
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Tue 2008-07-22 18:15:33 +0100
    message:
      Merged TestCaseWithQueue changes.
    modified:
      pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.12
        revision-id: daniel at daniel-watkins.co.uk-20080722171149-aut0g1391q5zdpjv
        parent: daniel at daniel-watkins.co.uk-20080722170203-rr1mr5tlq1vxm9x6
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Tue 2008-07-22 18:11:49 +0100
        message:
          Fixed failing tests.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.11
        revision-id: daniel at daniel-watkins.co.uk-20080722170203-rr1mr5tlq1vxm9x6
        parent: daniel at daniel-watkins.co.uk-20080717104404-m2mkd8o1luidl0s0
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Tue 2008-07-22 18:02:03 +0100
        message:
          Converted TestCaseWithQueue to subclass bzrlib.tests.TestCaseWithTransport.
        modified:
          pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.21
    revision-id: daniel at daniel-watkins.co.uk-20080720154125-l9swnh5sjv2taakp
    parent: daniel at daniel-watkins.co.uk-20080720153107-cstlnsfbvuey2opo
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 16:41:25 +0100
    message:
      Added test for nonsense patch input.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.20
    revision-id: daniel at daniel-watkins.co.uk-20080720153107-cstlnsfbvuey2opo
    parent: daniel at daniel-watkins.co.uk-20080720151321-6rw3owxyorfqqe89
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 16:31:07 +0100
    message:
      Added test for valid patch input.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.19
    revision-id: daniel at daniel-watkins.co.uk-20080720151321-6rw3owxyorfqqe89
    parent: daniel at daniel-watkins.co.uk-20080720145015-keiwgsunyso3uxfn
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 16:13:21 +0100
    message:
      Removed now unnecessary cleanup from queue test stuff.
    modified:
      pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
    ------------------------------------------------------------
    revno: 182.2.18
    revision-id: daniel at daniel-watkins.co.uk-20080720145015-keiwgsunyso3uxfn
    parent: daniel at daniel-watkins.co.uk-20080720144232-7awjf34ecez4pnnl
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 15:50:15 +0100
    message:
      Abstracted config creation.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.17
    revision-id: daniel at daniel-watkins.co.uk-20080720144232-7awjf34ecez4pnnl
    parent: daniel at daniel-watkins.co.uk-20080720143643-hsglti92y3i1p68z
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 15:42:32 +0100
    message:
      Working test for empty patch content.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.16
    revision-id: daniel at daniel-watkins.co.uk-20080720143643-hsglti92y3i1p68z
    parent: daniel at daniel-watkins.co.uk-20080720135622-0g07e2i4hpas5m89
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 15:36:43 +0100
    message:
      Nearer to working tests.
    modified:
      pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.15
    revision-id: daniel at daniel-watkins.co.uk-20080720135622-0g07e2i4hpas5m89
    parent: daniel at daniel-watkins.co.uk-20080720135450-oy11dliev8n9etb4
    parent: daniel at daniel-watkins.co.uk-20080717104404-m2mkd8o1luidl0s0
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 14:56:22 +0100
    message:
      Merged TestCaseWithQueue work.
    modified:
      pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
      pqm/ui/tests/test_twisted.py   x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
        ------------------------------------------------------------
        revno: 176.1.10
        revision-id: daniel at daniel-watkins.co.uk-20080717104404-m2mkd8o1luidl0s0
        parent: daniel at daniel-watkins.co.uk-20080717102329-dnul7uxcu03b5bih
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-17 11:44:04 +0100
        message:
          Fixed up as per lifeless' review comments.
        modified:
          pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
        ------------------------------------------------------------
        revno: 176.1.9
        revision-id: daniel at daniel-watkins.co.uk-20080717102329-dnul7uxcu03b5bih
        parent: daniel at daniel-watkins.co.uk-20080710164650-dd3c037m6wah8yuq
        parent: robertc at robertcollins.net-20080717100934-40fjde09nglggsub
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-17 11:23:29 +0100
        message:
          Merged pqm.dev r182.
        added:
          pqm/commandline.py             commandline.py-20080416102158-op31dy0lnkeo91ww-1
          pqm/errors.py                  errors.py-20080528044209-lpacj0a0ub4woseh-1
          pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
          pqm/tests/test_commandline.py  test_commandline.py-20080416102209-p18w8m9sw21704j9-1
        modified:
          .bzrignore                     bzrignore-20060322120158-35e5bcdaf76b6fdf
          Makefile.am                    i_Automake_rules_for_toplevel_tla-pqm_directory
          bin/pqm                        i_Simple_patch_queue_manager_for_tla
          configure.ac                   i_Toplevel_Autoconf_configuration_script
          pqm/__init__.py                i_dc99ede3-0c64-434d-ac84-305c06455a8d
          pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
          pqm/tests/test_lockfile.py     test_lockfile.py-20060111035725-07e8b573302c8fef
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
          pqm/ui/tests/test_twisted.py   x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
          pqm/ui/twistd.py               x_Robert_Collins_<robert.collins at canonical.com>_Sun_Jul_10_02:00:08_2005_15556.0
        ------------------------------------------------------------
        revno: 176.1.8
        revision-id: daniel at daniel-watkins.co.uk-20080710164650-dd3c037m6wah8yuq
        parent: daniel at daniel-watkins.co.uk-20080710164337-y4962o5sczz0tqv7
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:46:50 +0100
        message:
          Converted TestTwistedUI to subclass TestCaseWithQueue.
        modified:
          pqm/ui/tests/test_twisted.py   x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
        ------------------------------------------------------------
        revno: 176.1.7
        revision-id: daniel at daniel-watkins.co.uk-20080710164337-y4962o5sczz0tqv7
        parent: daniel at daniel-watkins.co.uk-20080710164201-zmw1dgimft79nd1f
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:43:37 +0100
        message:
          Import cleanup.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
          pqm/ui/tests/test_twisted.py   x_Robert_Collins_<robert.collins at canonical.com>_Sat_Jul__9_22:36:13_2005_7873.0
        ------------------------------------------------------------
        revno: 176.1.6
        revision-id: daniel at daniel-watkins.co.uk-20080710164201-zmw1dgimft79nd1f
        parent: daniel at daniel-watkins.co.uk-20080710163552-maaev5jnyg7iyp3h
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:42:01 +0100
        message:
          Converted TestWithQueueDirectory to subclass TestCaseWithQueue.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.5
        revision-id: daniel at daniel-watkins.co.uk-20080710163552-maaev5jnyg7iyp3h
        parent: daniel at daniel-watkins.co.uk-20080710162506-tpi33egh01pu79tg
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:35:52 +0100
        message:
          Removed need for scriptname to be a instance variable.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.4
        revision-id: daniel at daniel-watkins.co.uk-20080710162506-tpi33egh01pu79tg
        parent: daniel at daniel-watkins.co.uk-20080710161953-ohx24ca1c88s9m0j
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:25:06 +0100
        message:
          Added pqm.tests.TestCaseWithQueue.
        modified:
          pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.3
        revision-id: daniel at daniel-watkins.co.uk-20080710161953-ohx24ca1c88s9m0j
        parent: daniel at daniel-watkins.co.uk-20080710160216-hazgu51bbkw9fums
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: TestCaseWithQueue
        timestamp: Thu 2008-07-10 17:19:53 +0100
        message:
          Moved QueueSetup to pqm.tests.QueueSetup.
        modified:
          pqm/tests/__init__.py          i_74708178-eda5-4993-8549-5eddd090ce8e
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.2
        revision-id: daniel at daniel-watkins.co.uk-20080710160216-hazgu51bbkw9fums
        parent: daniel at daniel-watkins.co.uk-20080710155822-i9toa3rw19sp0pt2
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: empty-queue
        timestamp: Thu 2008-07-10 17:02:16 +0100
        message:
          Added 'empty' parameter to QueueSetup, to define whether there should be anything in the queue.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
        ------------------------------------------------------------
        revno: 176.1.1
        revision-id: daniel at daniel-watkins.co.uk-20080710155822-i9toa3rw19sp0pt2
        parent: robertc at robertcollins.net-20080710074340-dl0w25nbutl88sz2
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: empty-queue
        timestamp: Thu 2008-07-10 16:58:22 +0100
        message:
          Added processing option on QueueSetup, to define whether any further queue requests are being processed.
        modified:
          pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.14
    revision-id: daniel at daniel-watkins.co.uk-20080720135450-oy11dliev8n9etb4
    parent: daniel at daniel-watkins.co.uk-20080720134321-to8fhvf6c86925ha
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 14:54:50 +0100
    message:
      Initial PatchCommand tests.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.13
    revision-id: daniel at daniel-watkins.co.uk-20080720134321-to8fhvf6c86925ha
    parent: daniel at daniel-watkins.co.uk-20080720134245-k4s920f01wodi7xe
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 14:43:21 +0100
    message:
      Updated docs.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.12
    revision-id: daniel at daniel-watkins.co.uk-20080720134245-k4s920f01wodi7xe
    parent: daniel at daniel-watkins.co.uk-20080719232528-o8geu9zoqgv75zbt
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 14:42:45 +0100
    message:
      Removed debugging statement.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.11
    revision-id: daniel at daniel-watkins.co.uk-20080719232528-o8geu9zoqgv75zbt
    parent: daniel at daniel-watkins.co.uk-20080719231943-8dlsumcdq1gw4jcy
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 00:25:28 +0100
    message:
      Changed test name.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.10
    revision-id: daniel at daniel-watkins.co.uk-20080719231943-8dlsumcdq1gw4jcy
    parent: daniel at daniel-watkins.co.uk-20080719230130-0pbzmgf1ba83h5ml
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 00:19:43 +0100
    message:
      Fixed accidental addition of CommandRunner to the start of every script.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.9
    revision-id: daniel at daniel-watkins.co.uk-20080719230130-0pbzmgf1ba83h5ml
    parent: daniel at daniel-watkins.co.uk-20080719225717-4v1k78wz4y56ug7t
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sun 2008-07-20 00:01:30 +0100
    message:
      Minor cleanup.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.8
    revision-id: daniel at daniel-watkins.co.uk-20080719225717-4v1k78wz4y56ug7t
    parent: daniel at daniel-watkins.co.uk-20080718174453-u4kxy00lc3w4nk18
    parent: daniel at daniel-watkins.co.uk-20080718121005-7lggidjfd1h28cyu
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Sat 2008-07-19 23:57:17 +0100
    message:
      Merged test fixes.
    modified:
      pqm/tests/test_pqm.py          x_Robert_Collins_<robert.collins at canonical.com>_Thu_Aug__4_22:52:41_2005_804.0
    ------------------------------------------------------------
    revno: 182.2.7
    revision-id: daniel at daniel-watkins.co.uk-20080718174453-u4kxy00lc3w4nk18
    parent: daniel at daniel-watkins.co.uk-20080718172252-xg48dt8p1j4o268z
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 18:44:53 +0100
    message:
      Patching will now actually work.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.6
    revision-id: daniel at daniel-watkins.co.uk-20080718172252-xg48dt8p1j4o268z
    parent: daniel at daniel-watkins.co.uk-20080718165818-b2a6ltt7efh8cind
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 18:22:52 +0100
    message:
      Rough pass at complete PatchCommand.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.5
    revision-id: daniel at daniel-watkins.co.uk-20080718165818-b2a6ltt7efh8cind
    parent: daniel at daniel-watkins.co.uk-20080718164423-94e1d8rdwy16k74p
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 17:58:18 +0100
    message:
      Started implementation of PatchCommand.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.4
    revision-id: daniel at daniel-watkins.co.uk-20080718164423-94e1d8rdwy16k74p
    parent: daniel at daniel-watkins.co.uk-20080718163204-i8nf9bmt8w2ae7jx
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 17:44:23 +0100
    message:
      Further work on hooking up Script.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.3
    revision-id: daniel at daniel-watkins.co.uk-20080718163204-i8nf9bmt8w2ae7jx
    parent: daniel at daniel-watkins.co.uk-20080718161928-o9nrkjsokjqxb9a8
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 17:32:04 +0100
    message:
      Add patch handling to Script.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.2
    revision-id: daniel at daniel-watkins.co.uk-20080718161928-o9nrkjsokjqxb9a8
    parent: daniel at daniel-watkins.co.uk-20080718152450-lxo4lcokpg2t37po
    parent: daniel at daniel-watkins.co.uk-20080718122827-alrsl33wdlnjgmkt
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: abstract-patch
    timestamp: Fri 2008-07-18 17:19:28 +0100
    message:
      Merged nodebug stuff.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
        ------------------------------------------------------------
        revno: 182.3.2
        revision-id: daniel at daniel-watkins.co.uk-20080718122827-alrsl33wdlnjgmkt
        parent: daniel at daniel-watkins.co.uk-20080718122355-u7ooqqrv2q0nh91s
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: nodebug
        timestamp: Fri 2008-07-18 13:28:27 +0100
        message:
          nodebug commands should now function correctly.
        modified:
          pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
        ------------------------------------------------------------
        revno: 182.3.1
        revision-id: daniel at daniel-watkins.co.uk-20080718122355-u7ooqqrv2q0nh91s
        parent: robertc at robertcollins.net-20080717100934-40fjde09nglggsub
        committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
        branch nick: nodebug
        timestamp: Fri 2008-07-18 13:23:55 +0100
        message:
          Added NoDebugCommand.
        modified:
          pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
    ------------------------------------------------------------
    revno: 182.2.1
    revision-id: daniel at daniel-watkins.co.uk-20080718152450-lxo4lcokpg2t37po
    parent: robertc at robertcollins.net-20080717100934-40fjde09nglggsub
    committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
    branch nick: 42866
    timestamp: Fri 2008-07-18 16:24:50 +0100
    message:
      Some UI niceification in CommandRunner.
    modified:
      pqm/script.py                  script.py-20080528044209-lpacj0a0ub4woseh-2
-------------- next part --------------
=== modified file 'pqm/script.py'
--- a/pqm/script.py	2008-07-22 19:58:19 +0000
+++ b/pqm/script.py	2008-07-22 19:58:36 +0000
@@ -82,6 +82,8 @@
     star_re = re.compile('^star-merge (\S+/\S+)\s+(\S+/\S+)\s*$')
     # parse matcher for the debug command
     debug_re = re.compile('^debug')
+    nodebug_re = re.compile('^nodebug')
+    patch_re = re.compile('^patch (\S+/\S+)\s*$')
 
     def __init__(self, filename, logger, verify_sigs, submission_time,
                  branch_spec_handler, configp, keyring=None):
@@ -172,21 +174,25 @@
         """Get the actual command lines from the script."""
         self.logger.info("parsing commands")
         result = []
-        legacy_lines = []
+        accumulating_lines = []
+        accumulating_patch = None
         for line in self.getLines():
             if not self.isCommand(line):
                 continue
             # identify and construct commands
             star_match = Script.star_re.match(line)
             debug_match = Script.debug_re.match(line)
-            any_match = star_match or debug_match
-            if any_match and legacy_lines:
-                result.append(CommandRunner(self,
-                                            self._branch_spec_handler,
-                                            self._configp,
-                                            legacy_lines,
-                                            ))
-                legacy_lines = []
+            nodebug_match = Script.nodebug_re.match(line)
+            patch_match = Script.patch_re.match(line)
+            command_match = (star_match or debug_match or nodebug_match
+                            or patch_match)
+            if command_match:
+                if accumulating_lines:
+                    result.append(
+                        self.get_accumulating_command(accumulating_patch,
+                                                      accumulating_lines))
+                accumulating_lines = []
+                accumulating_patch = None
             if star_match:
                 result.append(MergeCommand(self,
                                            self._branch_spec_handler,
@@ -197,15 +203,29 @@
                 result.append(DebugCommand(self,
                                            self._branch_spec_handler,
                                            self._configp))
+            elif nodebug_match:
+                result.append(NoDebugCommand(self,
+                                             self._branch_spec_handler,
+                                             self._configp))
+            elif patch_match:
+                accumulating_patch = patch_match.group(1)
             else:
-                legacy_lines.append(line)
-        if legacy_lines:
-            result.append(CommandRunner(self,
-                                        self._branch_spec_handler,
-                                        self._configp,
-                                        legacy_lines))
+                accumulating_lines.append(line)
+        if accumulating_lines:
+            result.append(
+                self.get_accumulating_command(accumulating_patch,
+                                              accumulating_lines))
+
         return result
 
+    def get_accumulating_command(self, patch, lines):
+        if patch is not None:
+            return PatchCommand(self, self._branch_spec_handler, self._configp,
+                                lines, patch)
+        else:
+            return CommandRunner(self, self._branch_spec_handler, self._configp,
+                                 lines)
+
     def getSubmissionTime(self):
         """Return the time the script was submitted."""
         return self.submission_time
@@ -614,6 +634,142 @@
         return ['debug'], [], ['Debug mode enabled.']
 
 
+class NoDebugCommand(Command):
+    """Turns off debug mode."""
+
+    def asHTML(self):
+        return "nodebug"
+
+    def getProjects(self):
+        """Nodebug applies to no projects."""
+        return set()
+
+    def run(self):
+        """Turn debug mode off."""
+        super(NoDebugCommand, self).run()
+        self.script.debug = False
+        return ['nodebug'], [], ['Debug mode disabled.']
+
+
+class PatchCommand(Command):
+    """Apply a patch."""
+
+    def __init__(self, script, branch_spec_handler, configp, lines,
+                 target_branch):
+        """Construct a patch command.
+
+        :param lines: A list containing the lines of the patch.
+        :param target_branch: The branch to apply the patch to.
+        """
+        super(PatchCommand, self).__init__(script, branch_spec_handler,
+                                           configp)
+        self.target_branch = target_branch
+        self.line = "patch %s" % (self.target_branch,)
+        self.patch_content = lines
+        self.script.logger.info("patch content found, target: %s",
+                                target_branch)
+
+    def asHTML(self):
+        return cgi.escape("Patch for %s" % self.target_branch)
+
+    def getProjects(self):
+        b, config = self.getBranchConfig(self.target_branch)
+        project = config['project']
+        if project is not None:
+            return set([project])
+        else:
+            return set()
+
+    def run(self):
+        super(PatchCommand, self).run()
+        self.cleanup_wd()
+        self.check_target(self.target_branch, self.line)
+        start_time = datetime.now()
+        self.patch_target, config = self.getBranchConfig(self.target_branch)
+        self.set_current_vcs(self.patch_target)
+        self.validate_revision(self.patch_target)
+        self.script.logger.info("getting working dir for %s", self.patch_target)
+        origdir = os.getcwd()
+        dir = self.get_wd(self.script.getSender(),
+                          self.patch_target,
+                          config)
+        try:
+            os.chdir(dir)
+            try:
+                self.output += ['\n']
+                (summary, moreoutput) = self.do_patch(self.script.getSender(),
+                                                      self.patch_content)
+                self.output += moreoutput
+                self.output += ['\n']
+            except PQMTlaFailure, e:
+                raise PQMCmdFailure(self.script.getSender(),
+                                    self.successful,
+                                    'patch ' + self.patch_target,
+                                    self.output + e.output)
+        except:
+            os.chdir(origdir)
+            raise
+        self.script.logger.info("executing patch")
+        self.run_precommit(self.patch_target, config, self.line, dir)
+        self.successful.append('patch ' + self.patch_target)
+        self.output += self._success_output('patch', start_time)
+        os.chdir(origdir)
+        self.get_vcs().commit(self.script.getSender(), dir, summary,
+                              self.patch_target, config)
+        return self.line, [], self.output
+
+    def do_patch(self, sender, content):
+        # TODO: Tim Penhey, 2008-05-28
+        # Get rid of the imports from pqm module itself.
+        from pqm import gnupatch_path, popen_noshell_with_input
+
+        def is_patchline(line):
+            return line != '' and (line[0] in ('+', '-') or line[0:2] == '@@')
+        if content == []:
+            raise PQMException(self.sender, "Empty patch content")
+        if not is_patchline(content[0]):
+            summary = content[0]
+        else:
+            raise PQMException(self.sender, "No summary given for patch")
+        filenames = []
+        for line in content:
+            if line[0:4] in ('+++ ', '--- '):
+                # We intentionally include the date, etc - stripping it out
+                # is too hard and error-prone
+                filenames.insert(0, line[4:].strip())
+        for filename in filenames:
+            if (filename.find('/..') > 0) or (filename.find('../') > 0):
+                msg = ("Invalid backreferencing filename in patch: %s"
+                        % (filename,))
+                raise PQMException(self.sender, msg)
+            elif filename[0] == '/':
+                msg = "Invalid absolute filename in patch: %s" % (filename,)
+                raise PQMException(self.sender, msg)
+        fd = self.write_lines_to_fd(content)
+        status, msg, output = \
+            popen_noshell_with_input(gnupatch_path, fd, '-p1', '--batch',
+                                     '--no-backup-if-mismatch')
+        os.close(fd)
+        if not ((status is None) or (status == 0)):
+            err = "patch command \"%s\" failed (%s): %s" % (gnupatch_path,
+                                                            status,
+                                                            msg)
+            raise PQMException(self.sender, [err] + output)
+        return (summary, output)
+
+    def write_lines_to_fd(self, lines):
+        (stdin, stdout) = os.pipe()
+        pid = os.fork()
+        if pid != 0:
+            os.close(stdout)
+            return stdin
+        os.close(stdin)
+        for line in lines:
+            os.write(stdout, line)
+            os.write(stdout, '\n')
+        os._exit(0)
+
+
 class MergeCommand(Command):
     """A merge request."""
 
@@ -771,14 +927,11 @@
     make_repo_re = re.compile('^make-repo (\S+)\s+(\S+)\s*$')
     create_branch_re = re.compile('^create-branch (\S+/\S+)\s+(\S+/\S+)\s*$')
     create_version_re = re.compile('^create-version (\S+/\S+)\s*$')
-    patch_re = re.compile('^patch (\S+/\S+)\s*$')
 
     def asHTML(self):
         """Return an HTML representation of the command."""
-        result = ''
-        for line in self.lines:
-            result += cgi.escape(line)
-        return result
+        result = [cgi.escape(s) for s in self.lines]
+        return "<pre>%s</pre>" % ("<br>".join(result),)
 
     def __eq__(self, other):
         return (super(CommandRunner, self).__eq__(other) and
@@ -803,50 +956,14 @@
         super(CommandRunner, self).run()
         self.cleanup_wd()
         self.accumulating_patch = False
-        self.patch_target = None
-        self.patch_content = []
         for line in self.lines:
             self.run_command(line)
-        if self.patch_content != []:
-            start_time = datetime.now()
-            self.patch_target, config = self.getBranchConfig(self.patch_target)
-            self.set_current_vcs(self.patch_target)
-            self.validate_revision(self.patch_target)
-            self.script.logger.info("getting working dir for %s", self.patch_target)
-            origdir = os.getcwd()
-            dir = self.get_wd(self.script.getSender(),
-                              self.patch_target,
-                              config)
-            try:
-                os.chdir(dir)
-                try:
-                    self.output += ['\n']
-                    (summary, moreoutput) = self.do_patch(self.script.getSender(),
-                                                          self.patch_content)
-                    self.output += moreoutput
-                    self.output += ['\n']
-                except PQMTlaFailure, e:
-                    raise PQMCmdFailure(self.script.getSender(),
-                                        self.successful,
-                                        'patch ' + self.patch_target,
-                                        self.output + e.output)
-            except:
-                os.chdir(origdir)
-                raise
-            self.script.logger.info("executing patch")
-            self.run_precommit(self.patch_target, config, line, dir)
-            self.successful.append('patch ' + self.patch_target)
-            self.output += self._success_output('patch', start_time)
-            os.chdir(origdir)
-            self.get_vcs().commit(self.script.getSender(), dir, summary,
-                                  self.patch_target, config)
         self.cleanup_wd()
         return (self.successful, self.unrecognized, self.output)
 
     def run_command(self, line):
         # its a command of some sort
         start_time = datetime.now()
-        patch_match = self.patch_re.match(line)
         replay_match = self.replay_re.match(line)
         repo_cache_match=self.repo_cache_re.match(line)
         repo_uncache_match=self.repo_uncache_re.match(line)
@@ -856,15 +973,7 @@
         create_version_match=self.create_version_re.match(line)
         logger = self.script.logger
 
-        if patch_match:
-            # GNU Patch
-            logger.info("patch content found, target: %s", patch_match.group(1))
-            self.patch_target = patch_match.group(1)
-            self.check_target(self.patch_target, line)
-            self.accumulating_patch = True
-        elif self.accumulating_patch:
-            self.patch_content.append(line)
-        elif replay_match:
+        if replay_match:
             self.do_merge(from_repo_revision=replay_match.group(1),
                           to_repo_revision=replay_match.group(2),
                           merge_name='replay',
@@ -995,44 +1104,5 @@
         else:
             self.unrecognized.append(line)
 
-    def write_lines_to_fd(self, lines):
-        (stdin, stdout) = os.pipe()
-        pid = os.fork()
-        if pid != 0:
-            os.close(stdout)
-            return stdin
-        os.close(stdin)
-        for line in lines:
-            os.write(stdout, line)
-            os.write(stdout, '\n')
-        os._exit(0)
-
-    def do_patch(self, sender, content):
-        # TODO: Tim Penhey, 2008-05-28
-        # Get rid of the imports from pqm module itself.
-        from pqm import gnupatch_path, popen_noshell_with_input
-
-        def is_patchline(line):
-            return line != '' and (line[0] in ('+', '-') or line[0:2] == '@@')
-        if content == []:
-            raise PQMException(self.sender, "Empty patch content")
-        if not is_patchline(content[0]):
-            summary = content[0]
-        else:
-            raise PQMException(self.sender, "No summary given for patch")
-        filenames = []
-        for line in content:
-            if line[0:4] in ('+++ ', '--- '):
-                # We intentionally include the date, etc - stripping it out is too hard and error-prone
-                filenames.insert(0, line[4:].strip())
-        for filename in filenames:
-            if (filename.find('/..') > 0) or (filename.find('../') > 0):
-                raise PQMException(self.sender, "Invalid backreferencing filename in patch: %s", filename)
-            elif filename[0] == '/':
-                raise PQMException(self.sender, "Invalid absolute filename in patch: %s", filename)
-        fd = self.write_lines_to_fd(content)
-        (status, msg, output) = popen_noshell_with_input(gnupatch_path, fd, '-p1', '--batch', '--no-backup-if-mismatch')
-        os.close(fd)
-        if not ((status is None) or (status == 0)):
-            raise PQMException(self.sender, ["patch command \"%s\" failed (%s): %s" % (gnupatch_path, status, msg)] + output)
-        return (summary, output)
+    def getProjects(self):
+        return set()

=== modified file 'pqm/tests/__init__.py'
--- a/pqm/tests/__init__.py	2006-01-11 03:58:41 +0000
+++ b/pqm/tests/__init__.py	2008-07-22 17:15:33 +0000
@@ -0,0 +1,81 @@
+import os
+import shutil
+from textwrap import dedent
+
+from bzrlib.tests import TestCaseWithTransport
+
+
+sample_message = dedent("""\
+    From: John.Citizen at example.com
+    Subject: A new action
+    star-merge http://www.example.com/foo/bar http://www.example.com/bar/baz
+    """)
+
+sample_message_2 = dedent("""\
+    From: John.Citizen at example.com
+    Subject: A new action
+    star-merge http://www.example.com/qux/thud http://www.example.com/fred/waldo
+    """)
+
+sample_message_bad = dedent("""\
+    From: John.Citizen at example.com
+    Subject: A new action
+    star-merge http://www.example.com/foo/bar http://www.example.com/foo/unregistered
+    """)
+
+
+class QueueSetup(object):
+    """Setup a queue with mock messages in it."""
+
+    def __init__(self, processing=True, empty=False):
+        self.configFileName = "Foo"
+        self.cwd = os.path.abspath(os.path.curdir)
+        self.processing = processing
+        self.empty = empty
+        if not empty:
+            self.message = sample_message
+            self.message_bad = sample_message_bad
+            self.message3 = sample_message_2
+
+    def setUp(self):
+        myFile=open(self.configFileName, "w")
+        myFile.write(dedent("""\
+            [DEFAULT]
+            queuedir=%s/queue
+            [http://www.example.com/bar/baz]
+            project=project
+            [http://www.example.com/fred/waldo]
+            """ % self.cwd))
+        myFile.close()
+        self.queuedir = os.path.join(self.cwd, "queue")
+        try:
+            os.mkdir(self.queuedir)
+            os.mkdir(self.queuedir + '/pqm')
+        except OSError:
+            pass
+        if not self.processing:
+            open("%s/stop.patch" % (self.queuedir,), "w").close()
+        if not self.empty:
+            self.messageFileName = os.path.join(self.queuedir,
+                                                "patch.00000001")
+            messageFile = open(self.messageFileName, "w")
+            messageFile.write(self.message)
+            messageFile.close()
+            self.messageFileNameBad = os.path.join(self.queuedir,
+                                                   "patch.00000002")
+            messageFile = open(self.messageFileNameBad, "w")
+            messageFile.write(self.message_bad)
+            messageFile.close()
+            self.messageFileName3 = os.path.join(self.queuedir,
+                                                 "patch.00000003")
+            messageFile = open(self.messageFileName3, "w")
+            messageFile.write(self.message3)
+            messageFile.close()
+
+
+class TestCaseWithQueue(TestCaseWithTransport):
+
+    def getQueue(self, processing=True, empty=False):
+        queue = QueueSetup(processing, empty)
+        queue.setUp()
+        return queue

=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-18 12:10:05 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-22 18:19:39 +0000
@@ -9,25 +9,21 @@
 from twisted.trial import unittest
 
 import pqm
-from pqm.errors import PQMCmdFailure
+from pqm.tests import (sample_message,
+                       sample_message_2,
+                       sample_message_bad,
+                       TestCaseWithQueue,
+                      )
+
+from pqm.errors import PQMCmdFailure, PQMException
 from pqm.PQMConfigParser import ConfigParser
-from pqm.script import Command, CommandRunner, DebugCommand, MergeCommand
+from pqm.script import (Command,
+                        CommandRunner,
+                        DebugCommand,
+                        MergeCommand,
+                        PatchCommand,
+                       )
 
-sample_message = dedent("""\
-    From: John.Citizen at example.com
-    Subject: A new action
-    star-merge http://www.example.com/foo/bar http://www.example.com/bar/baz
-    """)
-sample_message_2 = dedent("""\
-    From: John.Citizen at example.com
-    Subject: A new action
-    star-merge http://www.example.com/qux/thud http://www.example.com/fred/waldo
-    """)
-sample_message_bad = dedent("""\
-    From: John.Citizen at example.com
-    Subject: A new action
-    star-merge http://www.example.com/foo/bar http://www.example.com/foo/unregistered
-    """)
 sample_signed_message = dedent("""\
     From: whee at bar.com (Matthew Thomas)
     Subject: [trivial] fix various actions portlet icons
@@ -115,83 +111,24 @@
     """)
 
 
-class QueueSetup(object):
-    """Setup a queue with mock messages in it."""
-
-    def __init__(self):
-        self.configFileName = "Foo"
-        self.cwd = os.path.abspath(os.path.curdir)
-        self.message = sample_message
-        self.message_bad = sample_message_bad
-        self.message3 = sample_message_2
-
-    def setUp(self):
-        myFile=open(self.configFileName, "w")
-        myFile.write(dedent("""\
-            [DEFAULT]
-            queuedir=%s/queue
-            [http://www.example.com/bar/baz]
-            project=project
-            [http://www.example.com/fred/waldo]
-            """) % self.cwd)
-        myFile.close()
-        self.queuedir = os.path.join(self.cwd, "queue")
-        try:
-            os.mkdir(self.queuedir)
-            os.mkdir(self.queuedir + '/pqm')
-        except OSError:
-            pass
-        self.messageFileName = os.path.join(self.queuedir, "patch.00000001")
-        messageFile = open(self.messageFileName, "w")
-        messageFile.write(self.message)
-        messageFile.close()
-        self.messageFileNameBad = os.path.join(self.queuedir, "patch.00000002")
-        messageFile = open(self.messageFileNameBad, "w")
-        messageFile.write(self.message_bad)
-        messageFile.close()
-        self.messageFileName3 = os.path.join(self.queuedir, "patch.00000003")
-        messageFile = open(self.messageFileName3, "w")
-        messageFile.write(self.message3)
-        messageFile.close()
-
-    def tearDown(self):
-        os.unlink(self.configFileName)
-        shutil.rmtree(self.queuedir, ignore_errors=True)
-
-
-class TestWithQueueDirectory(unittest.TestCase):
-
-    def setUp(self):
-        unittest.TestCase.setUp(self)
-        self.queue = QueueSetup()
-        self.queue.setUp()
+class TestWithQueueDirectory(TestCaseWithQueue):
 
     def testName(self):
         patch = pqm.Script('foo.script', logging, False, 0, None, None)
         self.assertEqual(patch.filename, 'foo.script')
-        self.scriptname = 'fpp'
-
-    def tearDown(self):
-        try:
-            os.unlink(self.scriptname)
-        except OSError:
-            pass
-        self.queue.tearDown()
-
-    def getScript(self, content):
+
+    def getScript(self, queue, content):
         """Get a script for testing with."""
-        self.scriptname = 'foo.script'
-        scriptFile = open(self.scriptname, "w")
-        scriptFile.write(content)
-        scriptFile.close()
+        self.build_tree_contents([('foo.script', content)])
         pqm.pqm_subdir = os.path.abspath('queue/pqm')
         configp = ConfigParser()
-        configp.read([self.queue.configFileName])
+        configp.read([queue.configFileName])
         handler = pqm.BranchSpecOptionHandler(configp)
-        return pqm.Script(self.scriptname, logging, False, 54, handler, configp)
+        return pqm.Script('foo.script', logging, False, 54, handler, configp)
 
     def testFields(self):
-        script = self.getScript(sample_message)
+        queue = self.getQueue()
+        script = self.getScript(queue, sample_message)
         self.assertEqual(script.getSender(), "John.Citizen at example.com")
         self.assertEqual(script.getSubject(), "A new action")
         self.assertEqual(script.getContent(),
@@ -208,7 +145,8 @@
                          script.getCommands())
 
     def testGPGFields(self):
-        script = self.getScript(sample_signed_message)
+        queue = self.getQueue()
+        script = self.getScript(queue, sample_signed_message)
         self.assertEqual(script.getSender(), "whee at bar.com (Matthew Thomas)")
         self.assertEqual(script.getSubject(),
             "[trivial] fix various actions portlet icons")
@@ -238,27 +176,30 @@
 
     def testDate(self):
         """Can we access a submission time for scripts."""
-        script = self.getScript(sample_message)
+        queue = self.getQueue()
+        script = self.getScript(queue, sample_message)
         self.assertEqual(script.getSubmissionTime(), 54)
 
     def testProjects(self):
         # A script may affect multiple branches, so we can ask the script
         # for its projects, and then for the commands for a project.
-        script = self.getScript(sample_message)
+        queue = self.getQueue()
+        script = self.getScript(queue, sample_message)
         self.assertEqual(set(['project']), script.getProjects())
 
     def test_log_status(self):
         # make an initial status file
-        status = file(self.queue.queuedir + '/pqm/status', 'wt')
+        queue = self.getQueue()
+        status = file(queue.queuedir + '/pqm/status', 'wt')
         status.write('bar\n')
         status.close()
-        script = self.getScript(sample_message)
+        script = self.getScript(queue, sample_message)
         command = Command(script,
                           script._branch_spec_handler,
                           script._configp)
         logger = MockLogger()
         command.log_with_status(logger, 'foo')
-        content = file(self.queue.queuedir + '/pqm/status').read()
+        content = file(queue.queuedir + '/pqm/status').read()
         self.assertEqual('bar\nfoo\n', content)
 
 
@@ -381,7 +322,7 @@
         self.assertEqual(expected_mapper, runner._get_url_override_mapper())
 
 
-class TestCommand(unittest.TestCase):
+class TestDebugCommand(unittest.TestCase):
 
     def test_debug_command_sets_script_debug(self):
         configp = ConfigParser()
@@ -397,6 +338,83 @@
         self.assertTrue(script.debug)
 
 
+class TestPatchCommand(TestCaseWithQueue):
+
+    def set_up(self):
+        # Create branch to be patched
+        tree = self.make_branch_and_tree('foo')
+        configp = ConfigParser()
+        configp.add_section('foo')
+        self.getQueue(empty=True)
+        # Create PQM working directory
+        self.build_tree(['bar/'])
+        pqm.workdir = 'bar'
+        pqm.precommit_hook = []
+        return configp, tree
+
+    def get_patch_command(self, lines):
+        configp, tree = self.set_up()
+        self.build_tree_contents([('foo/bar', '')])
+        tree.smart_add(['foo/bar'])
+        tree.commit("Add bar.")
+        script = MockScript()
+        handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
+        return PatchCommand(script, handler, configp, lines, 'foo')
+
+    def test_PatchCommand_empty_patch(self):
+        patch = []
+        command = self.get_patch_command(patch)
+        e = self.assertRaises(PQMException, command.run)
+        self.assertEqual("'Empty patch content'", str(e))
+
+    def test_PatchCommand_valid_patch(self):
+        patch = ["=== modified file 'bar'",
+                 "--- old/bar 2008-07-20 16:06:44.000000000 +0100",
+                 "+++ new/bar 2008-07-20 16:06:48.000000000 +0100",
+                 "@@ -0,0 +1 @@",
+                 "+foo"]
+        command = self.get_patch_command(patch)
+        command.run()
+        self.assertFileEqual('foo\n', 'bar/foo/foo/bar')
+
+    def test_PatchCommand_nonsense_patch(self):
+        patch = ["`Twas brillig, and the slithy toves",
+                 "  Did gyre and gimble in the wabe;",
+                 "All mimsy were the borogoves,",
+                 "  And the mome raths outgrabe."]
+        command = self.get_patch_command(patch)
+        e = self.assertRaises(PQMException, command.run)
+        self.assertEqual(
+            "['patch command \"patch\" failed (512): patch exited with error"
+            " code 2', 'patch: **** Only garbage was found in the patch"
+            " input.\\n']",
+            str(e))
+
+    def test_PatchCommand_absolute_path(self):
+        patch = ["=== modified file 'bar'",
+                 "--- /bar 2008-07-20 16:06:44.000000000 +0100",
+                 "+++ /bar 2008-07-20 16:06:48.000000000 +0100",
+                 "@@ -0,0 +1 @@",
+                 "+foo"]
+        command = self.get_patch_command(patch)
+        e = self.assertRaises(PQMException, command.run)
+        self.assertEqual("'Invalid absolute filename in patch: /bar 2008-07-20"
+                         " 16:06:48.000000000 +0100'",
+                         str(e))
+
+    def test_PatchCommand_backreferencing_path(self):
+        patch = ["=== modified file 'bar'",
+                 "--- bar/.. 2008-07-20 16:06:44.000000000 +0100",
+                 "+++ bar/.. 2008-07-20 16:06:48.000000000 +0100",
+                 "@@ -0,0 +1 @@",
+                 "+foo"]
+        command = self.get_patch_command(patch)
+        e = self.assertRaises(PQMException, command.run)
+        self.assertEqual("'Invalid backreferencing filename in patch: bar/.."
+                         " 2008-07-20 16:06:48.000000000 +0100'",
+                         str(e))
+
+
 class FunctionalTestCommandRunner(unittest.TestCase):
 
     def setUp(self):

=== modified file 'pqm/ui/tests/test_twisted.py'
--- a/pqm/ui/tests/test_twisted.py	2008-07-16 15:44:48 +0000
+++ b/pqm/ui/tests/test_twisted.py	2008-07-17 10:23:29 +0000
@@ -1,37 +1,29 @@
-
 from twisted.trial import unittest
 from twisted.web.resource import getChildForRequest
 from twisted.web.test.test_web import DummyRequest
 import logging
 
 import pqm
+from pqm.tests import TestCaseWithQueue
 from pqm.PQMConfigParser import ConfigParser
-from pqm.tests.test_pqm import QueueSetup
-
-class TestTwistedUI(unittest.TestCase):
+
+
+class TestTwistedUI(TestCaseWithQueue):
 
     def testImports(self):
         import pqm.ui.twistd
 
-    def setUp(self):
-        unittest.TestCase.setUp(self)
-        self.queueSetup = QueueSetup()
-        self.queueSetup.setUp()
-
-    def tearDown(self):
-        unittest.TestCase.tearDown(self)
-        self.queueSetup.tearDown()
-
     def testQueue(self):
         from pqm.ui.twistd import FakeOptions
+        queue = self.getQueue()
         configp = ConfigParser()
-        configp.read([self.queueSetup.configFileName])
+        configp.read([queue.configFileName])
         handler = pqm.BranchSpecOptionHandler(configp)
         queuedir = pqm.get_queuedir(configp, logging, [])
         patches = pqm.find_patches(
             queuedir, logging, handler, configp, FakeOptions())
         self.assertEqual(3, len(patches))
-        self.assertEqual(patches[0].filename, self.queueSetup.messageFileName)
+        self.assertEqual(patches[0].filename, queue.messageFileName)
         self.assertEqual(set(['project']),
                          patches[0].getCommands()[0].getProjects())
         self.assertRaises(KeyError,
@@ -41,10 +33,11 @@
 
     def getResource(self):
         from pqm.ui.twistd import PQMInfo, QueueResource
-        statusfile = file(self.queueSetup.queuedir + '/pqm/status', 'wt')
+        queue = self.getQueue()
+        statusfile = file(queue.queuedir + '/pqm/status', 'wt')
         statusfile.write("<foo\nbar\nbaz\nquux\ntheta\n")
         statusfile.close()
-        pqminfo = PQMInfo([self.queueSetup.configFileName])
+        pqminfo = PQMInfo([queue.configFileName])
         resource = QueueResource(pqminfo)
         pqminfo.refresh()
         return resource



More information about the bazaar-commits mailing list