Merge lp://qastaging/~amanica/bzr-externals/ecmd into lp://qastaging/bzr-externals
- ecmd
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://qastaging/~amanica/bzr-externals/ecmd |
Merge into: | lp://qastaging/bzr-externals |
Diff against target: |
184 lines (+82/-21) 3 files modified
__init__.py (+5/-2) cli.py (+47/-0) externals.py (+30/-19) |
To merge this branch: | bzr merge lp://qastaging/~amanica/bzr-externals/ecmd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Eugene Tarasenko | Approve | ||
Alexander Belchenko (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marius Kruger (amanica) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Eugene Tarasenko (etarasenko) wrote : | # |
Thanks that have found time to improve this plugin, but tell me as you are going to use ecmd? What use case?
Also your variant does not work with commands qbzr:
C:\Temp\
# qdiff
# C:/Temp/
bzr: ERROR: exceptions.
Traceback (most recent call last):
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "C:/Program Files/Bazaar/
File "C:/Program Files/Bazaar/
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
NotImplementedE
bzr 2.1.0 on python 2.5.4 (Windows-
arguments: ['C:\\Program Files\\
encoding: 'cp1251', fsenc: 'mbcs', lang: None
plugins:
bzrtools C:\Program Files\Bazaar\
explorer C:\Program Files\Bazaar\
externals C:\Program Files\Bazaar\
launchpad C:\Program Files\Bazaar\
netrc_
qbzr C:\Program Files\Bazaar\
rebase C:\Program Files\Bazaar\
svn C:\Program Files\Bazaar\
upload C:\Program Files\Bazaar\
xmloutput C:\Program Files\Bazaar\
*** Bazaar has encountered an internal error. This probably indicates a
bug in Bazaar. You can help us fix it by filing a bug report at
https:/
including this traceback and a description of the problem.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Marius Kruger пишет:
> Marius Kruger has proposed merging lp:~amanica/bzr-externals/ecmd into lp:bzr-externals.
> I needed functionality similar to scmproj's pcmd command,
> so I quickly implemented a ecmd.
> It is heavily borrowed from scmproj, so you are welcome to merge this if Alexander (bialix) is ok with it.
I have no objections to borrow scmproj code. :-)
I will look on your patch on weekend.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marius Kruger (amanica) wrote : | # |
I use it from the commandline and scripts because its very powerful
especially for commands that we don't support specifically. So don't really
imagine it to work well with qbzr. Use case examples I remember using so
far:
bzr ecmd status (to show the status for all branches)
bzr ecmd -- commit -m 'bump version' pom.xml
bzr ecmd log -r-1..
bzr ecmd revno
Etc.
On Feb 19, 2010 8:11 AM, "Eugene Tarasenko" <email address hidden>
wrote:
Review: Needs Fixing
Thanks that have found time to improve this plugin, but tell me as you are
going to use ecmd? What use case?
Also your variant does not work with commands qbzr:
C:\Temp\
# qdiff
# C:/Temp/
bzr: ERROR: exceptions.
make_output_stream
Traceback (most recent call last):
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "C:/Program Files/Bazaar/
File "C:/Program Files/Bazaar/
run_cmd
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
NotImplementedE
bzr 2.1.0 on python 2.5.4 (Windows-
arguments: ['C:\\Program Files\\
encoding: 'cp1251', fsenc: 'mbcs', lang: None
plugins:
bzrtools C:\Program Files\Bazaar\
explorer C:\Program Files\Bazaar\
externals C:\Program Files\Bazaar\
launchpad C:\Program Files\Bazaar\
netrc_
Files\Bazaar\
qbzr C:\Program Files\Bazaar\
rebase C:\Program Files\Bazaar\
svn C:\Program Files\Bazaar\
upload C:\Program Files\Bazaar\
xmloutput C:\Program Files\Bazaar\
*** Bazaar has encountered an internal error. This probably indicates a
bug in Bazaar. You can help us fix it by filing a bug report at
https:/
including this traceback and a description of the problem.
--
https:/
You are the owner of lp:~amanica...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Marius, why you're using run_bzr_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
OK, I see, it's used that way in scmproj.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Eugene, are you running ecmd via qrun dialog?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
OK, this is problem in QBzr itself. I'm investigate it now.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Marius' patch is correct.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
- 20. By Marius Kruger <email address hidden>
-
support adjusting the command verbosity separate from reporting our actions
otherwise it gets adjusted for each component eg:
$ bzr ecmd missing -v
# missing
# Component1> missing -v
# Component2> missing -v -v
...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Eugene, I've fixed problem you mentioned in the QBzr itself. This should not block this patch anymore.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Eugene Tarasenko (etarasenko) wrote : | # |
Thanks Alexander, but I found another error with russian dirs. I try resolve this error, but not have time.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marius Kruger (amanica) wrote : | # |
If you have a specific problem, let me know, then I can also look at it.
Since its a new command its lower risk IMHO so it does not need to be
perfect from the start; we can fix specific thing as they come up.
On Feb 26, 2010 12:38 PM, "Eugene Tarasenko" <email address hidden>
wrote:
Thanks Alexander, but I found another error with russian dirs. I try resolve
this error, but not have time.
--
https:/
You are the owner of lp:~ama...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Eugene Tarasenko (etarasenko) wrote : | # |
Is fix errors and merge.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Eugene Tarasenko (etarasenko) wrote : | # |
I found bug bzr not accepted arguments with symbol '-' for command.
Example:
bzr ecmd log -r-1 # bzr: ERROR: no such option: -r
bzr ecmd log # is ok
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Eugene Tarasenko пишет:
> I found bug bzr not accepted arguments with symbol '-' for command.
I does not accept options, because they are started with dash.
> Example:
> bzr ecmd log -r-1 # bzr: ERROR: no such option: -r
Should be
bzr ecmd -- log -r-1
This is how bzr command-line parser works. Two dashes means: "there is
no options anymore, treat the end of the line as arguments".
> bzr ecmd log # is ok
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alexander Belchenko (bialix) wrote : | # |
Alexander Belchenko пишет:
> Eugene Tarasenko пишет:
>> I found bug bzr not accepted arguments with symbol '-' for command.
>
> I does not accept options, because they are started with dash.
s/I/It/
Preview Diff
1 | === modified file '__init__.py' |
2 | --- __init__.py 2009-12-05 08:02:27 +0000 |
3 | +++ __init__.py 2010-02-25 13:26:16 +0000 |
4 | @@ -45,7 +45,8 @@ |
5 | * Does not support lightweight checkout. |
6 | """ |
7 | |
8 | -from bzrlib import branch |
9 | +from bzrlib import branch, progress |
10 | +from bzrlib.commands import plugin_cmds |
11 | |
12 | plugin_name = 'externals' |
13 | version_info = (1, 1, 0) |
14 | @@ -82,6 +83,8 @@ |
15 | from bzrlib import ui |
16 | ui.ui_factory.clear_term() |
17 | |
18 | -from bzrlib import progress |
19 | old_finished = progress.ProgressTask.finished |
20 | progress.ProgressTask.finished = new_finished |
21 | + |
22 | +plugin_cmds.register_lazy('cmd_externals_command', 'ecmd', |
23 | + 'bzrlib.plugins.externals.cli') |
24 | |
25 | === added file 'cli.py' |
26 | --- cli.py 1970-01-01 00:00:00 +0000 |
27 | +++ cli.py 2010-02-25 13:26:16 +0000 |
28 | @@ -0,0 +1,47 @@ |
29 | +from bzrlib import bzrdir |
30 | +from bzrlib.commands import Command, run_bzr_catch_user_errors |
31 | +from bzrlib.option import Option |
32 | +from bzrlib.plugins.externals.externals import Externals |
33 | +from bzrlib.urlutils import local_path_from_url |
34 | +import os, os.path |
35 | + |
36 | +class cmd_externals_command(Command): |
37 | + """Run some command(s) for this and external branches.""" |
38 | + aliases = ['ecmd'] |
39 | + takes_args = ['command+'] |
40 | + takes_options = [ |
41 | + 'verbose', |
42 | + 'dry-run', |
43 | + Option('shell', short_name='s', |
44 | + help='Run shell commands instead of bzr commands.'), |
45 | + Option('externals_only', short_name='e', |
46 | + help='Don\'t run on the main branch.'), |
47 | + ] |
48 | + |
49 | + def run(self, command_list, verbose=False, dry_run=False, |
50 | + shell=False, externals_only=False): |
51 | + # TODO: support setting the base location with -d |
52 | + basebzrdir, relpath = bzrdir.BzrDir.open_containing('.') |
53 | + branch = basebzrdir.open_branch() |
54 | + base_dir = local_path_from_url(branch.base) |
55 | + externals = Externals(branch, branch.last_revision()) |
56 | + externals.adjust_verbosity(command_list) |
57 | + if not externals_only: |
58 | + self.run_cmd(externals, command_list, '', base_dir, |
59 | + dry_run, shell) |
60 | + |
61 | + if externals.read_config(): |
62 | + orig_cwd = os.getcwdu() |
63 | + for location, dir, revision, bound in externals.branch_iterator(): |
64 | + self.run_cmd(externals, command_list, dir, base_dir, |
65 | + dry_run, shell) |
66 | + |
67 | + def run_cmd(self, externals, command_list, dir, base_dir, dry_run, shell): |
68 | + externals.report(command_list, relpath=dir) |
69 | + if not dry_run: |
70 | + os.chdir(os.path.join(base_dir, dir)) |
71 | + if shell: |
72 | + ret = os.system(' '.join(command_list)) |
73 | + else: |
74 | + run_bzr_catch_user_errors(command_list) |
75 | + os.chdir(base_dir) |
76 | |
77 | === modified file 'externals.py' |
78 | --- externals.py 2009-12-05 08:02:27 +0000 |
79 | +++ externals.py 2010-02-25 13:26:16 +0000 |
80 | @@ -20,7 +20,7 @@ |
81 | from bzrlib import branch |
82 | from bzrlib.urlutils import join, local_path_from_url |
83 | from bzrlib.osutils import check_legal_path, getcwd, get_user_encoding, isdir, isfile, pathjoin, relpath |
84 | -from bzrlib.commands import run_bzr, shlex_split_unicode |
85 | +from bzrlib.commands import run_bzr, shlex_split_unicode, plugin_cmds |
86 | from bzrlib.trace import is_quiet, is_verbose, note |
87 | |
88 | CONFIG_PATH = '.bzrmeta/externals' |
89 | @@ -91,36 +91,38 @@ |
90 | return join(base, relative) |
91 | |
92 | @staticmethod |
93 | - def _report(cmd): |
94 | + def report(cmd, relpath=None): |
95 | + if not is_quiet(): |
96 | + desc = '# ' |
97 | + if relpath: |
98 | + desc += relpath + '> ' |
99 | + desc += ' '.join(cmd) |
100 | + note(desc) |
101 | + |
102 | + @staticmethod |
103 | + def adjust_verbosity(cmd): |
104 | if is_quiet(): |
105 | cmd += ['-q'] |
106 | - else: |
107 | - desc = 'External' |
108 | - for param in cmd: |
109 | - desc += ' ' + param |
110 | - note(desc) |
111 | - |
112 | if is_verbose(): |
113 | cmd += ['-v'] |
114 | |
115 | - def pull(self): |
116 | + def branch_iterator(self): |
117 | if self.config is None: |
118 | # branch not have externals configuration |
119 | return |
120 | |
121 | - is_bind = True |
122 | + bound = True |
123 | parent = self.branch.get_bound_location() |
124 | if not parent: |
125 | - is_bind = False |
126 | + bound = False |
127 | parent = self.branch.get_parent() |
128 | if not parent: |
129 | - # parent not found |
130 | - return |
131 | + # support new braches with no parent yet |
132 | + parent = self.branch.base |
133 | |
134 | encoding = get_user_encoding() |
135 | for line in self.config: |
136 | arg = shlex_split_unicode(line) # url directory [revision] |
137 | - |
138 | location = self._urljoin(parent, arg[0]) |
139 | if parent.startswith('file:///'): |
140 | # try to pull externals from the parent for the feature branch |
141 | @@ -135,18 +137,26 @@ |
142 | check_legal_path(arg[1]) |
143 | dir = self._relpath(pathjoin(self.root, arg[1])) |
144 | |
145 | + revision = None |
146 | + if len(arg) > 2: |
147 | + revision = arg[2] |
148 | + yield location, dir, revision, bound |
149 | + |
150 | + |
151 | + def pull(self): |
152 | + for location, dir, revision, bound in self.branch_iterator(): |
153 | if location == dir: |
154 | # not create feature branch for directory above the root |
155 | continue |
156 | |
157 | # select what do it |
158 | if isdir(pathjoin(dir, '.bzr')) or isdir(pathjoin(dir, '.svn')): |
159 | - if is_bind: |
160 | + if bound: |
161 | cmd = ['update', dir] |
162 | else: |
163 | cmd = ['pull', location, '--directory', dir] |
164 | else: |
165 | - if is_bind: |
166 | + if bound: |
167 | cmd = ['checkout', location, dir] |
168 | else: |
169 | cmd = ['branch', location, dir] |
170 | @@ -157,10 +167,11 @@ |
171 | os.makedirs(dirs[0].encode(encoding)) |
172 | |
173 | # if use revision options but not for 'update' |
174 | - if len(arg) > 2 and cmd[0] != 'update': |
175 | - cmd += ['--revision', arg[2]] |
176 | + if revision is not None and cmd[0] != 'update': |
177 | + cmd += ['--revision', revision] |
178 | |
179 | - self._report(cmd) |
180 | + self.adjust_verbosity(cmd) |
181 | + self.report(cmd) |
182 | run_bzr(cmd) |
183 | |
184 | def add_to_ignore(self): |
I needed functionality similar to scmproj's pcmd command,
so I quickly implemented a ecmd.
It is heavily borrowed from scmproj, so you are welcome to merge this if Alexander (bialix) is ok with it.