Patchwork D1073: commands: move a bunch of statements into if True for next patch

login
register
mail settings
Submitter phabricator
Date Oct. 14, 2017, 2:41 p.m.
Message ID <differential-rev-PHID-DREV-cvsdwpdr7bmyehmrpxtj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/24898/
State Superseded
Headers show

Comments

phabricator - Oct. 14, 2017, 2:41 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch moves a bunch of statements under if True to reduce the noise for the
  next patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1073

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 15, 2017, 8:40 a.m.
dlax requested changes to this revision.
dlax added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> commands.py:1048
>              scmutil.checknewlabel(repo, label, 'branch')
> -            repo.dirstate.setbranch(label)
> -            ui.status(_('marked working directory as branch %s\n') % label)
> -
> -            # find any open named branches aside from default
> -            others = [n for n, h, t, c in repo.branchmap().iterbranches()
> -                      if n != "default" and not c]
> -            if not others:
> -                ui.status(_('(branches are permanent and global, '
> -                            'did you want a bookmark?)\n'))
> +            if True:
> +                repo.dirstate.setbranch(label)

Instead of this, you could use an early `return` in the next patch as:

  --- a/mercurial/commands.py
  +++ b/mercurial/commands.py
  @@ -1045,6 +1045,10 @@ def branch(ui, repo, label=None, **opts)
                                        # i18n: "it" refers to an existing branch
                                        hint=_("use 'hg update' to switch to it"))
               scmutil.checknewlabel(repo, label, 'branch')
  +
  +            if revs:
  +                return cmdutil.changebranch(ui, repo, revs, label)
  +
               repo.dirstate.setbranch(label)
               ui.status(_('marked working directory as branch %s\n') % label)

and drop this one.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1073

To: pulkit, #hg-reviewers, dlax
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1045,15 +1045,16 @@ 
                                      # i18n: "it" refers to an existing branch
                                      hint=_("use 'hg update' to switch to it"))
             scmutil.checknewlabel(repo, label, 'branch')
-            repo.dirstate.setbranch(label)
-            ui.status(_('marked working directory as branch %s\n') % label)
-
-            # find any open named branches aside from default
-            others = [n for n, h, t, c in repo.branchmap().iterbranches()
-                      if n != "default" and not c]
-            if not others:
-                ui.status(_('(branches are permanent and global, '
-                            'did you want a bookmark?)\n'))
+            if True:
+                repo.dirstate.setbranch(label)
+                ui.status(_('marked working directory as branch %s\n') % label)
+
+                # find any open named branches aside from default
+                others = [n for n, h, t, c in repo.branchmap().iterbranches()
+                          if n != "default" and not c]
+                if not others:
+                    ui.status(_('(branches are permanent and global, '
+                                'did you want a bookmark?)\n'))
 
 @command('branches',
     [('a', 'active', False,