We do the same as for hg outgoing, instead of relying on implicit passing
value by monkey punching them onto the repo object, we pass equivalent
information by argument to the proper function.
This is way cleaner.
pulkit |
hg-reviewers |
We do the same as for hg outgoing, instead of relying on implicit passing
value by monkey punching them onto the repo object, we pass equivalent
information by argument to the proper function.
This is way cleaner.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/commands.py (6 lines) | |||
M | mercurial/hg.py (23 lines) | |||
M | mercurial/subrepo.py (3 lines) |
ui.pager(b'incoming') | ui.pager(b'incoming') | ||||
ui.status( | ui.status( | ||||
_(b'comparing with %s\n') % urlutil.hidepassword(source) | _(b'comparing with %s\n') % urlutil.hidepassword(source) | ||||
) | ) | ||||
return bookmarks.incoming(ui, repo, other) | return bookmarks.incoming(ui, repo, other) | ||||
finally: | finally: | ||||
other.close() | other.close() | ||||
repo._subtoppath = ui.expandpath(source) | |||||
try: | |||||
return hg.incoming(ui, repo, source, opts) | return hg.incoming(ui, repo, source, opts) | ||||
finally: | |||||
del repo._subtoppath | |||||
@command( | @command( | ||||
b'init', | b'init', | ||||
remoteopts, | remoteopts, | ||||
_(b'[-e CMD] [--remotecmd CMD] [DEST]'), | _(b'[-e CMD] [--remotecmd CMD] [DEST]'), | ||||
helpcategory=command.CATEGORY_REPO_CREATION, | helpcategory=command.CATEGORY_REPO_CREATION, | ||||
helpbasic=True, | helpbasic=True, |
repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) | repo.ui.status(_(b"aborting the merge, updating back to %s\n") % node[:12]) | ||||
stats = mergemod.clean_update(repo[node]) | stats = mergemod.clean_update(repo[node]) | ||||
assert stats.unresolvedcount == 0 | assert stats.unresolvedcount == 0 | ||||
_showstats(repo, stats) | _showstats(repo, stats) | ||||
def _incoming( | def _incoming( | ||||
displaychlist, subreporecurse, ui, repo, source, opts, buffered=False | displaychlist, | ||||
subreporecurse, | |||||
ui, | |||||
repo, | |||||
source, | |||||
opts, | |||||
buffered=False, | |||||
subpath=None, | |||||
): | ): | ||||
""" | """ | ||||
Helper for incoming / gincoming. | Helper for incoming / gincoming. | ||||
displaychlist gets called with | displaychlist gets called with | ||||
(remoterepo, incomingchangesetlist, displayer) parameters, | (remoterepo, incomingchangesetlist, displayer) parameters, | ||||
and is supposed to contain only code that can't be unified. | and is supposed to contain only code that can't be unified. | ||||
""" | """ | ||||
srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch')) | srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch')) | ||||
srcs = list(srcs) | srcs = list(srcs) | ||||
if len(srcs) != 1: | if len(srcs) != 1: | ||||
msg = _('for now, incoming supports only a single source, %d provided') | msg = _('for now, incoming supports only a single source, %d provided') | ||||
msg %= len(srcs) | msg %= len(srcs) | ||||
raise error.Abort(msg) | raise error.Abort(msg) | ||||
source, branches = srcs[0] | source, branches = srcs[0] | ||||
if subpath is not None: | |||||
subpath = urlutil.url(subpath) | |||||
if subpath.isabs(): | |||||
source = bytes(subpath) | |||||
else: | |||||
p = urlutil.url(source) | |||||
p.path = os.path.normpath(b'%s/%s' % (p.path, subpath)) | |||||
source = bytes(p) | |||||
other = peer(repo, opts, source) | other = peer(repo, opts, source) | ||||
cleanupfn = other.close | cleanupfn = other.close | ||||
try: | try: | ||||
ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(source)) | ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(source)) | ||||
revs, checkout = addbranchrevs(repo, other, branches, opts.get(b'rev')) | revs, checkout = addbranchrevs(repo, other, branches, opts.get(b'rev')) | ||||
if revs: | if revs: | ||||
revs = [other.lookup(rev) for rev in revs] | revs = [other.lookup(rev) for rev in revs] | ||||
displaychlist(other, chlist, displayer) | displaychlist(other, chlist, displayer) | ||||
displayer.close() | displayer.close() | ||||
finally: | finally: | ||||
cleanupfn() | cleanupfn() | ||||
subreporecurse() | subreporecurse() | ||||
return 0 # exit code is zero since we found incoming changes | return 0 # exit code is zero since we found incoming changes | ||||
def incoming(ui, repo, source, opts): | def incoming(ui, repo, source, opts, subpath=None): | ||||
def subreporecurse(): | def subreporecurse(): | ||||
ret = 1 | ret = 1 | ||||
if opts.get(b'subrepos'): | if opts.get(b'subrepos'): | ||||
ctx = repo[None] | ctx = repo[None] | ||||
for subpath in sorted(ctx.substate): | for subpath in sorted(ctx.substate): | ||||
sub = ctx.sub(subpath) | sub = ctx.sub(subpath) | ||||
ret = min(ret, sub.incoming(ui, source, opts)) | ret = min(ret, sub.incoming(ui, source, opts)) | ||||
return ret | return ret | ||||
def display(other, chlist, displayer): | def display(other, chlist, displayer): | ||||
limit = logcmdutil.getlimit(opts) | limit = logcmdutil.getlimit(opts) | ||||
if opts.get(b'newest_first'): | if opts.get(b'newest_first'): | ||||
chlist.reverse() | chlist.reverse() | ||||
count = 0 | count = 0 | ||||
for n in chlist: | for n in chlist: | ||||
if limit is not None and count >= limit: | if limit is not None and count >= limit: | ||||
break | break | ||||
parents = [p for p in other.changelog.parents(n) if p != nullid] | parents = [p for p in other.changelog.parents(n) if p != nullid] | ||||
if opts.get(b'no_merges') and len(parents) == 2: | if opts.get(b'no_merges') and len(parents) == 2: | ||||
continue | continue | ||||
count += 1 | count += 1 | ||||
displayer.show(other[n]) | displayer.show(other[n]) | ||||
return _incoming(display, subreporecurse, ui, repo, source, opts) | return _incoming( | ||||
display, subreporecurse, ui, repo, source, opts, subpath=subpath | |||||
) | |||||
def _outgoing(ui, repo, dests, opts, subpath=None): | def _outgoing(ui, repo, dests, opts, subpath=None): | ||||
out = set() | out = set() | ||||
others = [] | others = [] | ||||
for path in urlutil.get_push_paths(repo, ui, dests): | for path in urlutil.get_push_paths(repo, ui, dests): | ||||
dest = path.pushloc or path.loc | dest = path.pushloc or path.loc | ||||
if subpath is not None: | if subpath is not None: |
return hg.outgoing(ui, self._repo, dest, opts, subpath=subpath) | return hg.outgoing(ui, self._repo, dest, opts, subpath=subpath) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def incoming(self, ui, source, opts): | def incoming(self, ui, source, opts): | ||||
if b'rev' in opts or b'branch' in opts: | if b'rev' in opts or b'branch' in opts: | ||||
opts = copy.copy(opts) | opts = copy.copy(opts) | ||||
opts.pop(b'rev', None) | opts.pop(b'rev', None) | ||||
opts.pop(b'branch', None) | opts.pop(b'branch', None) | ||||
return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts) | subpath = subrepoutil.repo_rel_or_abs_source(self._repo) | ||||
return hg.incoming(ui, self._repo, source, opts, subpath=subpath) | |||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def files(self): | def files(self): | ||||
rev = self._state[1] | rev = self._state[1] | ||||
ctx = self._repo[rev] | ctx = self._repo[rev] | ||||
return ctx.manifest().keys() | return ctx.manifest().keys() | ||||
def filedata(self, name, decode): | def filedata(self, name, decode): |