@@ -2358,3 +2358,161 @@ fn get_bookmark_output(work_dir: &TestWorkDir) -> CommandOutput {
23582358 // --quiet to suppress deleted bookmarks hint
23592359 work_dir. run_jj ( [ "bookmark" , "list" , "--all-remotes" , "--quiet" ] )
23602360}
2361+
2362+ #[ test]
2363+ fn test_bookmark_bump ( ) {
2364+ let test_env = TestEnvironment :: default ( ) ;
2365+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2366+ let work_dir = test_env. work_dir ( "repo" ) ;
2367+
2368+ std:: fs:: write ( work_dir. root ( ) . join ( "file1" ) , "content1" ) . unwrap ( ) ;
2369+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2370+ work_dir. run_jj ( [ "bookmark" , "create" , "foo" ] ) . success ( ) ;
2371+ work_dir. run_jj ( [ "new" , "-m=second" ] ) . success ( ) ;
2372+ std:: fs:: write ( work_dir. root ( ) . join ( "file2" ) , "content2" ) . unwrap ( ) ;
2373+ work_dir. run_jj ( [ "new" , "-m=third" ] ) . success ( ) ;
2374+ std:: fs:: write ( work_dir. root ( ) . join ( "file3" ) , "content3" ) . unwrap ( ) ;
2375+
2376+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=description(first)" ] ) ;
2377+ insta:: assert_snapshot!( output, @r###"
2378+ ------- stderr -------
2379+ Moved bookmark foo to zsuskuln 22dbdd9a foo | second
2380+ [EOF]
2381+ "### ) ;
2382+ }
2383+
2384+ #[ test]
2385+ fn test_bookmark_bump_no_bookmark ( ) {
2386+ let test_env = TestEnvironment :: default ( ) ;
2387+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2388+ let work_dir = test_env. work_dir ( "repo" ) ;
2389+
2390+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2391+
2392+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=@" ] ) ;
2393+ insta:: assert_snapshot!( output, @r###"
2394+ ------- stderr -------
2395+ Error: No bookmarks found on 68a505386f936fff6d718f55005e77ea72589bc1 or its ancestors
2396+ [EOF]
2397+ [exit status: 1]
2398+ "### ) ;
2399+ }
2400+
2401+ #[ test]
2402+ fn test_bookmark_bump_no_descendants ( ) {
2403+ let test_env = TestEnvironment :: default ( ) ;
2404+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2405+ let work_dir = test_env. work_dir ( "repo" ) ;
2406+
2407+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2408+ work_dir. run_jj ( [ "bookmark" , "create" , "foo" ] ) . success ( ) ;
2409+
2410+ let output = work_dir. run_jj ( [ "bookmark" , "bump" ] ) ;
2411+ insta:: assert_snapshot!( output, @r###"
2412+ ------- stderr -------
2413+ Error: No non-empty descendants found for revision 68a505386f936fff6d718f55005e77ea72589bc1
2414+ [EOF]
2415+ [exit status: 1]
2416+ "### ) ;
2417+ }
2418+
2419+ #[ test]
2420+ fn test_bookmark_bump_multiple_bookmarks ( ) {
2421+ let test_env = TestEnvironment :: default ( ) ;
2422+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2423+ let work_dir = test_env. work_dir ( "repo" ) ;
2424+
2425+ std:: fs:: write ( work_dir. root ( ) . join ( "file1" ) , "content1" ) . unwrap ( ) ;
2426+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2427+ work_dir
2428+ . run_jj ( [ "bookmark" , "create" , "foo" , "bar" ] )
2429+ . success ( ) ;
2430+ work_dir. run_jj ( [ "new" , "-m=second" ] ) . success ( ) ;
2431+ std:: fs:: write ( work_dir. root ( ) . join ( "file2" ) , "content2" ) . unwrap ( ) ;
2432+
2433+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=description(first)" ] ) ;
2434+ insta:: assert_snapshot!( output, @r###"
2435+ ------- stderr -------
2436+ Warning: Multiple bookmarks found on revision c38d5fac53d0539d9caa10495b207732ef170052: bar, foo
2437+ Hint: Using bookmark: bar
2438+ Moved bookmark bar to zsuskuln 22dbdd9a bar | second
2439+ [EOF]
2440+ "### ) ;
2441+ }
2442+
2443+ #[ test]
2444+ fn test_bookmark_bump_backwards ( ) {
2445+ let test_env = TestEnvironment :: default ( ) ;
2446+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2447+ let work_dir = test_env. work_dir ( "repo" ) ;
2448+
2449+ std:: fs:: write ( work_dir. root ( ) . join ( "file1" ) , "content1" ) . unwrap ( ) ;
2450+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2451+ work_dir. run_jj ( [ "new" , "-m=second" ] ) . success ( ) ;
2452+ std:: fs:: write ( work_dir. root ( ) . join ( "file2" ) , "content2" ) . unwrap ( ) ;
2453+ work_dir. run_jj ( [ "bookmark" , "create" , "foo" ] ) . success ( ) ;
2454+ work_dir. run_jj ( [ "new" , "root()" , "-m=third" ] ) . success ( ) ;
2455+ std:: fs:: write ( work_dir. root ( ) . join ( "file3" ) , "content3" ) . unwrap ( ) ;
2456+
2457+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=description(second)" ] ) ;
2458+ insta:: assert_snapshot!( output, @r###"
2459+ ------- stderr -------
2460+ Error: No non-empty descendants found for revision 63351e1b9362cbf9d47547d2e87a5e3bb8bcab3c
2461+ [EOF]
2462+ [exit status: 1]
2463+ "### ) ;
2464+
2465+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=description(second)" , "--allow-backwards" ] ) ;
2466+ insta:: assert_snapshot!( output, @r###"
2467+ ------- stderr -------
2468+ Error: No non-empty descendants found for revision 63351e1b9362cbf9d47547d2e87a5e3bb8bcab3c
2469+ [EOF]
2470+ [exit status: 1]
2471+ "### ) ;
2472+ }
2473+
2474+ #[ test]
2475+ fn test_bookmark_bump_finds_ancestor_bookmark ( ) {
2476+ let test_env = TestEnvironment :: default ( ) ;
2477+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2478+ let work_dir = test_env. work_dir ( "repo" ) ;
2479+
2480+ std:: fs:: write ( work_dir. root ( ) . join ( "file1" ) , "content1" ) . unwrap ( ) ;
2481+ work_dir. run_jj ( [ "describe" , "-m=first" ] ) . success ( ) ;
2482+ work_dir. run_jj ( [ "bookmark" , "create" , "foo" ] ) . success ( ) ;
2483+ work_dir. run_jj ( [ "new" , "-m=second" ] ) . success ( ) ;
2484+ std:: fs:: write ( work_dir. root ( ) . join ( "file2" ) , "content2" ) . unwrap ( ) ;
2485+ work_dir. run_jj ( [ "new" , "-m=third" ] ) . success ( ) ;
2486+ std:: fs:: write ( work_dir. root ( ) . join ( "file3" ) , "content3" ) . unwrap ( ) ;
2487+
2488+ let output = work_dir. run_jj ( [ "bookmark" , "bump" ] ) ;
2489+ insta:: assert_snapshot!( output, @r###"
2490+ ------- stderr -------
2491+ Moved bookmark foo to zsuskuln 22dbdd9a foo | second
2492+ [EOF]
2493+ "### ) ;
2494+ }
2495+
2496+ #[ test]
2497+ fn test_bookmark_bump_from_parent_with_bookmark ( ) {
2498+ let test_env = TestEnvironment :: default ( ) ;
2499+ test_env. run_jj_in ( "." , [ "git" , "init" , "repo" ] ) . success ( ) ;
2500+ let work_dir = test_env. work_dir ( "repo" ) ;
2501+
2502+ std:: fs:: write ( work_dir. root ( ) . join ( "file1" ) , "content1" ) . unwrap ( ) ;
2503+ work_dir. run_jj ( [ "describe" , "-m=base" ] ) . success ( ) ;
2504+ work_dir. run_jj ( [ "new" , "-m=parent" ] ) . success ( ) ;
2505+ std:: fs:: write ( work_dir. root ( ) . join ( "file2" ) , "content2" ) . unwrap ( ) ;
2506+ work_dir. run_jj ( [ "bookmark" , "create" , "feature" ] ) . success ( ) ;
2507+ work_dir. run_jj ( [ "new" , "-m=child1" ] ) . success ( ) ;
2508+ std:: fs:: write ( work_dir. root ( ) . join ( "file3" ) , "content3" ) . unwrap ( ) ;
2509+ work_dir. run_jj ( [ "new" , "-m=child2" ] ) . success ( ) ;
2510+ std:: fs:: write ( work_dir. root ( ) . join ( "file4" ) , "content4" ) . unwrap ( ) ;
2511+
2512+ let output = work_dir. run_jj ( [ "bookmark" , "bump" , "--from=@" ] ) ;
2513+ insta:: assert_snapshot!( output, @r###"
2514+ ------- stderr -------
2515+ Moved bookmark feature to mzvwutvl 48fcc57d feature | child1
2516+ [EOF]
2517+ "### ) ;
2518+ }
0 commit comments