##// END OF EJS Templates
log: follow filenames through renames (issue647)...
log: follow filenames through renames (issue647) In commands.log a displayer was initialized from cmdutil.show_changeset() with the initial matchfn (which designates the specified files which only is correct in the highest revision in the range). prep() is handed the correct list of files, but displayer.show() didn't use that list but keept using the original matchfn. The matchfn argument to cmdutil.show_changeset() wasn't specified in other places and is only used in .show(), so now we give the matchfn as an optional parameter to .show(). We do however still have to detect --patch and --stat from opts in show_changeset() and let it imply a matchall, but that can now be overruled with the new .show() matchfn parameter.

File last commit:

r10282:08a0f04b default
r11488:f786fc4b 1.6 stable
Show More
parentrevspec.py
96 lines | 3.1 KiB | text/x-python | PythonLexer
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 # Mercurial extension to make it easy to refer to the parent of a revision
#
# Copyright (C) 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Martin Geisler
add blank line after copyright notices and after header
r8228
Cédric Duval
extensions: improve the consistency of synopses...
r8894 '''interpret suffixes to refer to ancestor revisions
Alexis S. L. Carvalho
Add parentrevspec extension
r5194
Martin Geisler
parentrevspec: wrap docstrings at 70 characters
r9268 This extension allows you to use git-style suffixes to refer to the
ancestors of a specific revision.
Alexis S. L. Carvalho
Add parentrevspec extension
r5194
Martin Geisler
parentrevspec: change list to a literal block
r9213 For example, if you can refer to a revision as "foo", then::
Alexis S. L. Carvalho
Add parentrevspec extension
r5194
Martin Geisler
parentrevspec: change list to a literal block
r9213 foo^N = Nth parent of foo
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 foo^0 = foo
foo^1 = first parent of foo
foo^2 = second parent of foo
foo^ = foo^1
Martin Geisler
parentrevspec: change list to a literal block
r9213 foo~N = Nth first grandparent of foo
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 foo~0 = foo
foo~1 = foo^1 = foo^ = first parent of foo
foo~2 = foo^1^1 = foo^^ = first parent of first parent of foo
'''
Matt Mackall
error: move repo errors...
r7637 from mercurial import error
Alexis S. L. Carvalho
Add parentrevspec extension
r5194
def reposetup(ui, repo):
if not repo.local():
return
class parentrevspecrepo(repo.__class__):
def lookup(self, key):
try:
_super = super(parentrevspecrepo, self)
return _super.lookup(key)
Matt Mackall
error: move repo errors...
r7637 except error.RepoError:
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 pass
circ = key.find('^')
tilde = key.find('~')
if circ < 0 and tilde < 0:
raise
elif circ >= 0 and tilde >= 0:
end = min(circ, tilde)
else:
end = max(circ, tilde)
cl = self.changelog
base = key[:end]
try:
node = _super.lookup(base)
Matt Mackall
error: move repo errors...
r7637 except error.RepoError:
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 # eek - reraise the first error
return _super.lookup(key)
rev = cl.rev(node)
suffix = key[end:]
i = 0
while i < len(suffix):
# foo^N => Nth parent of foo
# foo^0 == foo
# foo^1 == foo^ == 1st parent of foo
# foo^2 == 2nd parent of foo
if suffix[i] == '^':
j = i + 1
p = cl.parentrevs(rev)
if j < len(suffix) and suffix[j].isdigit():
j += 1
Matt Mackall
many, many trivial check-code fixups
r10282 n = int(suffix[i + 1:j])
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 if n > 2 or n == 2 and p[1] == -1:
raise
else:
n = 1
if n:
rev = p[n - 1]
i = j
# foo~N => Nth first grandparent of foo
# foo~0 = foo
# foo~1 = foo^1 == foo^ == 1st parent of foo
# foo~2 = foo^1^1 == foo^^ == 1st parent of 1st parent of foo
elif suffix[i] == '~':
j = i + 1
while j < len(suffix) and suffix[j].isdigit():
j += 1
if j == i + 1:
raise
Matt Mackall
many, many trivial check-code fixups
r10282 n = int(suffix[i + 1:j])
Alexis S. L. Carvalho
Add parentrevspec extension
r5194 for k in xrange(n):
rev = cl.parentrevs(rev)[0]
i = j
else:
raise
return cl.node(rev)
repo.__class__ = parentrevspecrepo