@@ -315,21 +315,9 @@ def update(rev=None, clean=False, is_local=False):
315
315
shutil .rmtree (fl )
316
316
return Bld .checkout (rev )
317
317
318
- def status ():
319
- return False
320
-
321
- def dirty ():
322
- return False
323
-
324
318
def untracked ():
325
319
return ""
326
320
327
- def outgoing ():
328
- return False
329
-
330
- def isdetached ():
331
- return False
332
-
333
321
def seturl (url ):
334
322
if not os .path .exists ('.' + Bld .name ):
335
323
os .mkdir ('.' + Bld .name )
@@ -356,14 +344,6 @@ def getrev():
356
344
def getbranch ():
357
345
return "default"
358
346
359
- def ignores ():
360
- return True
361
-
362
- def ignore (dest ):
363
- return True
364
-
365
- def unignore (dest ):
366
- return True
367
347
368
348
# pylint: disable=no-self-argument, no-method-argument, no-member, no-self-use, unused-argument
369
349
@scm ('hg' )
@@ -448,9 +428,6 @@ def outgoing():
448
428
raise e
449
429
return 0
450
430
451
- def isdetached ():
452
- return False
453
-
454
431
def geturl ():
455
432
tagpaths = '[paths]'
456
433
default_url = ''
@@ -939,30 +916,53 @@ def getscm(self):
939
916
if os .path .isdir (os .path .join (self .path , '.' + name )):
940
917
return scm
941
918
942
- def getrev (self ):
943
- if self .scm :
919
+ # Pass backend SCM commands and parameters if SCM exists
920
+ def __scm_call (self , method , * args , ** kwargs ):
921
+ if self .scm and hasattr (self .scm , method ) and callable (getattr (self .scm , method )):
944
922
with cd (self .path ):
945
- return self .scm . getrev ( )
923
+ return getattr ( self .scm , method )( * args , ** kwargs )
946
924
947
- def geturl (self ):
948
- if self .scm :
949
- with cd (self .path ):
950
- return self .scm .geturl ().strip ().replace ('\\ ' , '/' )
925
+ def geturl (self , * args , ** kwargs ):
926
+ return self .__scm_call ('geturl' , * args , ** kwargs )
951
927
952
- def ignores (self ):
953
- if self .scm :
954
- with cd (self .path ):
955
- return self .scm .ignores ()
928
+ def getrev (self , * args , ** kwargs ):
929
+ return self .__scm_call ('getrev' , * args , ** kwargs )
956
930
957
- def ignore (self , dest ):
958
- if self .scm :
959
- with cd (self .path ):
960
- return self .scm .ignore (dest )
931
+ def add (self , * args , ** kwargs ):
932
+ return self .__scm_call ('add' , * args , ** kwargs )
961
933
962
- def unignore (self , dest ):
963
- if self .scm :
964
- with cd (self .path ):
965
- return self .scm .unignore (dest )
934
+ def remove (self , * args , ** kwargs ):
935
+ return self .__scm_call ('remove' , * args , ** kwargs )
936
+
937
+ def ignores (self , * args , ** kwargs ):
938
+ return self .__scm_call ('ignores' , * args , ** kwargs )
939
+
940
+ def ignore (self , * args , ** kwargs ):
941
+ return self .__scm_call ('ignore' , * args , ** kwargs )
942
+
943
+ def unignore (self , * args , ** kwargs ):
944
+ return self .__scm_call ('unignore' , * args , ** kwargs )
945
+
946
+ def status (self , * args , ** kwargs ):
947
+ return self .__scm_call ('status' , * args , ** kwargs )
948
+
949
+ def dirty (self , * args , ** kwargs ):
950
+ return self .__scm_call ('dirty' , * args , ** kwargs )
951
+
952
+ def commit (self , * args , ** kwargs ):
953
+ return self .__scm_call ('commit' , * args , ** kwargs )
954
+
955
+ def outgoing (self , * args , ** kwargs ):
956
+ return self .__scm_call ('outgoing' , * args , ** kwargs )
957
+
958
+ def publish (self , * args , ** kwargs ):
959
+ return self .__scm_call ('publish' , * args , ** kwargs )
960
+
961
+ def update (self , * args , ** kwargs ):
962
+ return self .__scm_call ('update' , * args , ** kwargs )
963
+
964
+ def isdetached (self , * args , ** kwargs ):
965
+ return self .__scm_call ('isdetached' , * args , ** kwargs )
966
966
967
967
def getlibs (self ):
968
968
for root , dirs , files in os .walk (self .path ):
@@ -1007,11 +1007,11 @@ def can_update(self, clean, force):
1007
1007
"Preserving local library \" %s\" in \" %s\" .\n Please publish this library to a remote URL to be able to restore it at any time."
1008
1008
"You can use --ignore switch to ignore all local libraries and update only the published ones.\n "
1009
1009
"You can also use --force switch to remove all local libraries. WARNING: This action cannot be undone." % (self .name , self .path ))
1010
- elif not clean and self .scm . dirty ():
1010
+ elif not clean and self .dirty ():
1011
1011
err = (
1012
1012
"Uncommitted changes in \" %s\" in \" %s\" .\n Please discard or stash them first and then retry update.\n "
1013
1013
"You can also use --clean switch to discard all uncommitted changes. WARNING: This action cannot be undone." % (self .name , self .path ))
1014
- elif not force and self .scm . outgoing ():
1014
+ elif not force and self .outgoing ():
1015
1015
err = (
1016
1016
"Unpublished changes in \" %s\" in \" %s\" .\n Please publish them first using the \" publish\" command.\n "
1017
1017
"You can also use --force to discard all local commits and replace the library with the one included in this revision. WARNING: This action cannot be undone." % (self .name , self .path ))
@@ -1419,7 +1419,7 @@ def add(url, path=None, ignore=False, depth=None, protocol=None):
1419
1419
lib .sync ()
1420
1420
1421
1421
lib .write ()
1422
- repo .scm . add (lib .lib )
1422
+ repo .add (lib .lib )
1423
1423
1424
1424
1425
1425
# Remove library
@@ -1432,9 +1432,8 @@ def remove(path):
1432
1432
error ("Could not find library in path (%s)" % path , 1 )
1433
1433
1434
1434
lib = Repo .fromrepo (path )
1435
-
1436
- repo .scm .remove (lib .lib )
1437
1435
rmtree_readonly (lib .path )
1436
+ repo .remove (lib .lib )
1438
1437
repo .unignore (relpath (repo .path , lib .path ))
1439
1438
1440
1439
@@ -1460,16 +1459,16 @@ def publish(all=None, top=True):
1460
1459
1461
1460
sync (recursive = False )
1462
1461
1463
- if repo .scm . dirty ():
1462
+ if repo .dirty ():
1464
1463
action ("Uncommitted changes in %s \" %s\" in \" %s\" " % (repo .pathtype (repo .path ), repo .name , repo .path ))
1465
1464
raw_input ('Press enter to commit and publish: ' )
1466
- repo .scm . commit ()
1465
+ repo .commit ()
1467
1466
1468
1467
try :
1469
- outgoing = repo .scm . outgoing ()
1468
+ outgoing = repo .outgoing ()
1470
1469
if outgoing > 0 :
1471
1470
action ("Pushing local repository \" %s\" to remote \" %s\" " % (repo .name , repo .url ))
1472
- repo .scm . publish (all )
1471
+ repo .publish (all )
1473
1472
except ProcessException as e :
1474
1473
if e [0 ] != 1 :
1475
1474
raise e
@@ -1490,7 +1489,7 @@ def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=Non
1490
1489
1491
1490
repo = Repo .fromrepo ()
1492
1491
1493
- if top and not rev and repo .scm . isdetached ():
1492
+ if top and not rev and repo .isdetached ():
1494
1493
error (
1495
1494
"This %s is in detached HEAD state, and you won't be able to receive updates from the remote repository until you either checkout a branch or create a new one.\n "
1496
1495
"You can checkout a branch using \" %s checkout <branch_name>\" command before running \" mbed update\" ." % (cwd_type , repo .scm .name ), 1 )
@@ -1507,7 +1506,7 @@ def update(rev=None, clean=False, force=False, ignore=False, top=True, depth=Non
1507
1506
repo .revtype (rev , True )))
1508
1507
1509
1508
try :
1510
- repo .scm . update (rev , clean , repo .is_local )
1509
+ repo .update (rev , clean , repo .is_local )
1511
1510
except ProcessException as e :
1512
1511
err = "Unable to update \" %s\" to %s" % (repo .name , repo .revtype (rev , True ))
1513
1512
if depth :
@@ -1594,7 +1593,7 @@ def sync(recursive=True, keep_refs=False, top=True):
1594
1593
else :
1595
1594
if not keep_refs :
1596
1595
action ("Removing reference \" %s\" -> \" %s\" " % (lib .name , lib .fullurl ))
1597
- repo .scm . remove (lib .lib )
1596
+ repo .remove (lib .lib )
1598
1597
repo .unignore (relpath (repo .path , lib .path ))
1599
1598
1600
1599
for root , dirs , files in os .walk (repo .path ):
@@ -1613,7 +1612,7 @@ def sync(recursive=True, keep_refs=False, top=True):
1613
1612
dirs .remove (d )
1614
1613
lib .write ()
1615
1614
repo .ignore (relpath (repo .path , lib .path ))
1616
- repo .scm . add (lib .lib )
1615
+ repo .add (lib .lib )
1617
1616
progress ()
1618
1617
1619
1618
repo .sync ()
@@ -1657,9 +1656,9 @@ def list_(all=False, prefix='', p_path=None, ignore=False):
1657
1656
help = 'Show status of the current %s and its dependencies.' % cwd_type )
1658
1657
def status_ (ignore = False ):
1659
1658
repo = Repo .fromrepo ()
1660
- if repo .scm . dirty ():
1659
+ if repo .dirty ():
1661
1660
action ("Status for \" %s\" :" % repo .name )
1662
- print repo .scm . status ()
1661
+ print repo .status ()
1663
1662
1664
1663
for lib in repo .libs :
1665
1664
if lib .check_repo (ignore ):
@@ -1890,14 +1889,14 @@ def config(toolchain=None, mcu=None, source=False, prefix=None):
1890
1889
parser .print_help ()
1891
1890
sys .exit (1 )
1892
1891
1893
- args , remainder = parser .parse_known_args ()
1892
+ pargs , remainder = parser .parse_known_args ()
1894
1893
status = 1
1895
1894
1896
1895
try :
1897
- very_verbose = args .very_verbose
1898
- verbose = very_verbose or args .verbose
1896
+ very_verbose = pargs .very_verbose
1897
+ verbose = very_verbose or pargs .verbose
1899
1898
log ('Working path \" %s\" (%s)' % (os .getcwd (), cwd_type ))
1900
- status = args .command (args )
1899
+ status = pargs .command (pargs )
1901
1900
except ProcessException as e :
1902
1901
error (
1903
1902
"\" %s\" returned error code %d.\n "
0 commit comments