Previous revision
Augie Fackler
durin42 at gmail.com
Sun Jun 21 00:43:29 UTC 2009
On Jun 20, 2009, at 7:16 PM, Krzysiek Pawlik wrote:
>
> Hello,
>
> I was missing simple way of showing diff for specific revision, it
> can be done
> with for example `hg diff -r 852:853' or `hg log -p -r 853' -- but
> the first
> requires typing a lot of numbers and is error prone (especially when
> repository
> hits revisions >=10000), the second one displays log entry which is
> not needed
> when you're interested in diff only.
What's wrong with diff -c <revision>? That might be new since 1.2, but
it's still already there without a special revision spec.
> I'm attaching a simple patch that adds a notion of previous
> revision. It's
> denoted as ^<rev>, so above example becomes `hg diff -r ^853'. In
> fact ^<rev> is
> expanded to revision range <rev - 1>:<rev>, this behaviour produces
> *two*
> changesets in output for `hg log -r ^tip'. In case of ^0 an error is
> generated,
> as revision 0 simply can't have previous revision.
This is an interesting idea, but that's somewhat confusing when you
consider parentrevspec uses rev^ to mean the first parent of the
revision.
> The change is in cmdutil.py file so any command that uses -r gains
> this ability.
This feels like it belongs in an extension to me, but I've also got
the previously mentioned concern about similarity to the existing
parentrevspec extension.
> If there are no objections I'd like the patch be applied to main.
>
> --
> Krzysiek Pawlik (Nelchael) GPG Key ID: 0xBC555551
> http://www.linkedin.com/in/krzysiekpawlik
> # HG changeset patch
> # User Krzysiek Pawlik <krzysiek.pawlik at people.pl>
> # Date 1245541797 -3600
> # Node ID 2e78983c753740e1cba9ab2dcdc1e7290fc36ec1
> # Parent 91e26fb24fb154ca55953a3445c514c7819e1e6b
> Add ability to easily specify previous revision: prepend it with ^
>
> For example: ^tip - this means previous to tip and tip, so `hg log -
> r ^tip' displays two changesets, `hg diff -r ^tip' shows diff from
> previous to tip.
>
> diff -r 91e26fb24fb1 -r 2e78983c7537 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py Thu Jun 18 16:56:03 2009 -0500
> +++ b/mercurial/cmdutil.py Sun Jun 21 00:49:57 2009 +0100
> @@ -135,6 +135,10 @@ def revpair(repo, revs):
> start, end = revs[0].split(revrangesep, 1)
> start = revfix(repo, start, 0)
> end = revfix(repo, end, len(repo) - 1)
> + elif revs[0].startswith("^"):
> + start, end = revrange(repo, [revs[0]])
> + start = revfix(repo, start, 0)
> + end = revfix(repo, end, len(repo) - 1)
> else:
> start = revfix(repo, revs[0], None)
> elif len(revs) == 2:
> @@ -166,6 +170,16 @@ def revrange(repo, revs):
> continue
> seen.add(rev)
> l.append(rev)
> + elif spec.startswith("^"):
> + start = revfix(repo, spec[1:], 0) - 1
> + end = revfix(repo, spec[1:], len(repo) - 1)
> + if start == -1:
> + raise util.Abort(_('revision %d has no parent') %
> end)
> + for rev in [start, end]:
> + if rev in seen:
> + continue
> + seen.add(rev)
> + l.append(rev)
> else:
> rev = revfix(repo, spec, None)
> if rev in seen:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list