[PATCH] update: --check should fail if untracked files would be lost (issue2450)

Idan Kamara idankk86 at gmail.com
Fri Jun 10 03:12:34 CDT 2011


On Thu, Jun 9, 2011 at 3:48 AM, Mark Kendrat <swdev10 at live.com> wrote:

> # HG changeset patch
> # User Mark Kendrat <swdev10 at live.com>
> # Date 1307580470 14400
> # Node ID c187493d350a4afe8765d093cf0825a51bb5527b
> # Parent  48ec0763afbbbbb4802fb836ae75256e82e5609c
> update: --check should fail if untracked files would be lost (issue2450)
>
> diff -r 48ec0763afbb -r c187493d350a mercurial/commands.py
> --- a/mercurial/commands.py     Tue Jun 07 17:02:54 2011 -0500
> +++ b/mercurial/commands.py     Wed Jun 08 20:47:50 2011 -0400
> @@ -5027,7 +5027,7 @@
>         rev = cmdutil.finddate(ui, repo, date)
>
>     if clean or check:
> -        ret = hg.clean(repo, rev)
> +        ret = hg.clean(repo, rev, check=check)
>     else:
>         ret = hg.update(repo, rev)
>
> diff -r 48ec0763afbb -r c187493d350a mercurial/hg.py
> --- a/mercurial/hg.py   Tue Jun 07 17:02:54 2011 -0500
> +++ b/mercurial/hg.py   Wed Jun 08 20:47:50 2011 -0400
> @@ -395,9 +395,9 @@
>  # naming conflict in clone()
>  _update = update
>
> -def clean(repo, node, show_stats=True):
> +def clean(repo, node, show_stats=True, check=False):
>     """forcibly switch the working directory to node, clobbering changes"""
> -    stats = mergemod.update(repo, node, False, True, None)
> +    stats = mergemod.update(repo, node, False, True, None, check=check)
>     if show_stats:
>         _showstats(repo, stats)
>     return stats[3] > 0
> diff -r 48ec0763afbb -r c187493d350a mercurial/merge.py
> --- a/mercurial/merge.py        Tue Jun 07 17:02:54 2011 -0500
> +++ b/mercurial/merge.py        Wed Jun 08 20:47:50 2011 -0400
> @@ -443,7 +443,7 @@
>                 if f:
>                     repo.dirstate.drop(f)
>
> -def update(repo, node, branchmerge, force, partial, ancestor=None):
> +def update(repo, node, branchmerge, force, partial, ancestor=None,
> check=False):
>     """
>     Perform a merge between the working directory and the given node
>
> @@ -538,7 +538,7 @@
>         ### calculate phase
>         action = []
>         wc.status(unknown=True) # prime cache
> -        if not force:
> +        if not force or check:
>             _checkunknown(wc, p2)
>         if not util.checkcase(repo.path):
>             _checkcollision(p2)
> diff -r 48ec0763afbb -r c187493d350a tests/test-simple-update.t
> --- a/tests/test-simple-update.t        Tue Jun 07 17:02:54 2011 -0500
> +++ b/tests/test-simple-update.t        Wed Jun 08 20:47:50 2011 -0400
> @@ -54,3 +54,42 @@
>   $ hg upd -d foo 0
>   abort: you can't specify a revision and a date
>   [255]
> +
> +test for protection of untracked files using repo1 and repo2
> +
> +.. initial repo1
> +  $ hg init repo1
> +
> +.. repo2 is a clone that adds newfile and pushes back to repo1
> +  $ hg clone repo1 repo2
> +  updating to branch default
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ cd $TESTTMP/repo2
> +  cd: 42: can't cd to $TESTTMP/repo2
> +  [2]
>

There's a problem with your test starting here. I think you're missing a `cd
..` at the start or something like that.


> +  $ echo "finished work" > newfile
> +  $ hg add newfile
> +  $ hg commit -m "work 2"
> +  $ hg push
> +  pushing to default-push
> +  abort: repository default-push not found!
> +  [255]
> +
> +.. repo1 begins work in progress in newfile
> +  $ cd $TESTTMP/repo1
> +  cd: 52: can't cd to $TESTTMP/repo1
> +  [2]
> +  $ echo "work in progress" > newfile
> +
> +.. repo1 does an update and work in progress is protected
> +  $ hg update
> +  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +
> +.. repo1 does an update --check and work in progress is protected
> +  $ hg update --check
> +  abort: uncommitted local changes
> +  [255]
> +
> +.. repo1 does an update --clean and work in progress is removed
> +  $ hg update --clean
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20110610/6c0cca45/attachment.htm>


More information about the Mercurial-devel mailing list