[PATCH RFC] log: add --from for showing history from a certain rev

Durham Goode durham at fb.com
Fri Feb 6 19:17:56 UTC 2015


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1423249495 28800
#      Fri Feb 06 11:04:55 2015 -0800
# Node ID 86c462eee946ce6ce63140fa494e765196107126
# Parent  e1dbe0b215ae137eec53ceb12440536d570a83d2
log: add --from for showing history from a certain rev

Right now it's very obtuse to show the history of a particular rev (hg log -r
'reverse(::foo)'). This adds a --from option that allows "hg log --from foo".

Sending as an RFC since the naming might be controversial and there might be
better ways of integrating it with existing commands (like using this to show
history for bookmarks, hg log --from mybook vs hg log --bookmark mybook).

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4372,6 +4372,7 @@ def locate(ui, repo, *pats, **opts):
     ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
     ('', 'removed', None, _('include revisions where files were removed')),
     ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
+    ('', 'from', '', _('show history from the given revision')),
     ('u', 'user', [], _('revisions committed by user'), _('USER')),
     ('', 'only-branch', [],
      _('show only changesets within the given named branch (DEPRECATED)'),
@@ -4477,6 +4478,12 @@ def log(ui, repo, *pats, **opts):
     Returns 0 on success.
 
     """
+    if opts.get('from'):
+        if opts.get('rev'):
+            raise util.Abort(_('cannot specify both --rev and --from'))
+        fromrevs = repo.revs(opts.get('from'))
+        opts['rev'] = [revset.formatspec('reverse(::%ld)', fromrevs)]
+
     if opts.get('graph'):
         return cmdutil.graphlog(ui, repo, *pats, **opts)
 


More information about the Mercurial-devel mailing list