[PATCH 0 of 4] keyword: clean up verbosity and kwdemo
Christian Ebert
blacktrash at gmx.net
Mon Mar 22 06:57:02 CDT 2010
* Martin Geisler on Wednesday, March 17, 2010 at 11:03:50 +0100
> Christian Ebert <blacktrash at gmx.net> writes:
>> These 4 patches deal with keyword's verbosity when overwriting
>> (commit, kwexpand, kwshrink) and in kwdemo.
>>
>> overwrite: simply use ui.note, do not customize verbosity.
>> Makes hg commit -v more verbose, but there is no need
>> for keyword to have a "customized" verbose option.
>>
>> kwdemo: restrain information strictly to keyword related stuff.
>> At the same time a bit of a cleanup for this messy
>> function.
>
> Thanks, I like how this simplifies the code. Pushed to crew.
>
> I was debating whether the extra output in 'hg commit -v' will confuse
> scripts that parse the output. But I'm not sure why a script would parse
> the output to get the list of committed files when 'hg status' is more
> suited for this.
I've debated this with myself some more, because it still feels
somewhat unclean.
The following does this:
- keep / revert to previous behaviour for hg commit -v
(no messages)
- change the message format for hg commit --debug to a simple
one-liner
Advantage: clear distinction between hg commit and
kwexpand/kwshrink, hopefully in the code as well
Disadvantage: slightly more code than current version
What do you think?
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -173,6 +173,7 @@
self.restrict = True # do not expand when reading
msg = (expand and _('overwriting %s expanding keywords\n')
or _('overwriting %s shrinking keywords\n'))
+ overwritten = 0
for f in candidates:
fp = self.repo.file(f)
data = fp.read(mf[f])
@@ -186,10 +187,14 @@
else:
found = self.re_kw.search(data)
if found:
- self.ui.note(msg % f)
self.repo.wwrite(f, data, mf.flags(f))
if node is None:
+ self.ui.note(msg % f)
self.repo.dirstate.normal(f)
+ else:
+ overwritten += 1
+ if overwritten:
+ self.ui.debug('keywords expanded in %d files\n' % overwritten)
self.restrict = False
def shrinktext(self, text):
diff --git a/tests/test-keyword.out b/tests/test-keyword.out
--- a/tests/test-keyword.out
+++ b/tests/test-keyword.out
@@ -58,7 +58,7 @@
% commit
a
b
-overwriting a expanding keywords
+keywords expanded in 1 files
running hook commit.test: cp a hooktest
committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
% status
@@ -168,7 +168,7 @@
% commit
c
c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
-overwriting c expanding keywords
+keywords expanded in 1 files
committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
% cat a c
expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
@@ -233,7 +233,7 @@
? log
% commit
a
-overwriting a expanding keywords
+keywords expanded in 1 files
committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
% status
? c
@@ -295,7 +295,7 @@
% commit rejecttest
a
-overwriting a expanding keywords
+keywords expanded in 1 files
committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
% export
% import
@@ -319,7 +319,7 @@
abort: outstanding uncommitted changes
x/a
x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
-overwriting x/a expanding keywords
+keywords expanded in 1 files
committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
% cat a
expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
c
--
Was heißt hier Dogma, ich bin Underdogma!
[ What the hell do you mean dogma, I am underdogma. ]
free movies --->>> http://www.blacktrash.org/underdogma/
http://itunes.apple.com/podcast/underdogma-movies/id363423596
More information about the Mercurial-devel
mailing list