comparison hgext/fetch.py @ 50876:eeffc9687c9a

fetch: migrate `opts` to native kwargs
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 20 Aug 2023 16:10:22 -0400
parents c130d2d8d775
children f4733654f144
comparison
equal deleted inserted replaced
50875:00081fa564ed 50876:eeffc9687c9a
72 See :hg:`help dates` for a list of formats valid for -d/--date. 72 See :hg:`help dates` for a list of formats valid for -d/--date.
73 73
74 Returns 0 on success. 74 Returns 0 on success.
75 """ 75 """
76 76
77 opts = pycompat.byteskwargs(opts) 77 date = opts.get('date')
78 date = opts.get(b'date')
79 if date: 78 if date:
80 opts[b'date'] = dateutil.parsedate(date) 79 opts['date'] = dateutil.parsedate(date)
81 80
82 parent = repo.dirstate.p1() 81 parent = repo.dirstate.p1()
83 branch = repo.dirstate.branch() 82 branch = repo.dirstate.branch()
84 try: 83 try:
85 branchnode = repo.branchtip(branch) 84 branchnode = repo.branchtip(branch)
107 b'(use "hg heads ." and "hg merge" to merge)' 106 b'(use "hg heads ." and "hg merge" to merge)'
108 ) 107 )
109 ) 108 )
110 109
111 path = urlutil.get_unique_pull_path_obj(b'fetch', ui, source) 110 path = urlutil.get_unique_pull_path_obj(b'fetch', ui, source)
112 other = hg.peer(repo, opts, path) 111 other = hg.peer(repo, pycompat.byteskwargs(opts), path)
113 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(path.loc)) 112 ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(path.loc))
114 revs = None 113 revs = None
115 if opts[b'rev']: 114 if opts['rev']:
116 try: 115 try:
117 revs = [other.lookup(rev) for rev in opts[b'rev']] 116 revs = [other.lookup(rev) for rev in opts['rev']]
118 except error.CapabilityError: 117 except error.CapabilityError:
119 err = _( 118 err = _(
120 b"other repository doesn't support revision lookup, " 119 b"other repository doesn't support revision lookup, "
121 b"so a rev cannot be specified." 120 b"so a rev cannot be specified."
122 ) 121 )
160 err = False 159 err = False
161 if newheads: 160 if newheads:
162 # By default, we consider the repository we're pulling 161 # By default, we consider the repository we're pulling
163 # *from* as authoritative, so we merge our changes into 162 # *from* as authoritative, so we merge our changes into
164 # theirs. 163 # theirs.
165 if opts[b'switch_parent']: 164 if opts['switch_parent']:
166 firstparent, secondparent = newparent, newheads[0] 165 firstparent, secondparent = newparent, newheads[0]
167 else: 166 else:
168 firstparent, secondparent = newheads[0], newparent 167 firstparent, secondparent = newheads[0], newparent
169 ui.status( 168 ui.status(
170 _(b'updating to %d:%s\n') 169 _(b'updating to %d:%s\n')
177 ) 176 )
178 err = hg.merge(p2ctx, remind=False) 177 err = hg.merge(p2ctx, remind=False)
179 178
180 if not err: 179 if not err:
181 # we don't translate commit messages 180 # we don't translate commit messages
182 message = cmdutil.logmessage(ui, opts) or ( 181 message = cmdutil.logmessage(ui, pycompat.byteskwargs(opts)) or (
183 b'Automated merge with %s' % urlutil.removeauth(other.url()) 182 b'Automated merge with %s' % urlutil.removeauth(other.url())
184 ) 183 )
185 editopt = opts.get(b'edit') or opts.get(b'force_editor') 184 editopt = opts.get('edit') or opts.get('force_editor')
186 editor = cmdutil.getcommiteditor(edit=editopt, editform=b'fetch') 185 editor = cmdutil.getcommiteditor(edit=editopt, editform=b'fetch')
187 n = repo.commit( 186 n = repo.commit(message, opts['user'], opts['date'], editor=editor)
188 message, opts[b'user'], opts[b'date'], editor=editor
189 )
190 ui.status( 187 ui.status(
191 _(b'new changeset %d:%s merges remote changes with local\n') 188 _(b'new changeset %d:%s merges remote changes with local\n')
192 % (repo.changelog.rev(n), short(n)) 189 % (repo.changelog.rev(n), short(n))
193 ) 190 )
194 191