Patchwork [evolve-ext] evolve: fix the 'grab' alias to work on Windows

login
register
mail settings
Submitter Matt Harbison
Date Aug. 12, 2014, 11:56 p.m.
Message ID <51cda4d2bb2cd52f4e90.1407887786@Envy>
Download mbox | patch
Permalink /patch/5367/
State Not Applicable
Headers show

Comments

Matt Harbison - Aug. 12, 2014, 11:56 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1407884993 14400
#      Tue Aug 12 19:09:53 2014 -0400
# Node ID 51cda4d2bb2cd52f4e90bf35c4243e33c8ec71bb
# Parent  66f4c5c52d970f145cd218ceed065c3fe096631d
evolve: fix the 'grab' alias to work on Windows

For some reason, the $HG variable wasn't substituted on Windows in this case.
From the test suite:

   $ hg grab 8
   '$HG' is not recognized as an internal or external command,\r (esc)
   operable program or batch file.\r (esc)

This change seems hacky, but there isn't a readily available example of setting
up a shell alias like this from a python module to know if there is a better
way, and it seems like this is maybe just a convenience for tests, since there
is no documentation for the aliases.


The local copy of run-tests.py appears to predate the Windows support in the
Mercurial repository's version, and fails each test with:

    The system cannot find the path specified.

However, with this change and blacklisting test-simple4server.t, the tests can
(mostly) be run on Windows like so:

    $ ../../hg/tests/run-tests.py --with-hg=../../hg/hg --blacklist windows
    Skipped test-simple4server.t: blacklisted
    Warned test-obsolete.t: no result code from test
    Warned test-tutorial.t: no result code from test
    Warned test-evolve.t: no result code from test
    Warned test-userguide.t: no result code from test
    Warned test-sharing.t: no result code from test
    Warned test-drop.t: no result code from test
    Failed test-prune.t: output changed
    # Ran 41 tests, 1 skipped, 6 warned, 1 failed.
Pierre-Yves David - Sept. 2, 2014, 7:10 p.m.
On 08/13/2014 01:56 AM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1407884993 14400
> #      Tue Aug 12 19:09:53 2014 -0400
> # Node ID 51cda4d2bb2cd52f4e90bf35c4243e33c8ec71bb
> # Parent  66f4c5c52d970f145cd218ceed065c3fe096631d
> evolve: fix the 'grab' alias to work on Windows

Patch applied, thanks. I find it very brave of you to claim that `grab` 
works.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -22,7 +22,7 @@ 
 testedwith = '3.0.1 3.1'
 buglink = 'http://bz.selenic.com/'
 
-import sys
+import sys, os
 import random
 from StringIO import StringIO
 import struct
@@ -69,6 +69,7 @@ 
 from mercurial import localrepo
 from mercurial.hgweb import hgweb_mod
 from mercurial import bundle2
+from mercurial import util
 
 _pack = struct.pack
 
@@ -456,8 +457,13 @@ 
         ui.setconfig('alias', 'odiff',
             "diff --hidden --rev 'limit(precursors(.),1)' --rev .")
     if ui.config('alias', 'grab', None) is None:
-        ui.setconfig('alias', 'grab',
-            "! $HG rebase --dest . --rev $@ && $HG up tip")
+        if os.name == 'nt':
+            ui.setconfig('alias', 'grab',
+                "! " + util.hgexecutable() + " rebase --dest . --rev $@ && "
+                 + util.hgexecutable() + " up tip")
+        else:
+            ui.setconfig('alias', 'grab',
+                "! $HG rebase --dest . --rev $@ && $HG up tip")
 
 
 ### Troubled revset symbol