How to identify the source's revision?
Daniel(原志)
dlin.tw at gmail.com
Tue Sep 16 22:23:03 CDT 2008
Oh, this match utility can NOT work. It have ever workable.
Is there anyone know.
By the way, Matt, could u put it in default extension?
--- my ~/.hgrc begin
[extensions]
match= ~/tool/for_hg/match.py
--- my ~/.hgrc end
The error message is:
File "match.py", line 10, in match
data1 = repo[None][fname].data()
TypeError: 'parentrevspecrepo' object is unsubscriptable
On Sat, Jun 28, 2008 at 9:40 AM, Daniel(原志) <dlin.tw at gmail.com> wrote:
> Thank you very much.
> The file match is useful to me.
>
>
> On Sat, Jun 28, 2008 at 12:32 AM, Matt Mackall <mpm at selenic.com> wrote:
>
>>
>> On Fri, 2008-06-27 at 10:52 -0500, Matt Mackall wrote:
>> > There's no good shortcut for "compare a given file with all revisions
>> > of a file", no. That would make for a clever little extension.
>>
>> And I hacked one together:
>>
>> $ hg cat -r 3000 mercurial/localrepo.py > l
>> $ hg --config "extensions.match=" match l mercurial/localrepo.py
>> 0.00% 2967:eef469259745 tag: shorten hash in default commit message
>> 0.41% 3019:aebc3f64b20f fix incorrect warning when walking on a
>> particular r
>> 1.39% 2965:96d034d02d61 Demote a pull note to a debug message
>> 1.44% 3035:4d0e0f149581 localrepo: move the repo creation code, fail if
>> the
>> 1.58% 2961:5bb65c3945a3 localrepo.status: detect clean files even when
>> the m
>> 1.63% 3072:bc3fe3b5b785 Never apply string formatting to generated
>> errors wi
>> 1.94% 3079:4c9fcb5e3b82 If local repository is missing, make error
>> message c
>> 2.01% 2887:05257fd28591 filelog: add hash-based comparisons
>> 2.05% 3132:81da3c45aabd Move defaultrev into changectx
>> 2.23% 2875:3d6efcbbd1c9 remove localrepository.changes.
>>
>> This will work after I push out some other changes I've got queued:
>>
>> # match.py - extension to find the best matching file revision
>>
>> from mercurial.i18n import gettext as _
>> from mercurial import mdiff
>>
>> def match(ui, repo, fname, fname2=None):
>> '''find the best file match against all revisions'''
>> data1 = repo[None][fname].data()
>> f = fname2 or fname
>> fl = repo.file(f)
>>
>> stats = []
>> for r in fl:
>> n = fl.node(r)
>> data2 = fl.read(n)
>> length = 0
>> d = mdiff.unidiff(data1, "", data2, "", "a", "b")
>> for l in d.split('\n'):
>> if (l.startswith("+") and not l.startswith("+++ ") or
>> l.startswith("-") and not l.startswith("--- ")):
>> length += len(l) - 1
>> stats.append((length, fl.linkrev(n)))
>>
>> stats.sort()
>> for l, r in stats[:10]:
>> pct = 100.0 * l / len(data1 or " ")
>> c = repo[r]
>> d = c.description().splitlines()[0][:52]
>> ui.write("% 5.2f%% % 6d:%s %s\n" % (pct, r, str(c), d))
>>
>> cmdtable = {"match": (match, [], 'hg match file [file]')}
>>
>> --
>> Mathematics is the supreme nostalgia of our time.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://selenic.com/pipermail/mercurial/attachments/20080917/f64e8efd/attachment.htm
More information about the Mercurial
mailing list