Commits

Martin Vejnár committed ab29350

Locally modified Mercurial dependencies are now detected.

'hg depst' will now mark locally modified dependencies with 'L' modifier.
Unless forced, 'hg depup' and 'hg depci' will abort in the presence
of modified dependencies.

  • Participants
  • Parent commits 103d5d5

Comments (0)

Files changed (1)

             _save_config(ui, repo, config)
 
 
-def depupdate(ui, repo, rev=None):
+def depupdate(ui, repo, rev=None, force=False):
     '''update dependencies to a configured state
     
     Loads the dependency list from .hgdeps file and applies it.
             for item in manifest.values():
                 if item.dest:
                     scmhandler = _get_scm_handler(ui, repo, manifest, item.alias_name)
+                    if not force and scmhandler.is_locally_modified():
+                        raise util.Abort(_('dependency is locally modified: %s (use -f to override)') % item.alias_name)
                     scmhandler.move(dest=None)
             
             for dependency in deplist:
     M = modified
     A = added
     R = removed
+    L = has local modifications
       = unmodified
     '''
     manifest = _load_manifest(repo)
                 item.dest, _readable_rev(item.scmtype, rev),
                 dep.dest,
                 _readable_rev(alias.scmtype, dep.rev) if alias else dep.rev))
+        elif scmhandler.is_locally_modified():
+            ui.write("L %s %s %s\n" % (item.alias_name,
+                item.dest, _readable_rev(item.scmtype, rev)))
         else:
             ui.note("  %s %s %s\n" % (item.alias_name, item.dest,
                 _readable_rev(item.scmtype, rev)))
             continue
         
         scmhandler = _get_scm_handler(ui, repo, manifest, item.alias_name)
+        if not force and scmhandler.is_locally_modified():
+            raise util.Abort(_('dependency is locally modified: %s (use -f to override)') % item.alias_name)
         rev = scmhandler.get_revision()
         
         deplist.append(dependency(rev, item.alias_name, item.dest))
                 return
             parts.pop()
     
+    def is_locally_modified(self):
+        return False
+    
     def get_revision(self):
         return self.manifest[self.alias_name].rev
     
         raise util.Abort(_('removed alias: %s') % self.alias_name)
 
 class scm_hg(scm_unknown):
+    def is_locally_modified(self):
+        dir = self.manifest.get_dir(self.alias_name)
+        path = self._make_deppath(dir)
+        
+        current_repo = localrepo.localrepository(self.ui, path)
+        for modlist in current_repo.status():
+            if modlist:
+                return True
+        return False
+    
     def get_revision(self):
         dir = self.manifest.get_dir(self.alias_name)
         path = self._make_deppath(dir)
              ('d', 'dest', '', 'destination directory for the dependency')],
             'hg deps [-a ALIAS -r REV -d DEST] [NAME]'),
     
-    'depupdate|depup|depsclone': (depupdate, [], '[NAME]'), 
+    'depupdate|depup|depsclone':
+        (depupdate, [
+            ('f', 'force', None, 'update even if some dependency is locally modified'),
+        ], '[NAME]'),
+    
     'depstatus|depst': (depstatus, [], ''),
     
     'depcommit|depci':