hgext/narrow/narrowcommands.py
changeset 41043 ce0bc2952e2a
parent 41039 54c3b4bd01f2
child 41076 8ecb17b7f432
equal deleted inserted replaced
41042:7db1619af061 41043:ce0bc2952e2a
   337      ('', 'import-rules', '', _('import narrowspecs from a file')),
   337      ('', 'import-rules', '', _('import narrowspecs from a file')),
   338      ('', 'removeexclude', [], _('old paths to no longer exclude')),
   338      ('', 'removeexclude', [], _('old paths to no longer exclude')),
   339      ('', 'clear', False, _('whether to replace the existing narrowspec')),
   339      ('', 'clear', False, _('whether to replace the existing narrowspec')),
   340      ('', 'force-delete-local-changes', False,
   340      ('', 'force-delete-local-changes', False,
   341        _('forces deletion of local changes when narrowing')),
   341        _('forces deletion of local changes when narrowing')),
       
   342      ('', 'update-working-copy', False,
       
   343       _('update working copy when the store has changed')),
   342     ] + commands.remoteopts,
   344     ] + commands.remoteopts,
   343     _('[OPTIONS]... [REMOTE]'),
   345     _('[OPTIONS]... [REMOTE]'),
   344     inferrepo=True)
   346     inferrepo=True)
   345 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
   347 def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
   346     """show or change the current narrowspec
   348     """show or change the current narrowspec
   396     addedincludes = narrowspec.parsepatterns(opts['addinclude'])
   398     addedincludes = narrowspec.parsepatterns(opts['addinclude'])
   397     removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
   399     removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
   398     addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
   400     addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
   399     removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
   401     removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
   400 
   402 
       
   403     update_working_copy = opts['update_working_copy']
   401     only_show = not (addedincludes or removedincludes or addedexcludes or
   404     only_show = not (addedincludes or removedincludes or addedexcludes or
   402                      removedexcludes or newrules)
   405                      removedexcludes or newrules or update_working_copy)
   403 
   406 
   404     oldincludes, oldexcludes = repo.narrowpats
   407     oldincludes, oldexcludes = repo.narrowpats
   405 
   408 
   406     # filter the user passed additions and deletions into actual additions and
   409     # filter the user passed additions and deletions into actual additions and
   407     # deletions of excludes and includes
   410     # deletions of excludes and includes
   426             fm.write('status', '%s ', 'X', label='narrow.excluded')
   429             fm.write('status', '%s ', 'X', label='narrow.excluded')
   427             fm.write('pat', '%s\n', i, label='narrow.excluded')
   430             fm.write('pat', '%s\n', i, label='narrow.excluded')
   428         fm.end()
   431         fm.end()
   429         return 0
   432         return 0
   430 
   433 
       
   434     if update_working_copy:
       
   435         with repo.wlock(), repo.lock(), repo.transaction('narrow-wc') as tr:
       
   436             narrowspec.updateworkingcopy(repo, tr)
       
   437             narrowspec.copytoworkingcopy(repo, tr)
       
   438         return 0
       
   439 
   431     if not widening and not narrowing:
   440     if not widening and not narrowing:
   432         ui.status(_("nothing to widen or narrow\n"))
   441         ui.status(_("nothing to widen or narrow\n"))
   433         return 0
   442         return 0
   434 
   443 
   435     with repo.wlock(), repo.lock():
   444     with repo.wlock(), repo.lock():