Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG2ff8994ac71d: cleanup: use repo['.'] instead of repo[None].p1()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | contrib/synthrepo.py (2 lines) | |||
| M | hgext/fastannotate/formatter.py (4 lines) | |||
| M | mercurial/commands.py (6 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Martin von Zweigbergk | Jan 26 2019, 2:43 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| _synthesizing = _('synthesizing') | _synthesizing = _('synthesizing') | ||||
| _files = _('initial files') | _files = _('initial files') | ||||
| _changesets = _('changesets') | _changesets = _('changesets') | ||||
| # Synthesize a single initial revision adding files to the repo according | # Synthesize a single initial revision adding files to the repo according | ||||
| # to the modeled directory structure. | # to the modeled directory structure. | ||||
| initcount = int(opts['initfiles']) | initcount = int(opts['initfiles']) | ||||
| if initcount and initdirs: | if initcount and initdirs: | ||||
| pctx = repo[None].p1() | pctx = repo['.'] | ||||
| dirs = set(pctx.dirs()) | dirs = set(pctx.dirs()) | ||||
| files = {} | files = {} | ||||
| def validpath(path): | def validpath(path): | ||||
| # Don't pick filenames which are already directory names. | # Don't pick filenames which are already directory names. | ||||
| if path in dirs: | if path in dirs: | ||||
| return False | return False | ||||
| # Don't pick directories which were used as file names. | # Don't pick directories which were used as file names. | ||||
| datefunc = util.cachefunc(datefunc) | datefunc = util.cachefunc(datefunc) | ||||
| getctx = util.cachefunc(lambda x: repo[x[0]]) | getctx = util.cachefunc(lambda x: repo[x[0]]) | ||||
| hexfunc = self._hexfunc | hexfunc = self._hexfunc | ||||
| # special handling working copy "changeset" and "rev" functions | # special handling working copy "changeset" and "rev" functions | ||||
| if self.opts.get('rev') == 'wdir()': | if self.opts.get('rev') == 'wdir()': | ||||
| orig = hexfunc | orig = hexfunc | ||||
| hexfunc = lambda x: None if x is None else orig(x) | hexfunc = lambda x: None if x is None else orig(x) | ||||
| wnode = hexfunc(repo[None].p1().node()) + '+' | wnode = hexfunc(repo['.'].node()) + '+' | ||||
| wrev = '%d' % repo[None].p1().rev() | wrev = '%d' % repo['.'].rev() | ||||
| wrevpad = '' | wrevpad = '' | ||||
| if not opts.get('changeset'): # only show + if changeset is hidden | if not opts.get('changeset'): # only show + if changeset is hidden | ||||
| wrev += '+' | wrev += '+' | ||||
| wrevpad = ' ' | wrevpad = ' ' | ||||
| revenc = lambda x: wrev if x is None else ('%d' % x) + wrevpad | revenc = lambda x: wrev if x is None else ('%d' % x) + wrevpad | ||||
| def csetenc(x): | def csetenc(x): | ||||
| if x is None: | if x is None: | ||||
| return wnode | return wnode | ||||
| if not opts.get('clean') and not label: | if not opts.get('clean') and not label: | ||||
| if revs: | if revs: | ||||
| raise error.Abort(_("no branch name specified for the revisions")) | raise error.Abort(_("no branch name specified for the revisions")) | ||||
| ui.write("%s\n" % repo.dirstate.branch()) | ui.write("%s\n" % repo.dirstate.branch()) | ||||
| return | return | ||||
| with repo.wlock(): | with repo.wlock(): | ||||
| if opts.get('clean'): | if opts.get('clean'): | ||||
| label = repo[None].p1().branch() | label = repo['.'].branch() | ||||
| repo.dirstate.setbranch(label) | repo.dirstate.setbranch(label) | ||||
| ui.status(_('reset working directory to branch %s\n') % label) | ui.status(_('reset working directory to branch %s\n') % label) | ||||
| elif label: | elif label: | ||||
| scmutil.checknewlabel(repo, label, 'branch') | scmutil.checknewlabel(repo, label, 'branch') | ||||
| if revs: | if revs: | ||||
| return cmdutil.changebranch(ui, repo, revs, label) | return cmdutil.changebranch(ui, repo, revs, label) | ||||
| extra = {} | extra = {} | ||||
| if opts.get('close_branch'): | if opts.get('close_branch'): | ||||
| extra['close'] = '1' | extra['close'] = '1' | ||||
| if not bheads: | if not bheads: | ||||
| raise error.Abort(_('can only close branch heads')) | raise error.Abort(_('can only close branch heads')) | ||||
| elif opts.get('amend'): | elif opts.get('amend'): | ||||
| if repo[None].p1().p1().branch() != branch and \ | if repo['.'].p1().branch() != branch and \ | ||||
| repo[None].p1().p2().branch() != branch: | repo['.'].p2().branch() != branch: | ||||
| raise error.Abort(_('can only close branch heads')) | raise error.Abort(_('can only close branch heads')) | ||||
| if opts.get('amend'): | if opts.get('amend'): | ||||
| if ui.configbool('ui', 'commitsubrepos'): | if ui.configbool('ui', 'commitsubrepos'): | ||||
| raise error.Abort(_('cannot amend with ui.commitsubrepos enabled')) | raise error.Abort(_('cannot amend with ui.commitsubrepos enabled')) | ||||
| old = repo['.'] | old = repo['.'] | ||||
| rewriteutil.precheck(repo, [old.rev()], 'amend') | rewriteutil.precheck(repo, [old.rev()], 'amend') | ||||