comparison utility_commands.py @ 256:7932d098cb5f

Refactor commands to wrap their hg equivalent adding a --svn flag where sane.
author Augie Fackler <durin42@gmail.com>
date Fri, 10 Apr 2009 18:47:18 -0500
parents 9ba31af57e4b
children ffccf0080e54
comparison
equal deleted inserted replaced
255:246aaefb1cc0 256:7932d098cb5f
100 'date': hgutil.datestr(parent.date(), 100 'date': hgutil.datestr(parent.date(),
101 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') 101 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
102 }) 102 })
103 103
104 104
105 def parent(ui, repo, hg_repo_path, **opts): 105 def parent(orig, ui, repo, *args, **opts):
106 """show Mercurial & Subversion parents of the working dir or revision 106 """show Mercurial & Subversion parents of the working dir or revision
107 """ 107 """
108 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, 108 if not opts.get('svn', False):
109 ui_=ui) 109 return orig(ui, repo, *args, **opts)
110 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
110 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), 111 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
111 hge.revmap.iterkeys())) 112 hge.revmap.iterkeys()))
112 ha = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) 113 ha = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes)
113 if ha.node() != node.nullid: 114 if ha.node() == node.nullid:
114 r, br = svn_commit_hashes[ha.node()] 115 raise mutil.Abort('No parent svn revision!')
115 ui.status('Working copy parent revision is %s: r%s on %s\n' % 116 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
116 (ha, r, br or 'trunk')) 117 displayer.show(ha)
117 else:
118 ui.status('Working copy seems to have no parent svn revision.\n')
119 return 0 118 return 0
120 119
121 120
122 def rebase(ui, repo, extrafn=None, sourcerev=None, **opts): 121 def rebase(ui, repo, extrafn=None, sourcerev=None, **opts):
123 """rebase current unpushed revisions onto the Subversion head 122 """rebase current unpushed revisions onto the Subversion head
165 return hgrebase.rebase(ui, repo, dest=node.hex(target_rev.node()), 164 return hgrebase.rebase(ui, repo, dest=node.hex(target_rev.node()),
166 base=node.hex(sourcerev), 165 base=node.hex(sourcerev),
167 extrafn=extrafn) 166 extrafn=extrafn)
168 167
169 168
170 def outgoing(ui, repo, hg_repo_path, **opts): 169 def outgoing(orig, ui, repo, dest=None, *args, **opts):
171 """show changesets not found in the Subversion repository 170 """show changesets not found in the Subversion repository
172 """ 171 """
173 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, 172 svnurl = ui.expandpath(dest or 'default-push', dest or 'default')
174 ui_=ui) 173 if not (cmdutil.issvnurl(svnurl) or opts.get('svn', False)):
175 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), 174 return orig(ui, repo, dest, *args, **opts)
176 hge.revmap.iterkeys())) 175
177 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, repo.parents()[0].node()) 176 hge = hg_delta_editor.HgChangeReceiver(repo=repo)
177 svn_commit_hashes = dict(zip(hge.revmap.itervalues(),
178 hge.revmap.iterkeys()))
179 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes,
180 repo.parents()[0].node())
178 if not (o_r and len(o_r)): 181 if not (o_r and len(o_r)):
179 ui.status('No outgoing changes found.\n') 182 ui.status('no changes found\n')
180 return 0 183 return 0
181 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) 184 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
182 for node in reversed(o_r): 185 for node in reversed(o_r):
183 displayer.show(repo[node]) 186 displayer.show(repo[node])
184 187
212 nourl = ['version', 'listauthors'] 215 nourl = ['version', 'listauthors']
213 table = { 216 table = {
214 'url': url, 217 'url': url,
215 'genignore': genignore, 218 'genignore': genignore,
216 'info': info, 219 'info': info,
217 'parent': parent,
218 'outgoing': outgoing,
219 'listauthors': listauthors, 220 'listauthors': listauthors,
220 'version': version, 221 'version': version,
221 'rebase': rebase, 222 'rebase': rebase,
222 } 223 }