Patchwork [evolve,v4] evolve: make split respect rev args passed without --rev or -r

login
register
mail settings
Submitter Kostia Balytskyi
Date Feb. 4, 2016, 10:48 a.m.
Message ID <1e11ccaf25c178014d9e.1454582880@dev1902.lla1.facebook.com>
Download mbox | patch
Permalink /patch/12975/
State Superseded
Headers show

Comments

Kostia Balytskyi - Feb. 4, 2016, 10:48 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@fb.com>
# Date 1454582800 28800
#      Thu Feb 04 02:46:40 2016 -0800
# Node ID 1e11ccaf25c178014d9eb7ba2057244bd4cf83d8
# Parent  983f2e4dbe5d4d97d6ca82f6679913d75c1f2577
evolve: make split respect rev args passed without --rev or -r

Currently, if one runs `hg split .` or `hg split`, it will fail
with an exception. This happens becuase we only expect revision
args to be passed as --rev/-r ones and don't treat unnamed args
properly or add default values if no args are provided.
Kostia Balytskyi - Feb. 4, 2016, 10:48 a.m.
Please disregard, wrong tag.




On 2/4/16, 10:48 AM, "Mercurial-devel on behalf of Kostia Balytskyi" <mercurial-devel-bounces@mercurial-scm.org on behalf of ikostia@fb.com> wrote:

># HG changeset patch

># User Kostia Balytskyi <ikostia@fb.com>

># Date 1454582800 28800

>#      Thu Feb 04 02:46:40 2016 -0800

># Node ID 1e11ccaf25c178014d9eb7ba2057244bd4cf83d8

># Parent  983f2e4dbe5d4d97d6ca82f6679913d75c1f2577

>evolve: make split respect rev args passed without --rev or -r

>

>Currently, if one runs `hg split .` or `hg split`, it will fail

>with an exception. This happens becuase we only expect revision

>args to be passed as --rev/-r ones and don't treat unnamed args

>properly or add default values if no args are provided.

>

>diff --git a/hgext/evolve.py b/hgext/evolve.py

>--- a/hgext/evolve.py

>+++ b/hgext/evolve.py

>@@ -2729,16 +2729,13 @@

>     tr = wlock = lock = None

>     newcommits = []

> 

>-    revopt = opts.get('rev')

>-    if revopt:

>-        revs = scmutil.revrange(repo, revopt)

>-        if len(revs) != 1:

>-            raise error.Abort(_("you can only specify one revision to split"))

>-        else:

>-            rev = list(revs)[0]

>-    else:

>-        rev = '.'

>-

>+    revarg = (list(revs) + opts.get('rev')) or ['.']

>+    if len(revarg) != 1:

>+        msg = _("more than one revset is given")

>+        hnt = _("use either `hg split <rs>` or `hg split --rev <rs>`, not both")

>+        raise error.Abort(msg, hint=hnt)

>+

>+    rev = scmutil.revsingle(repo, revarg[0])

>     try:

>         wlock = repo.wlock()

>         lock = repo.lock()

>diff --git a/tests/test-split.t b/tests/test-split.t

>--- a/tests/test-split.t

>+++ b/tests/test-split.t

>@@ -320,9 +320,14 @@

>      bookA                     19:a2b5c9d9b362

>    * bookB                     19:a2b5c9d9b362

>  

>-Cannot specify multiple revisions with -r

>+Lastest revision is selected if multiple are given to -r

>   $ hg split -r "desc(_a)::"

>-  abort: you can only specify one revision to split

>+  (leaving bookmark bookB)

>+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved

>+  adding _d

>+  diff --git a/_d b/_d

>+  new file mode 100644

>+  examine changes to '_d'? [Ynesfdaq?] abort: response expected

>   [255]

> 

> Cannot split a commit that is not a head if instability is not allowed

>@@ -335,4 +340,41 @@

>   abort: cannot split commit: ced8fbcce3a7 not a head

>   [255]

> 

>+Changing evolution level to createmarkers

>+  $ echo "[experimental]" >> $HGRCPATH

>+  $ echo "evolution=createmarkers" >> $HGRCPATH

> 

>+Running split without any revision operates on the parent of the working copy

>+  $ hg split << EOF

>+  > q

>+  > EOF

>+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved

>+  adding _d

>+  diff --git a/_d b/_d

>+  new file mode 100644

>+  examine changes to '_d'? [Ynesfdaq?] q

>+  

>+  abort: user quit

>+  [255]

>+

>+Running split with tip revision, specified as unnamed argument

>+  $ hg split . << EOF

>+  > q

>+  > EOF

>+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved

>+  adding _d

>+  diff --git a/_d b/_d

>+  new file mode 100644

>+  examine changes to '_d'? [Ynesfdaq?] q

>+  

>+  abort: user quit

>+  [255]

>+

>+Running split with both unnamed and named revision arguments shows an error msg

>+  $ hg split . --rev .^ << EOF

>+  > q

>+  > EOF

>+  abort: more than one revset is given

>+  (use either `hg split <rs>` or `hg split --rev <rs>`, not both)

>+  [255]

>+

>_______________________________________________

>Mercurial-devel mailing list

>Mercurial-devel@mercurial-scm.org

>https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=zUz3vdDt5hts8X-rXQD7oMrM8v-7YrDl9kZPpNefkvg&s=Toh6lkW1xHTpB1sic8rG0W-4qI0J8Ttw7YRkGzCmESE&e=

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2729,16 +2729,13 @@ 
     tr = wlock = lock = None
     newcommits = []
 
-    revopt = opts.get('rev')
-    if revopt:
-        revs = scmutil.revrange(repo, revopt)
-        if len(revs) != 1:
-            raise error.Abort(_("you can only specify one revision to split"))
-        else:
-            rev = list(revs)[0]
-    else:
-        rev = '.'
-
+    revarg = (list(revs) + opts.get('rev')) or ['.']
+    if len(revarg) != 1:
+        msg = _("more than one revset is given")
+        hnt = _("use either `hg split <rs>` or `hg split --rev <rs>`, not both")
+        raise error.Abort(msg, hint=hnt)
+
+    rev = scmutil.revsingle(repo, revarg[0])
     try:
         wlock = repo.wlock()
         lock = repo.lock()
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -320,9 +320,14 @@ 
      bookA                     19:a2b5c9d9b362
    * bookB                     19:a2b5c9d9b362
  
-Cannot specify multiple revisions with -r
+Lastest revision is selected if multiple are given to -r
   $ hg split -r "desc(_a)::"
-  abort: you can only specify one revision to split
+  (leaving bookmark bookB)
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  adding _d
+  diff --git a/_d b/_d
+  new file mode 100644
+  examine changes to '_d'? [Ynesfdaq?] abort: response expected
   [255]
 
 Cannot split a commit that is not a head if instability is not allowed
@@ -335,4 +340,41 @@ 
   abort: cannot split commit: ced8fbcce3a7 not a head
   [255]
 
+Changing evolution level to createmarkers
+  $ echo "[experimental]" >> $HGRCPATH
+  $ echo "evolution=createmarkers" >> $HGRCPATH
 
+Running split without any revision operates on the parent of the working copy
+  $ hg split << EOF
+  > q
+  > EOF
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  adding _d
+  diff --git a/_d b/_d
+  new file mode 100644
+  examine changes to '_d'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+
+Running split with tip revision, specified as unnamed argument
+  $ hg split . << EOF
+  > q
+  > EOF
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  adding _d
+  diff --git a/_d b/_d
+  new file mode 100644
+  examine changes to '_d'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]
+
+Running split with both unnamed and named revision arguments shows an error msg
+  $ hg split . --rev .^ << EOF
+  > q
+  > EOF
+  abort: more than one revset is given
+  (use either `hg split <rs>` or `hg split --rev <rs>`, not both)
+  [255]
+