D6828: uncommit: add options to update to the current user or current date

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  These are also from the evolve extension's version of uncommit.
 
  I tried adding validation that both forms of user or date can't be specified at
  the same time, but that fails because these show up in `opts` with a None value
  whether or not the option was given on the command line.  Presumably that means
  the conditional in `resolvecommitoptions` could be simplified.  But this is how
  both evolve and MQ handle it.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

AFFECTED FILES
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -42,6 +42,8 @@
    -l --logfile FILE             read commit message from file
    -d --date DATE                record the specified date as commit date
    -u --user USER                record the specified user as committer
+   -D --current-date             record the current date as commit date
+   -U --current-user             record the current user as committer
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -118,6 +118,7 @@
 walkopts = cmdutil.walkopts
 commitopts = cmdutil.commitopts
 commitopts2 = cmdutil.commitopts2
+commitopts3 = cmdutil.commitopts3
 formatteropts = cmdutil.formatteropts
 templateopts = cmdutil.templateopts
 logopts = cmdutil.logopts
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -100,6 +100,13 @@
      _('record the specified user as committer'), _('USER')),
 ]
 
+commitopts3 = [
+    (b'D', b'current-date', None,
+     _(b'record the current date as commit date')),
+    (b'U', b'current-user', None,
+     _(b'record the current user as committer')),
+]
+
 formatteropts = [
     ('T', 'template', '',
      _('display with template'), _('TEMPLATE')),
@@ -175,6 +182,15 @@
 # editor text
 _linebelow = "^HG: ------------------------ >8 ------------------------$"
 
+def resolvecommitoptions(ui, opts):
+    """modify commit options dict to handle related options
+    """
+    # N.B. this is extremely similar to setupheaderopts() in mq.py
+    if not opts.get(b'date') and opts.get(b'current_date'):
+        opts[b'date'] = b'%d %d' % dateutil.makedate()
+    if not opts.get(b'user') and opts.get(b'current_user'):
+        opts[b'user'] = ui.username()
+
 def ishunk(x):
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
     return isinstance(x, hunkclasses)
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -112,7 +112,8 @@
     [('', 'keep', None, _('allow an empty commit after uncommiting')),
      ('', 'allow-dirty-working-copy', False,
     _('allow uncommit with outstanding changes'))
-    ] + commands.walkopts + commands.commitopts + commands.commitopts2,
+    ] + commands.walkopts + commands.commitopts + commands.commitopts2
+    + commands.commitopts3,
     _('[OPTION]... [FILE]...'),
     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
 def uncommit(ui, repo, *pats, **opts):
@@ -128,6 +129,8 @@
     """
     opts = pycompat.byteskwargs(opts)
 
+    cmdutil.resolvecommitoptions(ui, opts)
+
     with repo.wlock(), repo.lock():
 
         m, a, r, d = repo.status()[:4]



To: mharbison72, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
This revision is now accepted and ready to land.
pulkit added a comment.
pulkit accepted this revision.


  I guess `--interactive` is the only flag left which is extra in evolve version, right?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6828/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

To: mharbison72, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Closed by commit rHG66048f6b5d0d: uncommit: add options to update to the current user or current date (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6828?vs=16449&id=16454

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6828/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

AFFECTED FILES
  hgext/uncommit.py
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-uncommit.t

CHANGE DETAILS

diff --git a/tests/test-uncommit.t b/tests/test-uncommit.t
--- a/tests/test-uncommit.t
+++ b/tests/test-uncommit.t
@@ -42,6 +42,8 @@
    -l --logfile FILE             read commit message from file
    -d --date DATE                record the specified date as commit date
    -u --user USER                record the specified user as committer
+   -D --current-date             record the current date as commit date
+   -U --current-user             record the current user as committer
   
   (some details hidden, use --verbose to show complete help)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -118,6 +118,7 @@
 walkopts = cmdutil.walkopts
 commitopts = cmdutil.commitopts
 commitopts2 = cmdutil.commitopts2
+commitopts3 = cmdutil.commitopts3
 formatteropts = cmdutil.formatteropts
 templateopts = cmdutil.templateopts
 logopts = cmdutil.logopts
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -100,6 +100,13 @@
      _('record the specified user as committer'), _('USER')),
 ]
 
+commitopts3 = [
+    (b'D', b'current-date', None,
+     _(b'record the current date as commit date')),
+    (b'U', b'current-user', None,
+     _(b'record the current user as committer')),
+]
+
 formatteropts = [
     ('T', 'template', '',
      _('display with template'), _('TEMPLATE')),
@@ -175,6 +182,15 @@
 # editor text
 _linebelow = "^HG: ------------------------ >8 ------------------------$"
 
+def resolvecommitoptions(ui, opts):
+    """modify commit options dict to handle related options
+    """
+    # N.B. this is extremely similar to setupheaderopts() in mq.py
+    if not opts.get(b'date') and opts.get(b'current_date'):
+        opts[b'date'] = b'%d %d' % dateutil.makedate()
+    if not opts.get(b'user') and opts.get(b'current_user'):
+        opts[b'user'] = ui.username()
+
 def ishunk(x):
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
     return isinstance(x, hunkclasses)
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -112,7 +112,8 @@
     [('', 'keep', None, _('allow an empty commit after uncommiting')),
      ('', 'allow-dirty-working-copy', False,
     _('allow uncommit with outstanding changes'))
-    ] + commands.walkopts + commands.commitopts + commands.commitopts2,
+    ] + commands.walkopts + commands.commitopts + commands.commitopts2
+    + commands.commitopts3,
     _('[OPTION]... [FILE]...'),
     helpcategory=command.CATEGORY_CHANGE_MANAGEMENT)
 def uncommit(ui, repo, *pats, **opts):
@@ -128,6 +129,8 @@
     """
     opts = pycompat.byteskwargs(opts)
 
+    cmdutil.resolvecommitoptions(ui, opts)
+
     with repo.wlock(), repo.lock():
 
         m, a, r, d = repo.status()[:4]



To: mharbison72, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
mharbison72 added a comment.


  In D6828#100139 <https://phab.mercurial-scm.org/D6828#100139>, @pulkit wrote:
 
  > I guess `--interactive` is the only flag left which is extra in evolve version, right?
 
  No:
 
    -a --all                 uncommit all changes when no arguments given
    -i --interactive         interactive mode to uncommit (EXPERIMENTAL)
    -r --rev REV             revert commit content to REV instead
       --revert              discard working directory changes after uncommit
    -n --note TEXT           store a note on uncommit
 
  I'd like to port `--interactive` and lean towards `--all` too for consistency with `revert` and `resolve`, though I can see how it might be used as an alternative to `rollback` in its current form.  I didn't take the time to understand what `--rev` is doing.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6828/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

To: mharbison72, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
pulkit added a comment.


  In D6828#100190 <https://phab.mercurial-scm.org/D6828#100190>, @mharbison72 wrote:
 
  > In D6828#100139 <https://phab.mercurial-scm.org/D6828#100139>, @pulkit wrote:
  >
  >> I guess `--interactive` is the only flag left which is extra in evolve version, right?
  >
  > No:
  >
  >   -a --all                 uncommit all changes when no arguments given
  >   -i --interactive         interactive mode to uncommit (EXPERIMENTAL)
  >   -r --rev REV             revert commit content to REV instead
  >      --revert              discard working directory changes after uncommit
  >   -n --note TEXT           store a note on uncommit
  >
  > I'd like to port `--interactive`.
 
  That will be great. https://phab.mercurial-scm.org/D6005 should help :)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6828/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

To: mharbison72, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6828: uncommit: add options to update to the current user or current date

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
mharbison72 added a comment.


  In D6828#100192 <https://phab.mercurial-scm.org/D6828#100192>, @pulkit wrote:
 
  > In D6828#100190 <https://phab.mercurial-scm.org/D6828#100190>, @mharbison72 wrote:
  >
  >> I'd like to port `--interactive`.
  >
  > That will be great. https://phab.mercurial-scm.org/D6005 should help :)
 
  I haven’t looked at it at all, and just assumed the evolve code could be dropped into place. Any idea why that patch got so complicated?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6828/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6828

To: mharbison72, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel