[PATCH 2 of 5 V2] debugdirstate: add option to drop or add files to dirstate
Laurent Charignon
lcharignon at fb.com
Wed Nov 18 01:18:35 UTC 2015
> On Nov 17, 2015, at 2:54 PM, cdelahousse at fb.com wrote:
>
> # HG changeset patch
> # User Christian Delahousse <cdelahousse at fb.com>
> # Date 1447728959 28800
> # Mon Nov 16 18:55:59 2015 -0800
> # Node ID 7e9f321545b481302597ecdc90e34b62b0b8e54c
> # Parent 6d207a588cef3e66d71dce337b0d2b14d921c600
> debugdirstate: add option to drop or add files to dirstate
>
> Debugging the dirstate helps if you have options to add files for normal lookup
> or drop them form the dirstate. This patch adds flags to the debugdirstate
> command to do just that.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3158,12 +3158,37 @@
> finally:
> wlock.release()
>
> +def _moddirstate(repo, *pats, **opts):
> + '''Manually add or drop a file to the dirstate'''
Why 'manually' here?
Do you mean that this is called when calling debugdirstate to manually add or drop of file from the dirstate?
> + wlock = repo.wlock()
> + try:
> + for file in pats:
> + if opts.get('normal_lookup'):
> + repo.dirstate.normallookup(file)
> + else:
> + repo.dirstate.drop(file)
> + repo.dirstate.write()
> + finally:
> + wlock.release()
> +
> @command('debugdirstate|debugstate',
> [('', 'nodates', None, _('do not display the saved mtime')),
> - ('', 'datesort', None, _('sort by saved mtime'))],
> + ('', 'datesort', None, _('sort by saved mtime')),
> + ('', 'drop', None, _('drop file from dirstate'), _('FILE')),
> + ('', 'normal-lookup', None, _('add file to dirstate'), _('FILE'))],
> _('[OPTION]...'))
> -def debugstate(ui, repo, **opts):
> - """show the contents of the current dirstate"""
> +def debugstate(ui, repo, *pats, **opts):
> + """show or modify the contents of the current dirstate"""
> +
> + drop = opts.get('drop')
> + nl = opts.get('normal_lookup')
> +
> + if not nl is None and not drop is None:
>From looking at the codebase it seems like we prefer using "is not":
"if nl is not None and drop is not None:"
> + raise error.Abort('drop and normal-lookup are mutually exclusive')
> +
> + if nl or drop:
> + _moddirstate(repo, *pats, **opts)
> + return
>
> nodates = opts.get('nodates')
> datesort = opts.get('datesort')
> diff --git a/tests/test-completion.t b/tests/test-completion.t
> --- a/tests/test-completion.t
> +++ b/tests/test-completion.t
> @@ -243,7 +243,7 @@
> debugdag: tags, branches, dots, spaces
> debugdata: changelog, manifest, dir
> debugdate: extended
> - debugdirstate: nodates, datesort
> + debugdirstate: nodates, datesort, drop, normal-lookup
> debugdiscovery: old, nonheads, ssh, remotecmd, insecure
> debugextensions: template
> debugfileset: rev
> diff --git a/tests/test-help.t b/tests/test-help.t
> --- a/tests/test-help.t
> +++ b/tests/test-help.t
> @@ -800,7 +800,7 @@
> debugdata dump the contents of a data file revision
> debugdate parse and display a date
> debugdirstate
> - show the contents of the current dirstate
> + show or modify the contents of the current dirstate
> debugdiscovery
> runs the changeset discovery protocol in isolation
> debugextensions
> diff --git a/tests/test-rebuildstate.t b/tests/test-rebuildstate.t
> --- a/tests/test-rebuildstate.t
> +++ b/tests/test-rebuildstate.t
> @@ -20,6 +20,19 @@
> n 644 -1 set bar
> n 644 -1 set foo
>
> + $ hg debugstate --normal-lookup file1 file2
> + $ hg debugstate --drop bar
> + $ hg debugstate --drop
> + $ hg debugstate --nodates
> + n 0 -1 unset file1
> + n 0 -1 unset file2
> + n 644 -1 set foo
> + $ hg debugstate --normal-lookup file1 --drop file2
> + abort: drop and normal-lookup are mutually exclusive
> + [255]
> +
> + $ hg debugrebuildstate
> +
> status
>
> $ hg st -A
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list