Mercurial > hgsubversion
comparison utility_commands.py @ 257:ffccf0080e54
Move wrappers for hg commands to their own module.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Fri, 10 Apr 2009 22:38:29 -0500 |
| parents | 7932d098cb5f |
| children | d978192f0d63 |
comparison
equal
deleted
inserted
replaced
| 256:7932d098cb5f | 257:ffccf0080e54 |
|---|---|
| 1 import os | 1 import os |
| 2 | 2 |
| 3 import mercurial | |
| 4 from mercurial import cmdutil as hgcmdutil | |
| 5 from mercurial import node | 3 from mercurial import node |
| 6 from mercurial import util as hgutil | 4 from mercurial import util as hgutil |
| 7 from hgext import rebase as hgrebase | 5 from hgext import rebase as hgrebase |
| 8 | 6 |
| 9 import svnwrap | 7 import svnwrap |
| 100 'date': hgutil.datestr(parent.date(), | 98 'date': hgutil.datestr(parent.date(), |
| 101 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') | 99 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') |
| 102 }) | 100 }) |
| 103 | 101 |
| 104 | 102 |
| 105 def parent(orig, ui, repo, *args, **opts): | |
| 106 """show Mercurial & Subversion parents of the working dir or revision | |
| 107 """ | |
| 108 if not opts.get('svn', False): | |
| 109 return orig(ui, repo, *args, **opts) | |
| 110 hge = hg_delta_editor.HgChangeReceiver(repo=repo) | |
| 111 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), | |
| 112 hge.revmap.iterkeys())) | |
| 113 ha = cmdutil.parentrev(ui, repo, hge, svn_commit_hashes) | |
| 114 if ha.node() == node.nullid: | |
| 115 raise mutil.Abort('No parent svn revision!') | |
| 116 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) | |
| 117 displayer.show(ha) | |
| 118 return 0 | |
| 119 | |
| 120 | |
| 121 def rebase(ui, repo, extrafn=None, sourcerev=None, **opts): | 103 def rebase(ui, repo, extrafn=None, sourcerev=None, **opts): |
| 122 """rebase current unpushed revisions onto the Subversion head | 104 """rebase current unpushed revisions onto the Subversion head |
| 123 | 105 |
| 124 This moves a line of development from making its own head to the top of | 106 This moves a line of development from making its own head to the top of |
| 125 Subversion development, linearizing the changes. In order to make sure you | 107 Subversion development, linearizing the changes. In order to make sure you |
| 164 return hgrebase.rebase(ui, repo, dest=node.hex(target_rev.node()), | 146 return hgrebase.rebase(ui, repo, dest=node.hex(target_rev.node()), |
| 165 base=node.hex(sourcerev), | 147 base=node.hex(sourcerev), |
| 166 extrafn=extrafn) | 148 extrafn=extrafn) |
| 167 | 149 |
| 168 | 150 |
| 169 def outgoing(orig, ui, repo, dest=None, *args, **opts): | |
| 170 """show changesets not found in the Subversion repository | |
| 171 """ | |
| 172 svnurl = ui.expandpath(dest or 'default-push', dest or 'default') | |
| 173 if not (cmdutil.issvnurl(svnurl) or opts.get('svn', False)): | |
| 174 return orig(ui, repo, dest, *args, **opts) | |
| 175 | |
| 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()) | |
| 181 if not (o_r and len(o_r)): | |
| 182 ui.status('no changes found\n') | |
| 183 return 0 | |
| 184 displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False) | |
| 185 for node in reversed(o_r): | |
| 186 displayer.show(repo[node]) | |
| 187 | |
| 188 | |
| 189 def listauthors(ui, args, authors=None, **opts): | 151 def listauthors(ui, args, authors=None, **opts): |
| 190 """list all authors in a Subversion repository | 152 """list all authors in a Subversion repository |
| 191 """ | 153 """ |
| 192 if not len(args): | 154 if not len(args): |
| 193 ui.status('No repository specified.\n') | 155 ui.status('No repository specified.\n') |
