Patchwork [2,of,5,topic-experiment] topics: rename '--change' flag to '--rev' flag

login
register
mail settings
Submitter Pulkit Goyal
Date June 21, 2017, 2:09 a.m.
Message ID <22705ee4a0f7a049dfd1.1498010963@workspace>
Download mbox | patch
Permalink /patch/21568/
State Accepted
Headers show

Comments

Pulkit Goyal - June 21, 2017, 2:09 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1497990601 -19800
#      Wed Jun 21 02:00:01 2017 +0530
# Node ID 22705ee4a0f7a049dfd18063b5410ef72c55393c
# Parent  1261e6d3ff9534a3a0f8f703e4a490328140d794
topics: rename '--change' flag to '--rev' flag

The --change flag was used to read a revset of which topic should be changed. In
mercurial we use --rev for this type of flag.

Now things will work as follows:

`hg topics topicname`: It will set the current topic
`hg topics topicname --rev revset`: Change topic of all the revs in the revset
to topicname

Further patches will try to achieve the following:

`hg topics --clear --rev revset`: clear topic from all the revisions in the
revset
`hg topics --clear`: clear the current topic (Current behavior)
`hg topics --rev revset`: show topics on the revisions in the revset

Patch

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -255,30 +255,30 @@ 
 
 @command('topics [TOPIC]', [
         ('', 'clear', False, 'clear active topic if any'),
-        ('', 'change', '', 'revset of existing revisions to change topic'),
+        ('r', 'rev', '', 'revset of existing revisions', _('REV')),
         ('l', 'list', False, 'show the stack of changeset in the topic'),
     ] + commands.formatteropts)
-def topics(ui, repo, topic='', clear=False, change=None, list=False, **opts):
+def topics(ui, repo, topic='', clear=False, rev=None, list=False, **opts):
     """View current topic, set current topic, or see all topics.
 
     The --verbose version of this command display various information on the state of each topic."""
     if list:
-        if clear or change:
-            raise error.Abort(_("cannot use --clear or --change with --list"))
+        if clear or rev:
+            raise error.Abort(_("cannot use --clear or --rev with --list"))
         if not topic:
             topic = repo.currenttopic
         if not topic:
             raise error.Abort(_('no active topic to list'))
         return stack.showstack(ui, repo, topic, opts)
 
-    if change:
+    if rev:
         if not obsolete.isenabled(repo, obsolete.createmarkersopt):
-            raise error.Abort(_('must have obsolete enabled to use --change'))
+            raise error.Abort(_('must have obsolete enabled to change topics'))
         if not topic and not clear:
             raise error.Abort('changing topic requires a topic name or --clear')
-        if any(not c.mutable() for c in repo.set('%r and public()', change)):
+        if any(not c.mutable() for c in repo.set('%r and public()', rev)):
             raise error.Abort("can't change topic of a public change")
-        _changetopics(ui, repo, change, topic, clear)
+        _changetopics(ui, repo, rev, topic, clear)
     if clear:
         if repo.vfs.exists('topic'):
             repo.vfs.unlink('topic')
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -22,9 +22,9 @@ 
   
   options:
   
-      --clear        clear active topic if any
-      --change VALUE revset of existing revisions to change topic
-   -l --list         show the stack of changeset in the topic
+      --clear   clear active topic if any
+   -r --rev REV revset of existing revisions
+   -l --list    show the stack of changeset in the topic
   
   (some details hidden, use --verbose to show complete help)
   $ hg topics
@@ -32,8 +32,8 @@ 
 Test topics interaction with evolution:
 
   $ hg topics --config experimental.evolution=
-  $ hg topics --config experimental.evolution= --change . bob
-  abort: must have obsolete enabled to use --change
+  $ hg topics --config experimental.evolution= --rev . bob
+  abort: must have obsolete enabled to change topics
   [255]
 
 Create some changes:
@@ -542,17 +542,17 @@ 
   $ hg topics
      fran
 Changing topic fails if we don't give a topic
-  $ hg topic --change 9
+  $ hg topic --rev 9
   abort: changing topic requires a topic name or --clear
   [255]
 
 Can't change topic of a public change
-  $ hg topic --change 1:: --clear
+  $ hg topic --rev 1:: --clear
   abort: can't change topic of a public change
   [255]
 
 Can clear topics
-  $ hg topic --change 9 --clear
+  $ hg topic --rev 9 --clear
   changed topic on 1 changes
   please run hg evolve --rev "not topic()" now
   $ hg log -Gr 'draft() and not obsolete()'
@@ -577,7 +577,7 @@ 
   rebasing 10:4073470c35e1 "fran?"
 
 Can add a topic to an existing change
-  $ hg topic --change 11 wat
+  $ hg topic --rev 11 wat
   changed topic on 1 changes
   please run hg evolve --rev "topic(wat)" now
   $ hg log -Gr 'draft() and not obsolete()'
@@ -651,8 +651,8 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     fran?
   
-Readding the same topic with topic --change should work:
-  $ hg topic --change . watwat
+Reading the same topic with topic --rev should work:
+  $ hg topic --rev . watwat
   changed topic on 1 changes
 
 Testing issue5441
@@ -675,7 +675,7 @@ 
   |  summary:     start on fran
   |
 
-  $ hg topics --change '13::19' changewat
+  $ hg topics --rev '13::19' changewat
   changed topic on 2 changes
   please run hg evolve --rev "topic(changewat)" now
   $ hg log -Gr 'draft()'