Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGc924e7dbcd0f: import: use context manager for wlock
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/commands.py (115 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Jun 14 2018, 6:12 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
raise error.Abort(_('cannot use --similarity with --bypass')) | raise error.Abort(_('cannot use --similarity with --bypass')) | ||||
if exact: | if exact: | ||||
if opts.get('edit'): | if opts.get('edit'): | ||||
raise error.Abort(_('cannot use --exact with --edit')) | raise error.Abort(_('cannot use --exact with --edit')) | ||||
if opts.get('prefix'): | if opts.get('prefix'): | ||||
raise error.Abort(_('cannot use --exact with --prefix')) | raise error.Abort(_('cannot use --exact with --prefix')) | ||||
base = opts["base"] | base = opts["base"] | ||||
wlock = dsguard = lock = tr = None | dsguard = lock = tr = None | ||||
msgs = [] | msgs = [] | ||||
ret = 0 | ret = 0 | ||||
with repo.wlock(): | |||||
try: | try: | ||||
wlock = repo.wlock() | |||||
if update: | if update: | ||||
cmdutil.checkunfinished(repo) | cmdutil.checkunfinished(repo) | ||||
if (exact or not opts.get('force')): | if (exact or not opts.get('force')): | ||||
cmdutil.bailifchanged(repo) | cmdutil.bailifchanged(repo) | ||||
if not opts.get('no_commit'): | if not opts.get('no_commit'): | ||||
lock = repo.lock() | lock = repo.lock() | ||||
tr = repo.transaction('import') | tr = repo.transaction('import') | ||||
else: | else: | ||||
dsguard = dirstateguard.dirstateguard(repo, 'import') | dsguard = dirstateguard.dirstateguard(repo, 'import') | ||||
parents = repo[None].parents() | parents = repo[None].parents() | ||||
for patchurl in patches: | for patchurl in patches: | ||||
if patchurl == '-': | if patchurl == '-': | ||||
ui.status(_('applying patch from stdin\n')) | ui.status(_('applying patch from stdin\n')) | ||||
patchfile = ui.fin | patchfile = ui.fin | ||||
patchurl = 'stdin' # for error message | patchurl = 'stdin' # for error message | ||||
else: | else: | ||||
patchurl = os.path.join(base, patchurl) | patchurl = os.path.join(base, patchurl) | ||||
ui.status(_('applying %s\n') % patchurl) | ui.status(_('applying %s\n') % patchurl) | ||||
patchfile = hg.openpath(ui, patchurl) | patchfile = hg.openpath(ui, patchurl) | ||||
haspatch = False | haspatch = False | ||||
for hunk in patch.split(patchfile): | for hunk in patch.split(patchfile): | ||||
with patch.extract(ui, hunk) as patchdata: | with patch.extract(ui, hunk) as patchdata: | ||||
msg, node, rej = cmdutil.tryimportone(ui, repo, patchdata, | msg, node, rej = cmdutil.tryimportone(ui, repo, | ||||
patchdata, | |||||
parents, opts, | parents, opts, | ||||
msgs, hg.clean) | msgs, hg.clean) | ||||
if msg: | if msg: | ||||
haspatch = True | haspatch = True | ||||
ui.note(msg + '\n') | ui.note(msg + '\n') | ||||
if update or exact: | if update or exact: | ||||
parents = repo[None].parents() | parents = repo[None].parents() | ||||
else: | else: | ||||
parents = [repo[node]] | parents = [repo[node]] | ||||
if rej: | if rej: | ||||
ui.write_err(_("patch applied partially\n")) | ui.write_err(_("patch applied partially\n")) | ||||
ui.write_err(_("(fix the .rej files and run " | ui.write_err(_("(fix the .rej files and run " | ||||
"`hg commit --amend`)\n")) | "`hg commit --amend`)\n")) | ||||
ret = 1 | ret = 1 | ||||
break | break | ||||
if not haspatch: | if not haspatch: | ||||
raise error.Abort(_('%s: no diffs found') % patchurl) | raise error.Abort(_('%s: no diffs found') % patchurl) | ||||
if tr: | if tr: | ||||
tr.close() | tr.close() | ||||
if msgs: | if msgs: | ||||
repo.savecommitmessage('\n* * *\n'.join(msgs)) | repo.savecommitmessage('\n* * *\n'.join(msgs)) | ||||
if dsguard: | if dsguard: | ||||
dsguard.close() | dsguard.close() | ||||
return ret | return ret | ||||
finally: | finally: | ||||
if tr: | if tr: | ||||
tr.release() | tr.release() | ||||
release(lock, dsguard, wlock) | release(lock, dsguard) | ||||
@command('incoming|in', | @command('incoming|in', | ||||
[('f', 'force', None, | [('f', 'force', None, | ||||
_('run even if remote repository is unrelated')), | _('run even if remote repository is unrelated')), | ||||
('n', 'newest-first', None, _('show newest record first')), | ('n', 'newest-first', None, _('show newest record first')), | ||||
('', 'bundle', '', | ('', 'bundle', '', | ||||
_('file to store the bundles into'), _('FILE')), | _('file to store the bundles into'), _('FILE')), | ||||
('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), | ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')), |