[PATCH 1 of 1] subrepo: make update -C for svn and git subrepos clean the working directory
Eric Eisner
ede at mit.edu
Fri Jan 28 11:14:51 CST 2011
On Fri, Jan 28, 2011 at 04:51, Erik Zielke <ez at aragost.com> wrote:
> # HG changeset patch
> # User Erik Zielke <ez at aragost.com>
> # Date 1296135382 -3600
> # Node ID 287c61b23a2cbd2c9b2d085a21380fa6310c9f8d
> # Parent a94042c6fca18bb3ead93ac6f3a8d38867569de4
> subrepo: make update -C for svn and git subrepos clean the working
> directory
>
> @@ -749,9 +751,10 @@
> out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
> return code == 1
>
> - def get(self, state):
> + def get(self, state, overwrite=False):
> source, revision, kind = state
> self._fetch(source, revision)
> +
> # if the repo was set to be bare, unbare it
> if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
> self._gitcommand(['config', 'core.bare', 'false'])
> @@ -759,16 +762,26 @@
> self._gitcommand(['reset', '--hard', 'HEAD'])
> return
> elif self._gitstate() == revision:
> + if overwrite:
> + self._gitcommand(['reset', 'HEAD', '.'])
>
+ self._gitcommand(['reset', '--hard', 'HEAD'])
>
It looks strange to call reset twice in a row. Maybe add a comment to
explain why we need to abuse git's interface to mimic hg's --clean
semantics.
The extra '.' argument is unnecessary and therefore confusing. It restricts
reset to '.', the working directory, which is everything.
> return
> branch2rev, rev2branch = self._gitbranchmap()
>
> + def checkout(args):
> + cmd = ['checkout']
> + if overwrite:
> + self._gitcommand(['reset', 'HEAD', '.'])
>
Same two comments as above.
> + cmd.append('-f')
> + self._gitcommand(cmd + args)
> +
> def rawcheckout():
> # no branch to checkout, check it out with no branch
>
> diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
> --- a/tests/test-subrepo-git.t
> +++ b/tests/test-subrepo-git.t
> @@ -304,3 +304,26 @@
> $ ls ../narchive/inner/s | grep -v pax_global_header
> f
> g
> +
> +Check hg update --clean
> + $ cd $TESTTMP/t
> + $ echo > s/g
> + $ cd s
> + $ echo c1 > f1
> + $ echo c1 > f2
> + $ git add f1
> + $ git status --short
> + A f1
> + M g
> + ?? f2
> + $ cd ..
> + $ hg update -C
> + From $TESTTMP/t/../gitroot
> + 126f2a1..32a3438 testing -> origin/testing
> + Switched to a new branch 'origin/testing'
> + pulling subrepo s
> + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
> + $ cd s
> + $ git status --short
> + ?? f1
> + ?? f2
>
There are some issues in this test with old git 1.5.6.5: status doesn't have
--short; checkout doesn't print anything. But the functionality seems to
work so these can be fixed in a followup patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110128/6b5d7646/attachment.htm>
More information about the Mercurial-devel
mailing list