@@ -412,10 +412,18 @@ impl Dependency {
412412 table. insert ( "version" , src. version . as_str ( ) . into ( ) ) ;
413413 }
414414 Some ( Source :: Path ( src) ) => {
415- let relpath = path_field ( crate_root, & src. path ) ;
416415 if let Some ( r) = src. version . as_deref ( ) {
417416 table. insert ( "version" , r. into ( ) ) ;
418417 }
418+ let relative_to = if let Some ( ( base_name, base_value) ) =
419+ src. base_name_and_value . as_ref ( )
420+ {
421+ table. insert ( "base" , base_name. into ( ) ) ;
422+ base_value
423+ } else {
424+ crate_root
425+ } ;
426+ let relpath = path_field ( relative_to, & src. path ) ;
419427 table. insert ( "path" , relpath. into ( ) ) ;
420428 }
421429 Some ( Source :: Git ( src) ) => {
@@ -493,12 +501,20 @@ impl Dependency {
493501 Some ( Source :: Registry ( src) ) => {
494502 overwrite_value ( table, "version" , src. version . as_str ( ) ) ;
495503
496- for key in [ "path" , "git" , "branch" , "tag" , "rev" , "workspace" ] {
504+ for key in [ "path" , "git" , "branch" , "tag" , "rev" , "workspace" , "base" ] {
497505 table. remove ( key) ;
498506 }
499507 }
500508 Some ( Source :: Path ( src) ) => {
501- let relpath = path_field ( crate_root, & src. path ) ;
509+ let relative_to =
510+ if let Some ( ( base_name, base_value) ) = src. base_name_and_value . as_ref ( ) {
511+ overwrite_value ( table, "base" , base_name) ;
512+ base_value
513+ } else {
514+ table. remove ( "base" ) ;
515+ crate_root
516+ } ;
517+ let relpath = path_field ( relative_to, & src. path ) ;
502518 overwrite_value ( table, "path" , relpath) ;
503519 if let Some ( r) = src. version . as_deref ( ) {
504520 overwrite_value ( table, "version" , r) ;
@@ -533,7 +549,7 @@ impl Dependency {
533549 table. remove ( "version" ) ;
534550 }
535551
536- for key in [ "path" , "workspace" ] {
552+ for key in [ "path" , "workspace" , "base" ] {
537553 table. remove ( key) ;
538554 }
539555 }
@@ -552,6 +568,7 @@ impl Dependency {
552568 "rev" ,
553569 "package" ,
554570 "default-features" ,
571+ "base" ,
555572 ] {
556573 table. remove ( key) ;
557574 }
@@ -812,6 +829,8 @@ impl std::fmt::Display for RegistrySource {
812829pub struct PathSource {
813830 /// Local, absolute path.
814831 pub path : PathBuf ,
832+ /// If using a named base, the base and relative path.
833+ pub base_name_and_value : Option < ( String , PathBuf ) > ,
815834 /// Version requirement for when published.
816835 pub version : Option < String > ,
817836}
@@ -821,6 +840,7 @@ impl PathSource {
821840 pub fn new ( path : impl Into < PathBuf > ) -> Self {
822841 Self {
823842 path : path. into ( ) ,
843+ base_name_and_value : None ,
824844 version : None ,
825845 }
826846 }
@@ -843,7 +863,11 @@ impl PathSource {
843863
844864impl std:: fmt:: Display for PathSource {
845865 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
846- self . path . display ( ) . fmt ( f)
866+ if let Some ( ( base_name, _) ) = & self . base_name_and_value {
867+ write ! ( f, "{} (@{base_name})" , self . path. display( ) )
868+ } else {
869+ self . path . display ( ) . fmt ( f)
870+ }
847871 }
848872}
849873
0 commit comments