Changeset View
Changeset View
Standalone View
Standalone View
hgext/fetch.py
Show All 13 Lines | |||||
from mercurial import ( | from mercurial import ( | ||||
cmdutil, | cmdutil, | ||||
error, | error, | ||||
exchange, | exchange, | ||||
hg, | hg, | ||||
lock, | lock, | ||||
pycompat, | pycompat, | ||||
registrar, | registrar, | ||||
util, | |||||
) | ) | ||||
from mercurial.utils import dateutil | from mercurial.utils import ( | ||||
dateutil, | |||||
urlutil, | |||||
) | |||||
release = lock.release | release = lock.release | ||||
cmdtable = {} | cmdtable = {} | ||||
command = registrar.command(cmdtable) | command = registrar.command(cmdtable) | ||||
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | ||||
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | ||||
# be specifying the version(s) of Mercurial they are tested with, or | # be specifying the version(s) of Mercurial they are tested with, or | ||||
# leave the attribute unspecified. | # leave the attribute unspecified. | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | try: | ||||
_( | _( | ||||
b'multiple heads in this branch ' | b'multiple heads in this branch ' | ||||
b'(use "hg heads ." and "hg merge" to merge)' | b'(use "hg heads ." and "hg merge" to merge)' | ||||
) | ) | ||||
) | ) | ||||
other = hg.peer(repo, opts, ui.expandpath(source)) | other = hg.peer(repo, opts, ui.expandpath(source)) | ||||
ui.status( | ui.status( | ||||
_(b'pulling from %s\n') % util.hidepassword(ui.expandpath(source)) | _(b'pulling from %s\n') | ||||
% urlutil.hidepassword(ui.expandpath(source)) | |||||
) | ) | ||||
revs = None | revs = None | ||||
if opts[b'rev']: | if opts[b'rev']: | ||||
try: | try: | ||||
revs = [other.lookup(rev) for rev in opts[b'rev']] | revs = [other.lookup(rev) for rev in opts[b'rev']] | ||||
except error.CapabilityError: | except error.CapabilityError: | ||||
err = _( | err = _( | ||||
b"other repository doesn't support revision lookup, " | b"other repository doesn't support revision lookup, " | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | try: | ||||
ui.status( | ui.status( | ||||
_(b'merging with %d:%s\n') % (p2ctx.rev(), short(secondparent)) | _(b'merging with %d:%s\n') % (p2ctx.rev(), short(secondparent)) | ||||
) | ) | ||||
err = hg.merge(p2ctx, remind=False) | err = hg.merge(p2ctx, remind=False) | ||||
if not err: | if not err: | ||||
# we don't translate commit messages | # we don't translate commit messages | ||||
message = cmdutil.logmessage(ui, opts) or ( | message = cmdutil.logmessage(ui, opts) or ( | ||||
b'Automated merge with %s' % util.removeauth(other.url()) | b'Automated merge with %s' % urlutil.removeauth(other.url()) | ||||
) | ) | ||||
editopt = opts.get(b'edit') or opts.get(b'force_editor') | editopt = opts.get(b'edit') or opts.get(b'force_editor') | ||||
editor = cmdutil.getcommiteditor(edit=editopt, editform=b'fetch') | editor = cmdutil.getcommiteditor(edit=editopt, editform=b'fetch') | ||||
n = repo.commit( | n = repo.commit( | ||||
message, opts[b'user'], opts[b'date'], editor=editor | message, opts[b'user'], opts[b'date'], editor=editor | ||||
) | ) | ||||
ui.status( | ui.status( | ||||
_(b'new changeset %d:%s merges remote changes with local\n') | _(b'new changeset %d:%s merges remote changes with local\n') | ||||
% (repo.changelog.rev(n), short(n)) | % (repo.changelog.rev(n), short(n)) | ||||
) | ) | ||||
return err | return err | ||||
finally: | finally: | ||||
release(lock, wlock) | release(lock, wlock) |