Re: [StGit PATCH 1/5] Check for local changes with "goto"
- From
Karl Hasselström <kha@treskal.com>
- Date
- Mar 17, 2009, 07:06 UTC
- Message-ID
- <20090317070654.GA3716@diana.vm.bytemark.co.uk>
- In-Reply-To
- <b0943d9e0903160756g79ac3464i4bb6f7f61ba0555a@mail.gmail.com>
On 2009-03-16 14:56:11 +0000, Catalin Marinas wrote:
Show 17 quoted lines
> 2009/3/13 Karl Hasselström <kha@treskal.com>:
>
> > "Repository" is misleading here. Maybe something like
> >
> > ix_c = iw.index.is_clean(self.stack.head)
> > wt_c = iw.worktree_clean()
> > if not ix_c or not wt_c:
> > self.__halt('%s not clean. Use "refresh" or "status --reset"'
> > % { (False, True): 'Index', (True, False): 'Worktree',
> > (False, False): 'Index and worktree' }[(ix_c, wt_c)])
>
> I added two separate if's as I don't find the above readable :-)
>
> if not iw.worktree_clean():
> self.__halt('Worktree not clean. Use "refresh" or "status --reset"')
> if not iw.index.is_clean(self.stack.head):
> self.__halt('Index not clean. Use "refresh" or "status --reset"')It's actually quite nice once you get used to the idea of ephemeral dictionaries just for selection inside an expression ... :-)
Your version doesn't generate the "Your index and worktree are both dirty" warning, but I guess that's OK.
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle